Skip to content

A quantum software stack connects a mathematical task to device operations and interprets the resulting measurements. Some work can happen before a run; some must finish while a quantum state remains coherent; statistical analysis usually combines many runs. Calibration and experimental results also change later compilation decisions, so the process has feedback rather than a single downward sequence.

This page follows those connections. It separates ideal program meaning, target-specific execution, and inference from finite data. The individual representations and compiler transformations are developed in the linked pages.

Required background. Circuit Model defines registers and quantum–classical operations; Universal Gate Sets explains synthesis; Hardware Overview introduces physical controls and device constraints.

Consider estimating an observable after a parameterized state preparation. An algorithm chooses the preparation and measurement. A compiler chooses native gates, physical qubits, and operation order. A controller delivers timed signals and acquires detector data. An estimator turns the outcomes into a value with uncertainty. A fault-tolerant implementation inserts encoded operations, syndrome extraction, decoding, and possibly resource factories.

Stage Main object Question to resolve
Task and algorithm Input, observable, accuracy, success probability Are state preparation and data access included?
Quantum–classical program Gates, measurements, branches, outputs What do the register labels and parameters mean?
Encoded implementation, if used Code operations, syndrome cycles, decoder, factories Which physical resources realize the logical computation?
Compiled circuit Native gates, placement, routing, schedule Are connectivity and simultaneous-operation constraints satisfied?
Control execution Frames, waveforms, acquisitions, branch decisions Do signals and feedback meet the required timing?
Data and inference Outcomes, acceptance flags, estimator, uncertainty Which experimental ensemble does the answer describe?

Not every system exposes each intermediate form. A service may combine passes or hide pulse definitions. The distinction still helps locate a failure: correct source code does not prove that a physical waveform was delivered, and plausible final counts do not prove that the intended circuit ran. Chong, Franklin, and Martonosi review how hardware constraints affect these software choices.

An application needs an input representation, output quantity, accuracy or decision criterion, and allowed failure probability. For phase estimation, phase-grid spacing alone does not specify confidence: the prepared state’s eigenstate weights and the measurement distribution also matter. The phase-estimation article develops those probabilities.

An oracle query, a prepared state, and a classical data table are different access assumptions. Compilation cannot make an omitted preparation cost disappear. Likewise, allowing postselection changes the task unless rejection and the probability of acceptance are included explicitly.

A program can denote a unitary, a channel, an outcome-resolved instrument, or a distribution of reported answers. Compare the relevant object on the specified input class. Equal matrix dimensions or equal gate counts establish none of these equivalences.

For an isolated unitary, global phase does not affect its channel. For a coherently controlled subroutine, that phase becomes relative between control branches and must be retained or compensated. Measurements and reset require channel or instrument semantics, developed in Circuit Intermediate Representations.

An unknown quantum state cannot be copied to avoid recomputation. Discarding a subsystem means taking its partial trace; if it is entangled with live data, the remaining state can be mixed. Reusing that physical subsystem additionally requires its specified initialization or reset. These physical operations are different from merely deleting a name in source code.

For compatible completely positive trace-preserving maps, define

d⋄(E,F)=12∥E−F∥⋄.d_\diamond(\mathcal E,\mathcal F) =\frac12\|\mathcal E-\mathcal F\|_\diamond.

This distance includes inputs entangled with an untouched reference. If stage jj approximates Fj\mathcal F_j by Ej\mathcal E_j within ϵj\epsilon_j, then

E=En∘⋯∘E1,F=Fn∘⋯∘F1,d⋄(E,F)≤∑j=1nϵj.\begin{aligned} \mathcal E&=\mathcal E_n\circ\cdots\circ\mathcal E_1,\\ \mathcal F&=\mathcal F_n\circ\cdots\circ\mathcal F_1,\\ d_\diamond(\mathcal E,\mathcal F)&\le\sum_{j=1}^n\epsilon_j. \end{aligned}

