> ## Documentation Index
> Fetch the complete documentation index at: https://docs.haiqu.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# QEC Run

> Run QEC-compiled circuits under noise and decode the outcomes on the Haiqu cloud.

A QEC run samples circuits that are compiled to a quantum error-correcting code, with
[qec\_compile](https://docs.haiqu.ai/reference/run/qec_compile.md) or during the run, under a noise
model. In each shot, the syndrome measured in the error-correction cycles is decoded, and the
decoder's correction is applied to the measured outcome. The run executes asynchronously on the Haiqu
cloud as a job, and the result of the job holds, for each circuit, the decoded counts of the circuit's
classical bits and the logical error rate.

Problems that are found when the job runs, such as a decoder that cannot decode a circuit, do not
raise an error in the call to `haiqu.qec_run`. They make the job fail, and the job's
[`result()`](#haiqu.sdk.schemas.QECRunJobModel.result) raises [`JobFailedError`](#haiqu.sdk.exceptions.JobFailedError),
whose message describes the problem and, for a problem in one circuit, names the circuit and the step that
failed. A run job that has not
finished after 30 minutes is cancelled, and `result` then raises
[`JobCancelledError`](#haiqu.sdk.exceptions.JobCancelledError).

After an update of the Haiqu cloud, circuits compiled before the update may need to be compiled
again: running them then makes the job fail with a message saying so.

# End-to-end example

The example compiles a one-qubit circuit whose ideal outcome is always `0` to the code
`"color_488_d3"`. It first runs the compiled circuit without noise, as a check, then with noise,
and finally sweeps the noise strength. The noisy runs use `"tesseract"`, the most accurate decoder
(see [Decoders](https://docs.haiqu.ai/reference/run/qec_run.md#decoders)).

```python theme={null}
from qiskit import QuantumCircuit
from haiqu.sdk import haiqu

haiqu.login()
haiqu.init("qec-run")

circuit = QuantumCircuit(1, 1)
circuit.h(0)
circuit.h(0)
circuit.measure(0, 0)

compiled = haiqu.qec_compile(circuit, code="color_488_d3").result()

# Without noise, every shot gives the ideal outcome.
noise = {"p1q": 0, "p2q": 0, "p_meas": 0}
result = haiqu.qec_run(compiled, shots=1000, noise=noise).result()
print(result.counts)  # {'0': 1000}
print(result.logical_error_rate)  # 0.0

# With noise, the decoder corrects most, but not all, of the errors.
noise = {"p1q": 1e-3, "p2q": 1e-3, "p_meas": 1e-3}
result = haiqu.qec_run(compiled, shots=10_000, noise=noise, decoder="tesseract").result()
print(result.decoder)  # tesseract
print(result.counts)  # mostly '0', a small number of '1'
print(result.logical_error_rate)  # a small probability, for example 0.003

# Noise sweep: collect the jobs, then read every result.
strengths = [1e-3, 2e-3, 5e-3]
jobs = []
for p in strengths:
    noise_p = {"p1q": p, "p2q": p, "p_meas": p}
    jobs.append(haiqu.qec_run(compiled, shots=10_000, noise=noise_p, decoder="tesseract"))
for p, job in zip(strengths, jobs):
    print(p, job.result().logical_error_rate)
```

# Noise model

The noise model, given in `noise`, applies uniform noise to the compiled circuit, that is to the
gates and measurements on the physical qubits. It has three channels, each given by a probability
in `[0, 1]`:

* `p1q`: depolarizing noise after every single-qubit gate, including identity gates. With
  probability `p1q`, one of the Pauli operators X, Y and Z, chosen uniformly at random, is applied
  to the qubit. A logical `id` gate is compiled into identity gates on the data qubits of its code
  block, so `id` gates are how idle time, for example in a memory experiment, receives noise.
* `p2q`: two-qubit depolarizing noise after every two-qubit gate. With probability `p2q`, one of
  the 15 non-identity two-qubit Pauli operators, chosen uniformly at random, is applied to the two
  qubits.
* `p_meas`: with probability `p_meas`, the outcome of a measurement is flipped. This applies to
  every measurement, syndrome measurements and data measurements alike.

Reset instructions and barriers are noiseless, and there is no other noise on idle qubits.

By default, noise is applied in every part of the compiled circuit, including the circuits that
prepare and reset logical qubits. How these are implemented, including whether they are
fault-tolerant, is defined by the code's `.qecx` file. To restrict noise to selected parts of the
compiled circuit, for example to the error-correction cycles, use the `toggles` argument, as
explained in [Targeted noise in QEC runs](https://docs.haiqu.ai/reference/run/qec_noise.md).

# Decoders

The decoder turns the syndrome measured in the error-correction cycles into a correction of the
outcome. The `decoder` argument takes one of five values:

| Value | Decoder |
| - | - |
| `"auto"` (default) | The first decoder that the code's QECX file declares, in the order `"chromobius"`, `"pymatching"`, `"tesseract"`, `"bposd"`, and `"pymatching"` for a code whose file declares none. The library's color codes declare Chromobius and PyMatching, so `"auto"` selects `"chromobius"` for them. A declared decoder can decode the code, but not necessarily every circuit well: see the limitations of each decoder below. |
| `"pymatching"` | The PyMatching decoder. It runs with every code and is fast, but it does not reliably correct errors on codes in the color family, and it corrects fewer errors on circuits whose faults each affect more than two checks, such as circuits with a `cx` between two code blocks. |
| `"chromobius"` | The Chromobius decoder, for color codes whose QECX file declares color information for it. It is fast, but it decodes less accurately across a logical S gate, and it makes the job fail on some circuits (see [Current limitations](https://docs.haiqu.ai/reference/run/qec_run.md#current-limitations)). |
| `"bposd"` | A belief-propagation decoder with ordered-statistics post-processing (BP-OSD). It runs with every code, but it is slow, and with its current settings it can decode some single faults on small codes incorrectly. |
| `"tesseract"` | The Tesseract decoder, a search-based decoder. It is the most accurate of these decoders and decodes circuits that the others decode poorly or not at all, but it is much slower: depending on the code, the circuit and the noise strength, decoding can take tens to thousands of times as long, and its time grows steeply with the noise strength and the code distance. |

Chromobius, which `"auto"` selects for the library's color codes, is faster than Tesseract but
usually reports higher logical error rates on them;
across a logical S gate, which a code such as `color_488_d3` also uses for a logical `x`, the gap
is larger. Use `"tesseract"` when accuracy matters. For example, for the noisy run of the
[End-to-end example](https://docs.haiqu.ai/reference/run/qec_run.md#end-to-end-example):

```python theme={null}
result = haiqu.qec_run(compiled, shots=10_000, noise=noise, decoder="chromobius").result()
print(result.logical_error_rate)  # for example 0.01, against about 0.003 with "tesseract"
```

The decoder that was used, with `"auto"` resolved to its choice, is reported in the `decoder`
field of each result. A decoder that cannot decode a given circuit makes the job fail: the job's
[`result()`](#haiqu.sdk.schemas.QECRunJobModel.result) raises [`JobFailedError`](#haiqu.sdk.exceptions.JobFailedError),
whose message names the decoder and suggests another. `"tesseract"` can be used with every code.

A run job is cancelled after 30 minutes. With `"tesseract"`, a run with many shots, a large code or
strong noise can take longer than that, and the job is then only cancelled once the decoding of its
shots has finished. Start with few shots to estimate the decoding time. `"auto"` selects
`"tesseract"` only for a code whose file declares it and neither Chromobius nor PyMatching.

# Custom codes

Circuits compiled to a custom code (see
[Custom codes](https://docs.haiqu.ai/reference/run/qec_compile.md#custom-codes)) are run like any other
compiled circuit, without `code`: they are sampled and decoded with exactly the version of the
QECX file they were compiled with, even if the file has been edited since.

`code` also accepts a custom code, in the same forms as `haiqu.qec_compile`, to compile circuits
that are not compiled yet during the run. When `code` is given together with compiled circuits, it
must be the code they were compiled to, or `ValueError` names both codes. A custom code matches by
content, so an edited file does not match the circuits compiled with the earlier version, and
neither does the same file in another experiment, since a custom code belongs to the experiment it
was stored with. In that case, leave out `code`.

For a custom code, `decoder="auto"` selects the first decoder its QECX file declares, as for library
codes, and `"pymatching"` when it declares none; the result's `code_slug` is the slug of the custom
code, for example `my_code-3f9a1c2e`. PyMatching does not reliably correct errors on color codes, so
if your custom code is a color code that declares no decoder, choose the decoder yourself, for example
`decoder="tesseract"`.

# Reading results

The job's [`result()`](#haiqu.sdk.schemas.QECRunJobModel.result) returns one
[`QECRunResultModel`](#haiqu.sdk.schemas.QECRunResultModel) for each circuit, or the result alone when the job
ran one circuit.

**Counts.** `counts` holds the decoded counts of the circuit's classical bits in the logical frame:
in each shot, the decoder's correction is applied to the measured outcome, and the outcome is
expressed in the classical bits of the logical circuit that was compiled. The keys are bitstrings in
Qiskit's convention: one space-separated group per classical register, the first register rightmost,
and bit 0 rightmost within its group.

**Logical error rate.** `logical_error_rate` is the fraction of shots in which the decoder's
correction disagrees with the actual flip of at least one logical Z observable of the circuit's
logical qubits. Whether an observable actually flipped is decided by comparing its outcome with its
outcome in the same circuit without noise. Therefore:

* The logical error rate is meaningful only for outcomes that are deterministic without noise. In the
  [End-to-end example](https://docs.haiqu.ai/reference/run/qec_run.md#end-to-end-example), whose
  ideal outcome is always `0`, it equals the fraction of shots whose decoded outcome is `1`.
* For a circuit whose ideal outcome is random, for example `h` followed by a measurement, it is
  `0.0` under any noise. `decoded_degrees_of_freedom` tells the two cases apart: it is the number
  of logical outcomes, or deterministic combinations of them, that the decoder predicts, and `0`
  when it predicts none, in which case `logical_error_rate` is `0.0` by convention and does not
  measure anything.
* For entangled outcomes whose combinations are deterministic, for example the parity of the two
  bits of a Bell pair, the deterministic combinations are checked.
* For codes with more than one logical qubit per code block, it does not describe the logical
  outcomes; use the counts instead.

The result also holds `shots`, the number of shots; `decoder`, the decoder that was used; and
`code_slug`, the slug of the code the circuit was compiled to.

**Warnings.** A job can succeed with results that need care, for example when the decoder is known to
decode the circuit less accurately, or when no logical outcome could be decoded. Such cases are
reported as lines starting with `WARNING:` in the job's `logs`, one line per kind of warning,
naming the circuits it concerns. Compilation jobs report warnings about the code in the same way.

# Current limitations

* A qubit that is measured cannot currently be measured again, also after a reset: such circuits
  compile, but the run fails.
* The `"chromobius"` decoder currently makes the job fail in these cases; use the slower
  `"tesseract"` instead. `"pymatching"` does not fail on them, but it does not reliably correct
  errors on color codes.
  * codes whose `.qecx` file declares no color information for it;
  * some circuits in which two `cx` gates that share a logical qubit follow each other without an
    error-correction cycle between them, for example `cx(0, 1)` followed by `cx(0, 2)` or by
    `cx(1, 2)`;
  * some larger codes, when state preparation is noisy.
* Across a logical S gate, `"chromobius"` runs but decodes less accurately than on other circuits.
  This includes gates that a code compiles into S gates, for example a logical `x` on
  `color_488_d3`.
* The `"bposd"` decoder, with its current default settings, can decode some single faults on small
  codes incorrectly, so its logical error rates can overstate the error rate of the code.

#### Haiqu.qec\_run(circuits, shots=1024, \*, noise, sampler='stim', decoder='auto', seed=None, code=None, job\_name=None, job\_description=None, toggles=None, \*\*compilation\_options)

Run QEC-compiled circuits under noise and decode the outcomes.

Each circuit is sampled under the noise model given in `noise`, the syndrome measured in its
error-correction cycles is decoded, and the decoded outcomes are returned as counts together
with a logical error rate. A circuit that is not compiled yet is compiled to `code` during the
run. The run executes asynchronously on the Haiqu cloud as a job. The noise model, the decoders
and the results are explained in
[Noise model](https://docs.haiqu.ai/reference/run/qec_run.md#noise-model),
[Decoders](https://docs.haiqu.ai/reference/run/qec_run.md#decoders) and
[Reading results](https://docs.haiqu.ai/reference/run/qec_run.md#reading-results).

By default, noise is applied everywhere in the compiled circuit. The `toggles` argument
restricts it to selected parts, as explained in
[Targeted noise in QEC runs](https://docs.haiqu.ai/reference/run/qec_noise.md).

Problems that are found when the job runs, such as a decoder that cannot decode a circuit, do not
raise an error in this call. They make the job fail, and the job's
[`result()`](#haiqu.sdk.schemas.QECRunJobModel.result) raises [`JobFailedError`](#haiqu.sdk.exceptions.JobFailedError),
whose message describes the problem.

* **Parameters:**
  * **circuits** (*QuantumCircuit* *|* *CircuitModel* *|* *list* \*\[\**QuantumCircuit* *|* *CircuitModel* *]*) -- The circuit to
    run, or a list of them. Each circuit is either QEC-compiled, as returned by the result of a
    `haiqu.qec_compile` job, or a logical circuit, which is compiled to `code` during the run.
    A logical circuit can be given as a `QuantumCircuit`, which is logged automatically, or as a
    logged circuit, for example as returned by `haiqu.log`.
  * **shots** (*int*) -- Number of shots for each circuit, at least 1. Defaults to 1024.
  * **noise** ([*QECNoiseModel*](#haiqu.sdk.schemas.QECNoiseModel) *|* *dict*) -- Required. The noise model, as a
    [`QECNoiseModel`](#haiqu.sdk.schemas.QECNoiseModel) or as a dict with the keys `"p1q"`, `"p2q"`
    and `"p_meas"`, each a probability in `[0, 1]`. See
    [Noise model](https://docs.haiqu.ai/reference/run/qec_run.md#noise-model).
  * **sampler** (*str*) -- The sampler, `"stim"`. Defaults to `"stim"`.
  * **decoder** (*str*) -- The decoder, one of `"auto"`, `"pymatching"`, `"chromobius"`, `"bposd"`
    and `"tesseract"`. `"auto"` selects the first decoder the code's QECX file declares, in
    the order `"chromobius"`, `"pymatching"`, `"tesseract"`, `"bposd"`, and
    `"pymatching"` for a code whose file declares none, custom codes included; the library's
    color codes get `"chromobius"`. Each decoder has limits: `"pymatching"` does not reliably
    correct color codes; `"chromobius"` needs color information in the code's file, decodes
    less accurately across a logical S gate and fails on some circuits; `"bposd"` is slow and
    can decode some single faults on small codes incorrectly; `"tesseract"` is the most
    accurate but much slower, and its decoding can outlast the job's 30-minute limit. Defaults
    to `"auto"`. See [Decoders](https://docs.haiqu.ai/reference/run/qec_run.md#decoders).
  * **seed** (*int* *|* *None*) -- Random seed of the sampling, a non-negative integer. With a seed, the
    sampling is reproducible: the same circuits, arguments and seed give the same results.
    Defaults to `None`, no seed.
  * **code** (*str* *|* [*QECCodeModel*](https://docs.haiqu.ai/reference/run/qec_codes.md#haiqu.sdk.schemas.QECCodeModel) *|* *os.PathLike* *|* *BinaryIO* *|* *None*) -- The code to compile logical circuits to
    during the run, in one of the forms accepted by
    [qec\_compile](https://docs.haiqu.ai/reference/run/qec_compile.md): a library code, given by
    its slug, e.g. `"color_488_d3"`, or as a code model, or a custom code, given as the path to
    its QECX file or as a file opened in binary mode. Required when a circuit is not compiled yet.
    Only library codes in the `"full"` completeness tier can be used (see
    [Completeness tiers](https://docs.haiqu.ai/reference/run/qec_codes.md#completeness-tiers)),
    and the current data of a library code is always fetched from the library, also when a code
    model is given; a slug that names no code makes the job fail. Compiled circuits run with the
    code they were compiled to, so `code` is not needed for them; when it is given, it must be
    that code, or `ValueError` is raised. A library code matches by slug and a custom code by
    content, so an edited file does not match, and neither does the same file in another
    experiment, since a custom code belongs to its experiment. The results report a custom code
    by a slug derived from its file name, or `custom_code` for a file object without a name,
    which differs for each version of the file. Defaults to `None`, no code.
  * **job\_name** (*str* *|* *None*) -- Name of the run job. Defaults to `None`, no name.
  * **job\_description** (*str* *|* *None*) -- Description of the run job. Defaults to `None`, no description.
  * **toggles** (*dict* *|* *None*) -- The parts of the compiled circuit that receive noise, as a dict with up
    to three keys, explained in
    [Targeted noise in QEC runs](https://docs.haiqu.ai/reference/run/qec_noise.md). A malformed
    dict makes the job fail. Defaults to `None`, noise everywhere.
  * **\*\*compilation\_options** --

    Options for compiling logical circuits during the run, the same as those
    of [qec\_compile](https://docs.haiqu.ai/reference/run/qec_compile.md), given as keyword
    arguments:

    * `ec_cycle_frequency` (int): Where error-correction cycles are inserted. Defaults to 1.
      See [Error-correction cycles](https://docs.haiqu.ai/reference/run/qec_compile.md#error-correction-cycles).
    * `variant_selections` (dict | None): The variants to use for the code's operations.
      Defaults to `None`, the code's default variant for every operation. See
      [Variant selections](https://docs.haiqu.ai/reference/run/qec_compile.md#variant-selections).
    * `add_layer_barriers` (bool): Whether to place a barrier at every boundary between
      consecutive logical layers of the compiled circuit. Defaults to `False`.

    A value of the wrong type makes the job fail. Other keys are not supported. The options are
    ignored for circuits that are already compiled, which keep the options they were compiled
    with.
* **Returns:**
  The run job. Its [`result()`](#haiqu.sdk.schemas.QECRunJobModel.result) waits for
  the job to finish and returns the decoded results.
* **Return type:**
  [QECRunJobModel](#haiqu.sdk.schemas.QECRunJobModel)

- **Raises:**
  * **ValueError** -- If a circuit is not compiled and no `code` is given, if `code` is a library code
    that is not in the `"full"` tier, if `code` is not the code a compiled circuit was compiled
    to, if `sampler` or `decoder` is not one of the supported values, if `noise`, `shots` or
    `seed` has an invalid value, or if a custom code's file is empty. These checks are made before
    any circuit is logged or any custom code is stored.
  * **FileNotFoundError** -- If `code` is a path, or a string containing `/` or `\`, that does not
    exist.
  * **TypeError** -- If `code` is a file opened in text mode, or of a type not listed above.
  * **requests.HTTPError** -- If a custom code's QECX file is larger than 5 MB (status 413), or a request
    fails for another reason. In a notebook, an error message is shown and `None` is returned
    instead.

#### Examples

```python theme={null}
>>> from qiskit import QuantumCircuit
>>> circuit = QuantumCircuit(1, 1)
>>> circuit.h(0)
>>> circuit.h(0)
>>> circuit.measure(0, 0)
>>> compiled = haiqu.qec_compile(circuit, code="color_488_d3").result()
```

Run without noise, as a check that every shot gives the ideal outcome:

```python theme={null}
>>> job = haiqu.qec_run(compiled, shots=1000, noise={"p1q": 0, "p2q": 0, "p_meas": 0})
>>> result = job.result()
>>> result.counts
{'0': 1000}
>>> result.logical_error_rate
0.0
```

Sweep the noise strength, collecting the jobs and then reading their results:

```python theme={null}
>>> jobs = []
>>> for p in [1e-3, 2e-3, 5e-3]:
...     noise = {"p1q": p, "p2q": p, "p_meas": p}
...     jobs.append(haiqu.qec_run(compiled, shots=10_000, noise=noise, decoder="tesseract"))
>>> results = [job.result() for job in jobs]
```

Compile a logical circuit to a custom code from a QECX file during the run:

```python theme={null}
>>> job = haiqu.qec_run(circuit, noise={"p1q": 1e-3, "p2q": 1e-3, "p_meas": 1e-3}, code="codes/my_code.qecx")
>>> job.result().code_slug
'my_code-3f9a1c2e'
```

Apply noise only in the error-correction cycles:

```python theme={null}
>>> from haiqu.sdk.qec_labels import ec_cycle_box_label
>>> job = haiqu.qec_run(
...     compiled,
...     noise={"p1q": 1e-3, "p2q": 1e-3, "p_meas": 1e-3},
...     decoder="tesseract",
...     toggles={"noisy_box_labels": [ec_cycle_box_label()], "apply_noise_outside_boxes": False},
... )
```

### *class* haiqu.sdk.schemas.QECRunJobModel

Job that samples circuits under noise and decodes the outcomes, as returned by `haiqu.qec_run`.

Call [`result()`](#haiqu.sdk.schemas.QECRunJobModel.result) to wait for the job to finish and obtain the decoded results.

#### id

ID of the job, for retrieving it later with `haiqu.get_job`.

* **Type:**
  str

#### status

Status of the job when it was last checked.

* **Type:**
  JobStatus

#### circuit\_ids

IDs of the submitted circuits.

* **Type:**
  list

#### shots

Number of shots per circuit.

* **Type:**
  int

#### noise

The noise model of the run.

* **Type:**
  [QECNoiseModel](#haiqu.sdk.schemas.QECNoiseModel)

#### sampler

The requested sampler.

* **Type:**
  str

#### decoder

The requested decoder, possibly `"auto"`. The decoder actually used is
reported on each result.

* **Type:**
  str

#### seed

The random seed, `None` when none was given.

* **Type:**
  int | None

#### toggles

The selection of where noise is applied, `None` when noise is
applied everywhere. The integer qubit indices of `"qubit_gate_overrides"` come back
as strings.

* **Type:**
  dict | None

#### code\_slug

Slug of the QEC code given in `code` for compiling circuits
during the run, `None` when none was given.

* **Type:**
  str | None

#### compilation\_options

The compilation options given for compiling circuits during
the run.

* **Type:**
  dict

#### qec\_results

One decoded result per circuit, available
once the job has finished, `None` until then.

* **Type:**
  list\[[QECRunResultModel](#haiqu.sdk.schemas.QECRunResultModel)] | None

#### progress()

Display a progress widget for the job and stream its log messages.

#### result()

Wait for the job to finish and return the decoded results.

The call blocks until the job has finished, checking its status every few seconds, with no
timeout. Interrupting the wait (for example with Ctrl+C) returns `None` without
cancelling the job; call [`result()`](#haiqu.sdk.schemas.QECRunJobModel.result) again to resume waiting. The job can also be
retrieved later by its ID with `haiqu.get_job`.

* **Returns:**
  The result of the circuit when the
  job ran one circuit, otherwise a list with one result per circuit. `None` if the wait
  was interrupted.
* **Return type:**
  [QECRunResultModel](#haiqu.sdk.schemas.QECRunResultModel) | list\[[QECRunResultModel](#haiqu.sdk.schemas.QECRunResultModel)] | None

- **Raises:**
  * [**haiqu.sdk.exceptions.JobFailedError**](#haiqu.sdk.exceptions.JobFailedError) -- If the job failed. The message describes the problem,
    and the exception's `logs` holds all log messages of the job.
  * [**haiqu.sdk.exceptions.JobCancelledError**](#haiqu.sdk.exceptions.JobCancelledError) -- If the job was cancelled, by the user or because it
    exceeded the time limit of 30 minutes, which the message then says.

### *class* haiqu.sdk.exceptions.JobFailedError(message, \*, job\_id, logs=None)

Raised by a job's `result` when the job failed.

* **Parameters:**
  * **message** (*str*)
  * **job\_id** (*str*)
  * **logs** (*str* *|* *None*)

#### job\_id

ID of the job.

* **Type:**
  str

#### logs

All log messages of the job, of which the exception message shows the error.

* **Type:**
  str | None

### *class* haiqu.sdk.exceptions.JobCancelledError(message, \*, job\_id, logs=None)

Raised by a job's `result` when the job was cancelled, by the user or because it exceeded its time limit.

* **Parameters:**
  * **message** (*str*)
  * **job\_id** (*str*)
  * **logs** (*str* *|* *None*)

#### job\_id

ID of the job.

* **Type:**
  str

#### logs

All log messages of the job, of which the exception message shows the reason.

* **Type:**
  str | None

### *class* haiqu.sdk.schemas.QECRunResultModel

Decoded result of a QEC run for one circuit.

How to read the counts and the logical error rate is explained in
[Reading results](https://docs.haiqu.ai/reference/run/qec_run.md#reading-results).

#### counts

Decoded counts of the circuit's classical bits in the logical
frame, keyed by bitstring in Qiskit's convention: one space-separated group per
classical register, the first register rightmost, and bit 0 rightmost within its
group.

* **Type:**
  dict\[str, int]

#### logical\_error\_rate

Fraction of the shots the decoder got wrong. The precise
definition is given in
[Reading results](https://docs.haiqu.ai/reference/run/qec_run.md#reading-results).

* **Type:**
  float

#### shots

Number of shots.

* **Type:**
  int

#### decoder

The decoder actually used, with `"auto"` resolved to its concrete
choice.

* **Type:**
  str

#### code\_slug

Slug of the QEC code the circuit was compiled to.

* **Type:**
  str

#### decoded\_degrees\_of\_freedom

Number of logical outcomes, or deterministic
combinations of them, that the decoder predicts. `0` means none could be decoded, and
`logical_error_rate` is then `0.0` by convention. `None` for results of jobs that
ran before this was reported.

* **Type:**
  int | None

### *class* haiqu.sdk.schemas.QECNoiseModel

Uniform noise parameters for a QEC run.

A plain dict with the keys `p1q`, `p2q` and `p_meas` is accepted wherever a noise model
is. Where each noise channel is applied is explained in
[Noise model](https://docs.haiqu.ai/reference/run/qec_run.md#noise-model).

#### p1q

Depolarizing probability of single-qubit gates, in `[0, 1]`.

* **Type:**
  float

#### p2q

Depolarizing probability of two-qubit gates, in `[0, 1]`.

* **Type:**
  float

#### p\_meas

Probability that a measurement outcome is flipped, in `[0, 1]`.

* **Type:**
  float


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.