Skip to main content
This guide walks through composing a hybrid program from layers and running it with haiqu.flow. If you are new to layers and programs, read the overview first.
1

Authenticate and start an experiment

Log in and initialize an experiment so your circuits and jobs are tracked.
You’re authenticated and ready to build a program. See the login reference for API-key options.
2

Build a program

A program is an ordered list of layers. Start with an InputLayer, end with a DeviceLayer, and add processing steps in between.
The program is validated as you build it — for example, leaving out the DeviceLayer raises an error.
3

Run the flow

Pass the program and your circuit(s) to haiqu.flow.
haiqu.flow returns a job handle you can track and collect results from.
4

Read the results

Call job.result() to retrieve the output.
Results come back as a nested list ordered by circuits → observables → parameters. With a single circuit and no observables, that is a one-element list holding the measurement distribution (bitstrings in Qiskit bit-order).
You’ve built and run your first hybrid program.

Worked examples

Measure observables

Supply observables to get expectation values instead of a distribution. A program that takes observables needs a layer that computes them; the simplest choice is the grouped EstimatorLayer, which evaluates the observables and applies error mitigation. The order of Pauli terms in a string follows the Qiskit reversed-order convention (for example, "IZ" measures qubit 0 in the Z basis).
Configure the mitigation through the layer’s flags — for example EstimatorLayer(noise_tailoring=True), or EstimatorLayer(mitigation_enabled=False) to turn it off. For full control, compute the observables by hand instead of using the grouped EstimatorLayer: split them with ObservableSplitLayer and evaluate them with QWCComputeLayer.
Building a program only validates its structure. A program that passes observables but has no EstimatorLayer (or ObservableSplitLayerQWCComputeLayer) is rejected when you call haiqu.flow, not when you construct it.

A full pipeline

Compose transpilation, packing, and error mitigation into one program. Each layer applies its step in order before the circuits reach the device:

Sweep over parameters

Pass parameters to run a parametrized circuit at several values. The extra dimension appears last in the result ordering:
Estimate cost before running. Pass dry_run=True to stop just before device execution and estimate the QPU cost. job.result() is then empty; read job.estimated_qpu_cost instead.
See the haiqu.flow reference for the full signature and every supported combination of circuits, parameters, and observables, and the hybrid program reference for all layers and their parameters.