Insert and subtract one stage at a time. The triangle inequality bounds the sum; composition with the surrounding channels cannot increase this norm. Both properties are needed, not merely the existence of some distance between two layer descriptions (Watrous, Chapter 3). Classical records can be retained as orthogonal output labels, so a complete adaptive program also fits this channel description.

When two representations live on different spaces, first specify their input and output encoding or interpretation maps. When physical errors depend on an unmodeled environment or history, separate context-independent stage channels may not exist. One must enlarge the model or bound the whole process. Average gate infidelities are not interchangeable with these worst-case bounds.

Postselection is another qualification. The map including success and failure flags is linear, but normalizing only a successful branch is generally nonlinear in the input. Conditioning on rare acceptance can magnify a small unconditional difference; an accepted-output bound needs acceptance control. The approximation sum is therefore not automatically an experimental error bar or a conditional-fidelity guarantee.

The target includes timing and calibration

Section titled “The target includes timing and calibration”

A device name and qubit count do not determine an executable. Relevant target information includes active connectivity, native operations, durations, concurrency restrictions, measurement/reset capabilities, calibrated frames and waveforms, and controller memory and latency limits. Record the version and calibration time used for a run so that these choices can be interpreted.

Drift can make yesterday’s good placement unsuitable today. Conversely, recompiling for every noisy fluctuation in a scalar calibration estimate can make performance less reliable. Error-Aware Compilation treats the uncertainty in choosing placements and schedules; Murali and colleagues give a concrete noise-adaptive mapping study.

For several modules, the target also includes resource contention, link generation, and memory availability. Modular Architectures explains those physical limits, while Distributed Quantum Computing develops remote operations and program partitioning.

A typical compilation sequence parses and checks the program, simplifies classical control, synthesizes gates, optimizes the circuit, places qubits, inserts movement, schedules operations, and lowers them to controller instructions. A later pass may expose new opportunities for an earlier one: routing can create adjacent inverse gates, and decomposition can expose cancellations. Exact transformations need not commute as representations.

A virtual Z rotation may update a tracked phase without emitting a pulse. Moving or deleting a subsequent operation without carrying that frame changes the physical rotation axis. Timing constraints can also make a formally valid gate identity invalid as a schedule rewrite. Häner and colleagues discuss compilation across abstraction levels; the pulse-control page develops frames and timing.

Gate count, depth, scheduled duration, ancilla count, classical bandwidth, and physical error can compete. Fewer entangling gates may require noisier links or longer idle times. More resource factories may reduce runtime at the cost of qubits and control infrastructure. Compare a Pareto set or state the weights and units of a scalar objective.

An independent-fault model sometimes uses

P(no modeled fault)=∏j(1−pj).P(\text{no modeled fault})=\prod_j(1-p_j).

This is not a generic circuit success probability: a fault can be corrected or irrelevant to the requested observable, and multiple faults can cancel. Coherent errors cannot generally be represented by independent fault events. Spectator effects, crosstalk, and common drift can invalidate even the assumed marginal probabilities. Noise in Quantum Information explains how a component characterization differs from a workload’s effective channel.

Regime Example Timing constraint
Before execution Synthesis, placement, scheduling Finish before the executable is needed and its target assumptions expire
Between executions Variational update or next-experiment selection Usually no live quantum state must survive the calculation
During execution Classification, reset, feedforward, decoder decision Finish before the dependent operation needs the result
After data acquisition Estimation, uncertainty, diagnostic comparisons Preserve the meaning and selection of the measured samples

Cross and colleagues distinguish near-time and real-time classical work in OpenQASM 3. Córcoles and colleagues demonstrate how adaptive execution changes an algorithm’s implementation. A faster classical processor helps only if acquisition, transport, synchronization, and dispatch meet the same deadline.

For a serial feedback path, a simple model is

