> For the complete documentation index, see [llms.txt](https://docs.sirraya.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sirraya.org/examples/full_pipeline.md).

# full\_pipeline

QASM in, real optimization, real per-backend lowering, real fidelity budgets, real execution — across all three backends, in one file.

```bash
cargo run --example full_pipeline
```

## What it does

Parses a 3-qubit QASM program (`h`, `cx`, `t`, `ryy`, `swap`, `cp` — a genuine mix, not a toy circuit), runs source-level optimization, then walks two paths:

**TrappedIon-specific path:** decompose to native `{Rz, Ry, Rzz}`, peephole-optimize, estimate fidelity against Quantinuum Helios's published calibration (the specific figures that gate set describes), execute on the simulator, print the resulting probability distribution.

**Multi-backend path:** for each of `TrappedIon`, `IbmQ`, `Rigetti`, lower the *same* source circuit to that backend's own native gate set, estimate fidelity against *that backend's own* published calibration (not one backend's numbers reused for another's gate counts), and actually execute it — not just gate-count it.

```rust
for backend in [Backend::TrappedIon, Backend::IbmQ, Backend::Rigetti] {
    let bc: BackendCircuit = lower(&circuit, backend);
    let backend_cal = backend.calibration();
    let backend_fidelity = estimate_backend_circuit_fidelity(&bc, &backend_cal);
    let backend_reg = emit::run_backend(&bc)?;
    print_distribution(&backend_reg);
}
```

## Why it matters

The detail worth noticing: every backend is judged against its *own* calibration data. It would be easy (and wrong) to compute one fidelity number and apply it across backends — this example is explicit that TrappedIon is judged against Quantinuum Helios, IbmQ against IBM Heron r2, Rigetti against Rigetti Ankaa-3, because those are the devices those published figures actually describe.

## Related

* [`pipeline_end_to_end`](/examples/pipeline_end_to_end.md) — same shape, plus circuit diagrams, real sampled measurements, and IBM QASM export
* [`backend_cost_comparison`](/examples/backend_cost_comparison.md) — the comparison-focused version of this same multi-backend loop


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.sirraya.org/examples/full_pipeline.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
