toggles argument described on this page.
The noise itself is determined by the noise model given in the noise argument (see
Noise model). The toggles
decide where that noise is applied; they do not change the noise model itself.
How a compiled circuit is structured
The QEC compiler wraps every instruction it emits for a logical operation in a box carrying a label that names that operation. Boxes are the unit of selection: noise is either applied to a box as a whole (meaning, to all of the gates and measurements contained in the box alike), or not applied at all (to that box). Six kinds of boxes can occur in a compiled circuit:
It is strongly recommended to create labels with the builders in
haiqu.sdk.qec_labels
rather than writing the label strings by hand.
Selecting where noise applies
toggles is a plain dictionary with up to three keys. Omit a key to keep its default.
Together the
toggles decide for every gate and measurement of the compiled circuit whether it
is noisy.
NOTE
A two-qubit gate is noisy if it is noisy for either of its qubits. Since an override names only a logical qubit’s data qubits, the two-qubit gates between data and syndrome qubits inside an error-correction cycle keep following"noisy_box_labels" for the syndrome qubit.
Examples
All examples start from a compiled circuit and a noise model, and decode with"tesseract", the
most accurate decoder (see Decoders):
p_meas
to zero in noise: box selection places gate and measurement noise together.
One bad logical qubit. Only the gates on the data qubits of logical qubit 0, inside the
logical Hadamard boxes, are noisy. No box is selected globally and there is no measurement noise.
Things to check
- A label must match a box of your compiled circuit. Labels name the gates as compiled, not
as written: a code whose native logical gates are H, S and CX compiles a logical X into H and S
boxes, so
logical_gate_box_label("x")selects nothing in that circuit. A label that matches no box is not an error; the part of the circuit you meant to select simply stays noise-free. - None and an empty list are opposites.
"noisy_box_labels": None(or omitting the key) selects every box;"noisy_box_labels": []selects none. - Overrides govern gates only. Selecting a box with
"noisy_box_labels"makes its gates and its measurements noisy; naming it in"qubit_gate_overrides"makes only the gates on that logical qubit’s data qubits noisy.
Label builders
Haiqu SDK. QEC box labels. The QEC compiler wraps each logical operation of a compiled circuit in a labeled box. This module builds those labels, so that they do not have to be typed by hand when selecting boxes in thetoggles argument of haiqu.qec_run, either in "noisy_box_labels" or in
"qubit_gate_overrides".
Every label is the shared prefix, a fixed operation term, and, for a parameterized operation, a
single space and one key=value tail:
haiqu.sdk.qec_labels.QEC_COMPILER_BOX_LABEL_PREFIX = ‘_qec_compiler_:’
Prefix shared by every label the compiler puts on a box.haiqu.sdk.qec_labels.data_measurement_box_label(basis)
Label on the box wrapping a data measurement (e.g. basis=‘Z’).- Parameters: basis (str)
- Return type: str
haiqu.sdk.qec_labels.ec_cycle_box_label()
Label on the box wrapping each error-correction cycle.- Return type: str
haiqu.sdk.qec_labels.logical_gate_box_label(gate_name)
Label on the box wrapping a logical gate (e.g. gate_name=‘x’).- Parameters: gate_name (str)
- Return type: str
haiqu.sdk.qec_labels.logical_measurement_box_label(observable)
Label on the box wrapping a logical measurement (e.g. observable=‘Z’).- Parameters: observable (str)
- Return type: str
haiqu.sdk.qec_labels.logical_reset_box_label(state)
Label on the box wrapping a logical reset (e.g. state=‘0’).- Parameters: state (str)
- Return type: str
haiqu.sdk.qec_labels.logical_state_preparation_box_label(state)
Label on the box wrapping a logical state preparation (e.g. state=‘0’).- Parameters: state (str)
- Return type: str