tff=tacq+tdigitize+tclassify+tdecide+tdispatch+tpropagate.t_{\rm ff}=t_{\rm acq}+t_{\rm digitize}+t_{\rm classify} +t_{\rm decide}+t_{\rm dispatch}+t_{\rm propagate}.

Streaming stages can overlap; then use the actual dependency path rather than adding overlapping durations. Distinguish first-result latency from sustained throughput. Meeting a deadline requires a bound or an accepted tail probability for jitter, not just a favorable mean. A host callback after a job finishes cannot implement a branch acting on quantum data already discarded.

Retain branch states as well as probabilities

Section titled “Retain branch states as well as probabilities”

Let measurement outcome mm have completely positive, trace-nonincreasing map Im\mathcal I_m, with ∑mIm\sum_m\mathcal I_m trace preserving. If the subsequent branch operation Cm\mathcal C_m is trace preserving, then

Jm=Cm∘Im,pm=Tr⁡[Im(ρ)]=Tr⁡[Jm(ρ)].\begin{aligned} \mathcal J_m&=\mathcal C_m\circ\mathcal I_m,\\ p_m&=\operatorname{Tr}[\mathcal I_m(\rho)] =\operatorname{Tr}[\mathcal J_m(\rho)]. \end{aligned}

The normalized branch state is Jm(ρ)/pm\mathcal J_m(\rho)/p_m for pm>0p_m>0. Matching only the final unconditioned state can lose the association between the output and the recorded bit. If a branch operation is itself selective, retain its additional success/failure outcome; its accepted trace is not the original measurement probability. See Quantum Instruments and Mid-Circuit Measurement and Feedforward.

Fault-tolerant resources must arrive on time

Section titled “Fault-tolerant resources must arrive on time”

Encoded execution adds repeated syndrome extraction, decoding, tracked frames, logical movement, and possibly state injection and distillation. A logical gate count alone omits factory placement, storage, routing, and classical processing. Resource Estimation connects these choices to physical qubits and time.

For a resource buffer, write the exact count balance as

B(t)=B(0)+Nadmitted(t)−Nconsumed(t).B(t)=B(0)+N_{\rm admitted}(t)-N_{\rm consumed}(t).

It obeys 0≤B≤Bmax⁡0\le B\le B_{\max}. Potential production is not always admitted production: a full buffer can block a factory or discard outputs. Requested demand is not always consumption: an empty buffer causes a stall unless the schedule can do other work. In a deterministic fluid approximation away from these boundaries, dB/dt=λT−aTdB/dt=\lambda_T-a_T is useful. Average supply greater than demand alone does not exclude shortfalls during bursts. Storage errors and expiry can require another loss term.

A union bound can allocate total failure probability across defined data, factory, routing, decoder, and input/output fault events. It does not require independence, but every failure must be included and each probability must refer to its actual context. Surface Code provides one concrete encoded implementation; it is not the only stack.

Suppose the task asks for C=⟨Z0Z1⟩C=\langle Z_0Z_1\rangle after preparing U(θ)∣00⟩U(\boldsymbol\theta)|00\rangle. The circuit measures both qubits in the computational basis. For shot ss,

Ys=(−1)b0,s⊕b1,s∈{−1,+1}.Y_s=(-1)^{b_{0,s}\oplus b_{1,s}}\in\{-1,+1\}.

With counts n00,n01,n10,n11n_{00},n_{01},n_{10},n_{11} summing to NN,

C^=n00+n11−n01−n10N.\widehat C=\frac{n_{00}+n_{11}-n_{01}-n_{10}}N.

The classical-bit schema matters when identifying which two bits these are. However, exchanging these two bits leaves parity unchanged. This particular observable cannot reveal their interchange; an asymmetric probe such as ⟨Z0⟩\langle Z_0\rangle is needed. A successful parity check therefore does not validate the entire output mapping.

For independent, identically distributed ±1\pm1 observations and fixed N>1N>1, the sample variance is N(1−C^2)/(N−1)N(1-\widehat C^2)/(N-1). The corresponding estimated standard error of the sample mean is

