Skip to main content

Hybrid programs

A hybrid program is an ordered pipeline of layers describing how your circuits are processed and run. Build one with HybridProgram 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 an InputLayer 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.
The list of layers must satisfy:
  • It is not empty.
  • The first layer is an InputLayer, and the last is a DeviceLayer.
  • There is exactly one InputLayer and exactly one DeviceLayer (neither appears in the middle).
  • It contains at most one grouped mitigation layer — EstimatorLayer or DistributionMitigationLayer — as the two are mutually exclusive.

Example

Layers

A layer is a single processing step in a program. Construct layers from the layers 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 {}.

Circuit processing

layers.TranspilationLayer(optimization_level=None)

Transpile the circuits for the target backend.
  • Parameters:
    • optimization_level (int | None) — The optimization effort, 03. Leave unset (None) for the backend default.

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.

Error mitigation (grouped)

A program uses at most one of these. Choose EstimatorLayer 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 {}.

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 as EstimatorLayer.

Individual processing steps

Finer-grained steps for building a custom pipeline by hand instead of the grouped error-mitigation layers above. Each takes no parameters.

layers.ObservableSplitLayer()

Split a task with several observables into one task per observable.

layers.NoiseTailoringLayer()

Tailor device noise with Pauli twirling.

layers.DynamicalDecouplingLayer()

Suppress idle-qubit errors with dynamical-decoupling sequences.

layers.AdvancedReadoutMitigationLayer()

Advanced measurement (readout) error mitigation.

layers.QWCComputeLayer()

Compute observable expectation values from grouped commuting measurements.