State compression
Haiqu.state_compression(circuit: QuantumCircuit | CircuitModel, compression_level: str = ‘balanced’, noise_profile: str = ‘default’, fine_tuning: str = ‘low’, approximation_level: int | None = None) → StateCompressionJobModel
Compress an arbitrary quantum circuit. Haiqu’s state compression is an approximate fixed-input-state compilation method to extend the effective depth of circuits that can be executed on noisy hardware. It features several tunable parameters to adjust the trade-off between compression level and circuit quality, allowing the user to tailor the compression to the circuit and device noise characteristics. Both the input and output circuits are assumed to be applied to the all-zero state (|00⋯0⟩). The action of the circuit
on other input states is not preserved by the compression.
- Parameters:
- circuit (QuantumCircuit | CircuitModel) — The quantum circuit to be compressed.
-
compression_level (str) —
The qualitative compression level. Three options are available:
- “low”: best used for shallow input circuits or very low noise levels
- “balanced” (default): gives the best performance for most circuits and noise profiles
- “high”: may sometimes yield better results for very deep circuits
- noise_profile (str) — The device noise profile to assume during compression. The currently available options are: “ibm_eagle_r3”, “ibm_heron_r1”, “ibm_heron_r2” (default), “ibm_heron_r3”, “iqm_garnet” and “iqm_emerald”.
-
fine_tuning (str) —
The extent to which classical resources should be used to further improve the compressed circuit.
Three options are available:
- “disabled”: no fine-tuning is performed, yielding the lowest latency
- “low” (default): best balance between speed and accuracy
- “heavy”: improved circuit accuracy, but time-intensive
-
approximation_level (int | None) — A small integer related to circuit complexity. Larger values improve the noiseless
quality metric, but may degrade noisy performance. Defaults to
None, which corresponds to auto-selection using the chosennoise_profile.
- Returns: The State Compression job that will generate the compressed circuit.
- Return type: StateCompressionJobModel
Examples
Generate a circuit:Observable backpropagation
Haiqu.observable_backpropagation(circuit: QuantumCircuit | CircuitModel, observables: SparsePauliOp | list[SparsePauliOp], max_qwc_groups: int | None = 50, max_error_total: float | None = 0.05, max_error_per_slice: float | None = 0.005, log: bool = True) → tuple[list[QuantumCircuit] | list[CircuitModel], list[SparsePauliOp]]
Optimize the observables for a circuit with observable backpropagation. This method wraps the Qiskit Operator Backpropagation (OBP) functionality to preprocess your circuits and observables for efficient execution.- Parameters:
- circuit (QuantumCircuit | CircuitModel) — The quantum circuit to optimize.
- observables (SparsePauliOp | list *(*SparsePauliOp )) — The observable(s) to optimize. Can be a single
SparsePauliOpor list ofSparsePauliOp. The order of Pauli terms follows the Qiskit reversed-order convention. - max_qwc_groups (int) — Maximum number of qubit-wise commuting groups to create. Defaults to 50. Treat with caution as increasing this value may lead to SIGNIFICANTLY higher computational costs!
- max_error_total (float) — Maximum error allowed for the entire circuit. Defaults to 0.05.
- max_error_per_slice (float) — Maximum error allowed per slice of the circuit. Defaults to 0.005.
- log (bool) — If
True(default), logs the reduced circuits to the Haiqu cloud.
- Returns: A list of reduced circuits and a list of backpropagated observables.
- Return type: tuple[list, list]