SE⁡^(C^)=1−C^2N−1.\widehat{\operatorname{SE}}(\widehat C) =\sqrt{\frac{1-\widehat C^2}{N-1}}.

With 54005400 even and 46004600 odd outcomes, C^=0.080\widehat C=0.080 and the estimated standard error is about 0.0100.010. A large-sample normal interval is roughly 0.080±0.0200.080\pm0.020 at 95% confidence. This approximation is unsuitable near all-even or all-odd counts: a zero empirical variance does not prove zero uncertainty. A binomial interval for pevenp_{\rm even}, transformed by C=2peven−1C=2p_{\rm even}-1, handles that boundary. Adaptive stopping needs its own coverage analysis.

If these are accepted shots, the estimate concerns the accepted ensemble. Acceptance correlated with the outcome or input generally changes the target. Readout correction changes the estimator and its variance; pooling drifting batches need not satisfy the identical-distribution assumption.

Sampling error does not include every bias

Section titled “Sampling error does not include every bias”

Let μtarget\mu_{\rm target} be the ideal quantity and μimpl\mu_{\rm impl} the actual expectation under the stated sampling and selection model. Then

μ^−μtarget=(μ^−μimpl)+(μimpl−μtarget).\widehat\mu-\mu_{\rm target} =(\widehat\mu-\mu_{\rm impl}) +(\mu_{\rm impl}-\mu_{\rm target}).

The first term has mean zero only if the estimator is unbiased for that model. The second describes implementation or modeling bias. More shots need not reduce either an estimator’s own bias or the difference between actual and ideal expectations. Calibration, detector errors, synthesis, and selection need separate analysis. Reading Quantum-Technology Claims develops these distinctions beyond this example.

Check software meaning and physical execution separately

Section titled “Check software meaning and physical execution separately”

For small isolated unitary circuits, compare matrices up to global phase, with a specified norm. Retain the phase for coherent controlled use. For adaptive circuits compare outcome-resolved maps, including probabilities and conditional states for every allowed input, not just one test state. Structural checks also verify resource conflicts, data dependencies, frames, and timing.

Exact dense comparison grows exponentially. Formal proofs, specialized equivalence methods, and independently generated small examples complement each other. Hietala and colleagues’ VOQC proves transformations against its mathematical circuit semantics; that proof does not certify an unmodeled controller, waveform, or device. Physical checks must additionally test measurement labels, branch execution, timing, and calibration validity.

Parsing the same source does not guarantee support for its operations or timing. A backend’s supported language profile and target capabilities matter. Two implementations can preserve ideal behavior while having very different gate counts, latency, and physical error. Splitting an adaptive program into separate jobs is equivalent only if its quantum state and dependencies survive the split; syntax acceptance does not establish this.

For a published run retain source and parameters, compiler versions/options, randomized-routing seeds, target/calibration information, physical and output mappings, executable identity, timestamps, outcomes with acceptance flags, and analysis code. Preserve batch boundaries when conditions change. The reproducible-notebook guide develops a runnable workflow rather than another list of software layers.

Retries need explicit handling: a lost reply does not tell the client whether the device ran. Stable request identifiers and recorded execution status help avoid silently duplicating samples. Missing or outcome-dependent rejected records can bias an estimate even if the completed circuits are correct. Reproducibility means reconstructing the procedure and expected variation, not forcing a future noisy device to return the same bit string.

Two exact compiler passes satisfy ⟦τ1(x)⟧=⟦x⟧\llbracket\tau_1(x)\rrbracket=\llbracket x\rrbracket and ⟦τ2(x)⟧=⟦x⟧\llbracket\tau_2(x)\rrbracket=\llbracket x\rrbracket. Must they produce the same cost when applied in opposite orders?

Solution

No. Semantic preservation does not imply that the transformations commute or have identical cost effects:

