Hybrid programs
A hybrid program is an ordered pipeline of layers describing how your circuits are processed and run. Build one withHybridProgram and execute it with haiqu.flow. See the
Hybrid programs overview for a conceptual introduction.
HybridProgram(layers, schema_version=1)
A pipeline of layers, validated on construction. It starts with anInputLayer and ends with a
DeviceLayer.
- Parameters:
- layers (list *[*Layer ]) — The ordered list of layers that make up the program.
- schema_version (int) — The wire-format version. Defaults to
1.
- Raises: ValueError — if the layers do not satisfy the structural rules below.
- It is not empty.
- The first layer is an
InputLayer, and the last is aDeviceLayer. - There is exactly one
InputLayerand exactly oneDeviceLayer(neither appears in the middle). - It contains at most one grouped mitigation layer —
EstimatorLayerorDistributionMitigationLayer— as the two are mutually exclusive.
Example
Layers
A layer is a single processing step in a program. Construct layers from thelayers module and pass
them to HybridProgram.
Required layers
layers.InputLayer()
The program’s entry point. Every program starts with one. Takes no parameters.layers.DeviceLayer(device_id, options=)
Runs the circuits on a backend; every program ends with one.- Parameters:
- device_id (str) — The backend to run on (e.g.
"aer_simulator","fake_torino"). - options (dict) — Backend-specific settings (e.g. credentials). Defaults to
{}.
- device_id (str) — The backend to run on (e.g.
Circuit processing
layers.TranspilationLayer(optimization_level=None)
Transpile the circuits for the target backend.- Parameters:
- optimization_level (int | None) — The optimization effort,
0–3. Leave unset (None) for the backend default.
- optimization_level (int | None) — The optimization effort,
layers.PackingLayer(pack_size=None)
Pack several copies of a circuit into one run to use spare device qubits.- Parameters:
- pack_size (int | None) — The number of copies to pack; must be
>= 2. Leave unset (None) to pick a value automatically from the circuit and device sizes.
- pack_size (int | None) — The number of copies to pack; must be
Error mitigation (grouped)
A program uses at most one of these. ChooseEstimatorLayer when you measure observables
(expectation values), and DistributionMitigationLayer when you read the raw measurement
distribution. The flags turn individual techniques on or off.
layers.EstimatorLayer(mitigation_enabled=True, advanced_mitigation=True, readout_mitigation=True, noise_tailoring=False, dynamical_decoupling=True, readout_mitigation_options=)
Measure observable expectation values with error mitigation. Use this when the job supplies observables.- Parameters:
- mitigation_enabled (bool) — Master switch for error mitigation. Defaults to
True. - advanced_mitigation (bool) — Toggle advanced mitigation. Defaults to
True. - readout_mitigation (bool) — Toggle readout error mitigation. Defaults to
True. - noise_tailoring (bool) — Toggle noise tailoring via Pauli twirling. Defaults to
False. - dynamical_decoupling (bool) — Toggle dynamical decoupling. Defaults to
True. - readout_mitigation_options (dict) — Extra settings for readout mitigation. Defaults to
{}.
- mitigation_enabled (bool) — Master switch for error mitigation. Defaults to
layers.DistributionMitigationLayer(mitigation_enabled=True, advanced_mitigation=True, readout_mitigation=True, noise_tailoring=False, dynamical_decoupling=True, readout_mitigation_options=)
Mitigate errors on the raw measured probability distribution. Use this when the job reads measurement outcomes (no observables). Takes the same parameters asEstimatorLayer.