Backpropagate Observables Mcp
Backpropagate observables through a circuit to shorten what must be run.
Use this tool to move part of the computation from the circuit into the observable: Haiqu rewrites each observable through the tail of the circuit and stores a correspondingly shortened circuit. Running the shorter circuit with the rewritten observable estimates the same expectation value with less hardware noise.
When to Use:
- Call this when the user wants expectation values from a circuit that is too deep to run faithfully on hardware.
- Call this before
run_circuits_on_qpu_or_simulatorfor expectation-value workloads, and pass the returned circuit and observable together.
Constraints:
- Backpropagation is synchronous and runs no quantum job.
- Each input observable yields one output circuit, so
optimized_circuit_idsandbackpropagated_observablesare aligned by index and must be used as pairs. - Truncation budgets trade accuracy for depth. Without
max_error_totalormax_error_per_slicethe rewritten observable can grow large.
Notes:
- Pauli coefficients are given and returned as
(pauli, real, imaginary)triples. - Compare the returned circuits against the input with
get_circuit_by_idto show how much depth was removed.
Args: user: Authenticated user resolved from the API key. data: Circuit identifier, observables, and optional truncation budgets. db: Active database session.
Returns: The generated circuit IDs with their rewritten observables.
Raises:
HTTPException: Raised with 404 when the circuit is not available to
the caller, 422 when an observable cannot be parsed, or 501
when the backpropagation dependency is unavailable.
Authorizations
Body
Define payload for backpropagating observables through a circuit.
Attributes:
circuit_id: Circuit to backpropagate through.
observables: Observables as lists of (pauli, real, imaginary) terms.
max_qwc_groups: Optional cap on qubit-wise-commuting groups.
max_error_total: Optional total truncation error budget.
max_error_per_slice: Optional per-slice truncation error budget.
Observables to backpropagate. Each observable is a list of Pauli terms given as [pauli_string, real_coefficient, imaginary_coefficient], for example [["ZZ", 1.0, 0.0], ["XX", 0.5, 0.0]].
Optional cap on the number of qubit-wise-commuting groups retained.
Optional total truncation error budget across the backpropagation.
Optional truncation error budget per circuit slice.
Response
Successful Response
Represent the outcome of an observable backpropagation.
Attributes:
optimized_circuit_ids: Circuits produced by the backpropagation, one per
input observable.
backpropagated_observables: Rewritten observables as
(pauli, real, imaginary) term lists.
context: Summary of what was produced and the next step.