τ2 ⁣∘τ1(x)≠τ1 ⁣∘τ2(x)\tau_2\!\circ\tau_1(x) \neq \tau_1\!\circ\tau_2(x)

as representations, even though both can denote the same computation. Decomposition can expose cancellations; routing can create new adjacent gates; and scheduling can constrain later rewrites. Pass order is therefore part of the optimization configuration and provenance.

Four compatible channel stages have certified half-diamond distances 2×10−42\times10^{-4}, 5×10−45\times10^{-4}, 10−310^{-3}, and 3×10−43\times10^{-4}. Give a conservative composed bound and state one reason it may not be a complete experimental error estimate.

Solution

A telescoping expansion and contractivity under the surrounding channels give

ϵsem≤2.0×10−3.\epsilon_{\mathrm{sem}} \leq 2.0\times10^{-3}.

This is conservative and valid only for compatible channel domains and the stated metric. Unmodeled drift, leakage, correlated faults, detector bias, or a mismatch between the certified model and the physical device can add error not present in the four terms.

A serial feedback path with nonoverlapping stages uses 300300 ns acquisition, 8080 ns digitization, 120120 ns classification, 4040 ns decision logic, 9090 ns dispatch, and 7070 ns propagation. The deadline is 900900 ns and the required engineering margin is 15%15\% of the deadline. Is the path admissible?

Solution

The nominal path is

tff=(300+80+120) ns+(40+90+70) ns=700 ns.\begin{aligned} t_{\mathrm{ff}} &= (300+80+120)\,\mathrm{ns} +(40+90+70)\,\mathrm{ns}\\ &= 700\ \mathrm{ns}. \end{aligned}

The margin is 0.15(900 ns)=135 ns0.15(900\ \mathrm{ns})=135\ \mathrm{ns}, so the admissible latency is 765765 ns. Since 700700 ns is below 765765 ns, the nominal design meets the requirement with 6565 ns remaining. Jitter and worst-case rather than mean latencies must still be checked.

A compiler estimates a candidate’s no-fault proxy as a product of independent gate no-fault probabilities. Give two physical effects that can make the ranking unreliable even when every marginal gate error estimate is accurate.

Solution

Coherent overrotations can add constructively or cancel depending on sequence and phase, so a product of marginal probabilities misses circuit structure. Simultaneous-operation crosstalk can make a gate’s error depend on the schedule and spectator states. Leakage persistence, common-mode drift, and correlated radiation events are other valid examples.

A dynamic program measures a qubit and applies XX when the result is one. Why is unitary matrix comparison insufficient for validating a compiler pass that rewrites this fragment?

Solution

Measurement is not a unitary operation on the program’s visible state. It produces an outcome distribution, updates the conditional quantum state, and creates a classical record used by the branch. Validation must compare the outcome-resolved instrument or every branch probability and conditional state for every allowed input. A unitary matrix has no place to encode those semantics.

A magic-state factory produces one state every 1212 code cycles. The scheduled computation consumes bursts of five states every 5050 cycles. Does the average supply exceed average demand, and is that alone sufficient to avoid stalls?

Solution

The supply rate is 1/12≃0.08331/12\simeq0.0833 states per cycle. The average demand is 5/50=0.105/50=0.10 states per cycle, so supply is already insufficient on average and the buffer will eventually empty.

Even if average supply exceeded demand, it would not alone prevent stalls. Burst timing and buffer capacity matter. The inventory must contain five usable states at each burst, including losses, verification failures, and routing latency.

One backend accepts an OpenQASM program but lowers unsupported dynamic branches by splitting it into host-controlled jobs. Another executes the branches in its controller. Which portability claims hold?

Solution

Both may provide source or syntax portability. Semantic portability holds only if splitting preserves quantum-state continuity, branch behavior, and all required timing. Fresh jobs that reinitialize live data generally fail this test. Real-time target portability does not hold: the host-controlled backend cannot implement a coherence-bound branch merely by accepting the source. Performance portability also need not hold because queue and network latency can dominate the split execution.

In the correlator example, N=2 500N=2\,500 accepted trials give n00+n11=1 450n_{00}+n_{11}=1\,450 and n01+n10=1 050n_{01}+n_{10}=1\,050. Compute C^\widehat C and its estimated standard error under the independent, identically distributed fixed-size sampling model.

Solution

The estimator is

C^=1450−10502500=0.16.\widehat C = \frac{1450-1050}{2500} = 0.16.

Therefore

SE⁡^(C^)=1−0.1622499≃0.0197.\widehat{\operatorname{SE}}(\widehat C) = \sqrt{ \frac{1-0.16^2}{2499} } \simeq 0.0197.

This quantifies sampling fluctuation under the stated model, not readout, compilation, or drift bias.

9. A symmetric observable hides a swapped mapping

Section titled “9. A symmetric observable hides a swapped mapping”

The intended two-qubit output is ∣01⟩|01\rangle, but the reported labels are interchanged. Compare the original and reported ⟨Z0Z1⟩\langle Z_0Z_1\rangle and ⟨Z0⟩\langle Z_0\rangle. Which detects the error?

Solution

Both ∣01⟩|01\rangle and ∣10⟩|10\rangle have parity −1-1, so the correlator is unchanged. The first-qubit expectation changes from +1+1 to −1-1. A parity-only check cannot detect this permutation; the asymmetric observable can.

10. Conditioning amplifies an unconditional difference

Section titled “10. Conditioning amplifies an unconditional difference”

Two classical output distributions over (reject,accept0,accept1)(\text{reject},\text{accept0}, \text{accept1}) are (1−p,p,0)(1-p,p,0) and (1−p,0,p)(1-p,0,p) for p>0p>0. Compute their total-variation distance before and after acceptance.

Solution

Before selection, half the sum of absolute differences is pp. After selection the output is certainly 0 in the first case and certainly 1 in the second, so the distance is 1. Arbitrarily small unconditional error can coexist with completely different rare accepted outputs. Retaining the acceptance flag avoids confusing these two questions.

  • F. T. Chong, D. Franklin, and M. Martonosi, “Programming languages and compiler design for realistic quantum hardware,” Nature 549, 180–187 (2017), doi:10.1038/nature23459.
  • A. D. Córcoles et al., “Exploiting dynamic quantum circuits in a quantum algorithm with superconducting qubits,” Physical Review Letters 127, 100501 (2021), doi:10.1103/PhysRevLett.127.100501; arXiv:2102.01682.
  • A. W. Cross et al., “OpenQASM 3: A broader and deeper quantum assembly language,” ACM Transactions on Quantum Computing 3, Article 12 (2022), doi:10.1145/3505636; arXiv:2104.14722.
  • T. Häner, D. S. Steiger, K. Svore, and M. Troyer, “A software methodology for compiling quantum programs,” Quantum Science and Technology 3, 020501 (2018), doi:10.1088/2058-9565/aaa5cc.
  • K. Hietala, R. Rand, S.-H. Hung, X. Wu, and M. Hicks, “A verified optimizer for quantum circuits,” Proceedings of the ACM on Programming Languages 5, Article 37 (2021), doi:10.1145/3434318; arXiv:1912.02250.
  • P. Murali, J. M. Baker, A. Javadi-Abhari, F. T. Chong, and M. Martonosi, “Noise-adaptive compiler mappings for noisy intermediate-scale quantum computers,” in Proceedings of ASPLOS 2019, 1015–1029 (2019), doi:10.1145/3297858.3304075.
  • M. A. Nielsen and I. L. Chuang, Quantum Computation and Quantum Information, 10th anniversary ed. (Cambridge University Press, 2010), doi:10.1017/CBO9780511976667.
  • J. Watrous, The Theory of Quantum Information (Cambridge University Press, 2018), Chapter 3, author’s manuscript.