Quantum Error Correction eXchange format (QECX) Specification¶
Purpose¶
The Quantum Error Correction eXchange format (QECX) is a portable, self-contained and toolkit-agnostic file format for quantum error correction codes and the operations, cycles and decoders that are needed to run them. One QECX file, in either the inline JSON or the ZIP archive container, holds everything a compiler and simulator/device runtime need to know: the code’s algebraic definition, its register template, the circuits for every logical operation and the error-correction cycle, optional decoder, layout and more. The goal of QECX as an abstraction is to help formalize QEC research, as well as simplify the sharing of codes, regardless of their implementation details, which are usually tied to a specific software toolkit or hardware vendor. The aim is to get as much adoption and integration with other QEC tools as possible.
Top-Level Structure¶
An inline-container document is a UTF-8 JSON document with the following top-level keys:
{
"qec_version": "0.1",
"code": { ... }, // required: algebraic definition
"register_template": { ... }, // required: qubit/clbit roles and sizes
"operations": { ... }, // required: circuit implementations
"error_correction_cycle": { ... }, // required: EC cycle composition
"decoder_config": { ... }, // optional: syndrome-decoder declaration
"qubit_layout": { ... }, // optional: spatial geometry and coordinates
"properties": { ... } // optional: metadata and provenance
}
qec_version, code,
register_template,
operations, and
error_correction_cycle are required.
decoder_config,
qubit_layout, and
properties are optional. A file
omitting any or all of the optional sections is fully valid.
Versioning: qec_version uses "major.minor" format. The value declares the minimum
spec version needed to fully interpret all features in the file. See
§9 for the full versioning model and guidelines for spec
editors.
Terminology¶
Variant. One concrete circuit implementation of an operation. A variant is a JSON object carrying an OpenQASM 3.0 fragment together with the register declarations and the metadata that fragment needs. An operation carries as many variants as it has implementations worth distributing: a fault-tolerant state preparation beside a bare one, a flagged syndrome extraction beside an unflagged one. Consumers select among them by variant key. An operation with a single implementation still expresses it as one variant.
Variant group. One {default, variants} container: the map from variant key to
variant object, plus the key to use when the consumer has no preference. The variant
group is the format’s unit of choice among declared alternatives with a named
default. Operations reach their groups through the three container
shapes of §3: syndrome_measurement holds one directly, state_preparation, reset,
and data_measurement hold one per target key, and logical_gates and
logical_measurement hold one per gate name or observable and operand shape. The
error_correction_cycle section (§6) is itself a single variant group, over cycle
variants rather than over circuit implementations.
Check. One row of a check source, a field of code a readout declaration may name: a row of
the binary matrix H_X, H_Z, gauge_X or gauge_Z, or one string of the Pauli string list
stabilizer_generators or gauge_generators. A check is read as an unsigned Pauli operator on
one block, as written: a row of H_X or gauge_X is X on every column holding 1, a row of H_Z
or gauge_Z is Z there, and column j (or character j) acts on qubit j of the block’s data
register. The qubits where a check acts are its support. The sources valid for each code_type
are listed under Readout declarations (§3): the stabilizer rows for "css" and "stabilizer",
the gauge rows for "subsystem_css" and "subsystem_stabilizer"; on subsystem codes the optional
stabilizer fields are not check sources.
Stabilizer generator. For "css" and "stabilizer" codes, the checks themselves. For the
subsystem types, products of gauge checks that lie in the stabilizer group, listed by the
optional stabilizer fields (H_X and H_Z, or stabilizer_generators) where the document gives
them. A gauge check that is not itself a stabilizer has no defined value on a code state; only the
products of gauge checks that are stabilizers have one.
Code state. A state of a block that is the +1 eigenstate of every stabilizer generator, with
the operator as written: this is the format’s sign convention. A variant leaves every block whose
data register it declares in a code state, except the block a data_measurement variant measures;
helper blocks are not covered (see Readout declarations, §3).
Check value. The value of a check on one of its eigenstates, as a bit: 0 for the eigenvalue +1, 1 for -1. A parity of bits is their sum modulo 2.
Unconditioned fragment. A variant’s QASM fragment with every classically conditioned
statement removed, each if statement together with all its branches. Readout declarations and
their sign contract are stated on the unconditioned fragment.
Check readout. Measured bits whose parity, on the unconditioned fragment, equals the value of a named check; for a gauge source, the parity of the bits of each set of declared gauge rows whose product is a stabilizer equals that stabilizer’s value. A readout declaration names what its bits equal there. Bits equal only to a product of checks are a readout of none of them.
Transversal readout. A check readout holding one bit for each block qubit it reads, each qubit read once, either directly or through a helper block coupled to the data qubit by qubit. The value of each check is the parity of the bits over its support.
Entry frame, exit frame. The two moments at which a readout declaration names its checks: the entry frame names a check of the block as it enters the operation, the exit frame a check of the state the operation produces.
Containers¶
Inline container (JSON) Archive container (ZIP)
┌─────────────────┐ ┌────────────────────────────────────────────────┐
│ steane.qecx │ │ color_488_d21.qecx │
│ (JSON file) │ │ ├── manifest.json │
│ │ │ ├── code/ │
│ All QASM and │ │ │ ├── H_X.json │
│ data inlined │ │ │ ├── H_Z.json │
│ │ │ │ └── logical_operators_X.txt │
└─────────────────┘ │ ├── circuits/ │
│ │ ├── state_preparation_0_css_encoder.qasm │
│ │ ├── logical_gates_cx_0_transversal.qasm │
│ │ └── syndrome_measurement_sequential.qasm │
│ ├── cycles/ │
│ │ └── repeated_sequential.json │
│ ├── decoders/ │
│ │ └── chromobius.json │
│ ├── layout/ │
│ │ ├── edges.json │
│ │ ├── faces.json │
│ │ ├── vertex_coordinates.json │
│ │ └── qubit_placement.json │
│ └── references.json │
└────────────────────────────────────────────────┘
Container detection: Loaders detect the container from the first four bytes of the file
content (after stripping a leading UTF-8 BOM \xEF\xBB\xBF if present): PK\x03\x04
indicates a ZIP archive; anything else is treated as inline JSON. The container form is identified
by content alone; the file extension is conventional and carries no meaning in the format.
Archive container structure: A ZIP archive containing:
manifest.json: same JSON schema as an inline-container document, with inline values replaced by$refreferences where appropriate.code/: algebraic code data externalized from thecodesection. Binary matrix fields, Pauli string list fields, and each list oflogical_operatorsmay be replaced by a$refpointing to a.json(dense or sparse matrix) or.txt(one Pauli string per line) file.circuits/: OpenQASM 3.0 circuit files externalized fromoperations. Any"qasm"field may be replaced by a$ref(e.g.{"$ref": "circuits/syndrome_measurement_sequential.qasm"}).layout/: spatial data externalized fromqubit_layout. The edges and faces ofcell_complex,embedding.vertex_coordinates, and thequbit_placementmap may each be replaced by a$refpointing to a.jsonfile.cycles/,decoders/,references/: one file pererror_correction_cyclevariant,decoder_configentry, and bibliography entry externalized as a whole object.references.json: theproperties.referenceslist externalized as a whole; thepropertiessection may equally stand inproperties.json.
Archive subdirectories mirror the top-level JSON sections they contain data for. Each directory is optional; include only those containing externalized data.
Manifest location: manifest.json must sit at the root of the archive, not inside a
folder. To create an archive from a folder, zip the files and subdirectories inside it
rather than the folder itself: zipping the folder puts every entry under the folder’s name,
and the archive then has no manifest.json at its root and does not load.
External references: Any field that supports externalization may be replaced by a
$ref object:
{"$ref": "circuits/syndrome_measurement_sequential.qasm"}
The $ref value is a relative path within the archive. This mechanism is uniform across all
externalizable fields: matrices, Pauli string lists, QASM circuits, and coordinate arrays.
Inline and external values may be freely mixed within a single archive.
Externalization granularity: the unit of externalization is a field holding unbounded collection content: typically an array growing with the code’s physical-qubit, check, or logical-qubit count, and in the bibliography’s case a list the author extends.
Section |
Collection fields |
|---|---|
|
|
|
each variant’s |
|
|
|
|
An element with no such field is one unit as a whole: an error_correction_cycle variant and
a decoder_config entry each externalize as one object, to cycles/<name>.json and
decoders/<slug>.json. A bibliography entry is one unit too, at references/<key>.json; its
enclosing references list is the canonical form for the bibliography as a whole.
A coarser reference is equally legal: a $ref may stand at an object enclosing those fields
(code, code.logical_operators, qubit_layout, qubit_layout.cell_complex,
qubit_layout.embedding, one operation variant, the whole properties section). The unit
forms above are the canonical ones; both spellings denote the same document.
Everything else is the floor: a $ref standing there resolves like any other, but no
canonical member form is defined for it. The floor is:
scalar fields (
n,k,d,num_vertices,dimension,tiling_type, …);human-scale metadata: any
description, the metadata fields ofproperties, and the fields of a bibliography entry;structure inside a unit: one row of a matrix, one entry of
qubit_placement, and a decoder tag value, whether source-anchored or asyndrome_measurementoverride;a whole collection section (
operations,error_correction_cycle,decoder_config), which names no single element.
Inline value detection: When a field value is a JSON object, a $ref key identifies it
as an external reference regardless of other keys. Otherwise, the inline representation
follows from the JSON type: array → inline
dense matrix or coordinate array; object with "rows" key → inline sparse matrix; string →
inline QASM or other string content.
An inline-container document that exceeds approximately 10 MB is a signal that the archive
container should be used instead. All field values in an inline container must be inline;
$ref objects are an error.
§1 code: Algebraic Definition¶
Captures the mathematical structure of the code independent of any circuit implementation.
The code_type field determines which fields are required.
"code": {
"name": "Steane Code [[7,1,3]]", // optional
"code_type": "css", // required
"n": 7, // required
"k": 1, // required
"d": 3, // required
...code_type-specific fields...
}
name is an optional human-readable label. All other top-level code fields are required.
Parameters n, k, d:
n: total number of physical qubits per block.k: number of logical qubits encoded per block.d: code distance. Either an integer (symmetric distance) or an object{"X": 3, "Z": 5}for codes with distinct X-distance and Z-distance (e.g. codes optimised for biased noise, where the minimum-weight logical X operator and minimum-weight logical Z operator differ in weight).
Code type hierarchy and required fields:
|
Required fields (besides |
Optional fields |
Description |
|---|---|---|---|
|
|
General Pauli stabilizer code |
|
|
|
CSS code: all stabilizers are purely X-type or purely Z-type |
|
|
|
|
Subsystem/gauge code with general Pauli generators |
|
|
|
Subsystem code where gauge generators also split into X-type and Z-type |
The four types are hierarchically related: subsystem_stabilizer ⊃ stabilizer ⊃ css,
and subsystem_stabilizer ⊃ subsystem_css ⊃ css. Each type requires a genuinely
different algebraic description; using the most specific type that applies is recommended
(e.g. use "css" rather than "stabilizer" for a CSS code).
Code-type field gating:
The required/optional matrix above is normative: a field not listed as required or optional
for a given code_type is forbidden for that code_type.
Field |
|
|
|
|
|---|---|---|---|---|
|
forbidden |
forbidden |
required |
optional |
|
forbidden |
forbidden |
forbidden |
required |
Field formats:
Pauli string list fields (stabilizer_generators, gauge_generators):
Each may be given as:
Inline list:
["XZZXI", "IXZZX", ...], a JSON array of Pauli strings, each of lengthnover the alphabet{I, X, Y, Z}.External file (archive container only):
{"$ref": "code/stabilizers.txt"}, a$refobject pointing to a file inside the archive. The file contains one Pauli string per line, no header.
Binary matrix fields (H_X, H_Z, gauge_X, gauge_Z):
Each may be given as:
Inline dense:
[[1,0,1,0,1,0,1], [0,1,1,0,0,1,1], ...], a 2D array of 0/1 integers with dimensions[m, n].Inline sparse:
{"rows": [[0,2,4,6], [1,2,5,6], [3,4,5,6]], "shape": [3, 7]}, an object whererowsis a list of per-row column indices (columns of nonzero entries), andshapeis[m, n]. Recommended for QLDPC codes with sparse matrices.External file (archive container only):
{"$ref": "code/H_X.json"}, a$refobject pointing to a.jsonfile inside the archive containing either the inline dense or inline sparse representation.
External $ref references are only valid inside an archive container. An inline-container
document must be fully self-contained; a $ref object in an inline container is an error.
Inline and external representations are distinguished by the JSON-type detection rules described in the Containers section above.
logical_operators field:
"logical_operators": {
"X": ["XXXXXXX", "..."],
"Z": ["ZZZZZZZ", "..."]
}
Each list contains exactly k Pauli strings: one representative per logical qubit, in
order. logical_operators["X"][i] is a physical operator implementing logical X on the
i-th logical qubit (0-indexed); similarly for Z. In an archive container each list may be
replaced by a $ref (code/logical_operators_X.txt, code/logical_operators_Z.txt), as may
the logical_operators object as a whole (code/logical_operators.json).
The ordering is load-bearing: it fixes the block’s canonical logical-qubit enumeration.
Multi-character target-state keys on state_preparation / reset (§3), operand
logical_qubit indices in logical_gates / logical_measurement (§3), and every other
format field that addresses a specific logical qubit within a block all refer to this same
position order. Implementations must not permute logical_operators["X"] independently of
logical_operators["Z"] or of downstream consumers.
For "subsystem_stabilizer" and "subsystem_css" codes, representatives must be elements
of N(G)/G; they must commute with all gauge generators, not merely the stabilizers.
An operator that commutes with all stabilizers but anti-commutes with some gauge generator
acts on gauge degrees of freedom only and is not a valid logical operator.
If alternative representatives are needed (e.g. for decoder hints), they should be stored
in a separate optional field, not in logical_operators.
Code family coverage:
Code family |
v0.1 support |
|---|---|
Surface codes (rotated, planar, toric) |
|
Color codes (triangular, hexagonal) |
|
General CSS codes (Steane, etc.) |
|
General stabilizer codes (5-qubit, etc.) |
|
Subsystem / gauge codes (Bacon-Shor, compass) |
|
QLDPC codes (k=1 or k>1) |
|
Floquet / dynamical codes |
Planned: |
Concatenated codes |
Planned: |
§2 register_template: Declarative Register Layout¶
Separates what registers exist and how large they are from the circuit code. All circuit fragments reference registers by name; the register declarations define what each name denotes.
The fundamental unit is a code block: a single physical implementation unit that encodes
code.k logical qubits. For k=1 codes, one block corresponds to one logical qubit. For k>1
codes (e.g. QLDPC codes), one block encodes multiple logical qubits and all register sizes
reflect the full block.
register_template has two top-level sections: global (optional) and per_code_block
(required). per_code_block must always be present because every operation references the
data register it declares. global is optional; omit it if no global registers are needed.
Registers declared in register_template are persistent: they are created once (globally
or per block instance) and reused across operation invocations. Classical registers created
fresh per operation (e.g. syndrome measurement outcomes, measurement results) are declared
within operation variants, not here.
global¶
Registers that exist once, independently of how many code block instances are present. They are reused across operations but never in parallel; the system guarantees at most one operation uses a global register at any given time.
"global": {
"ancilla_qregs": {
"shared_cat": {"size": 4}
},
"cregs": {
"control": {"size": 8}
}
}
Both ancilla_qregs and cregs are optional; omit either if empty.
per_code_block¶
Registers instantiated once per code block instance.
"per_code_block": {
"data_qreg": {"size": 7},
"ancilla_qregs": {
"syndrome": {"size": 3},
"flag": {"size": 2}
},
"cregs": {
"parity": {"size": 4}
}
}
data_qreg: required, reserved name. Contains allnphysical data qubits in the block. Itssizemust equalcode.n. Operations that act on data qubits reference this register by the namedata_qreg.ancilla_qregs: optional named map of ancilla quantum registers. Keys are user-chosen identifiers (e.g."syndrome","flag"); no fixed vocabulary is imposed. Each entry’s name is used directly as the register name in circuit fragments.cregs: optional named map of persistent classical registers, for classical state that is retained and reused across operation invocations within a block.
ancilla_qregs and cregs are optional; omit either if empty.
Register attributes¶
Every register entry is an object with at minimum a size field:
{"size": 7}
size is a positive integer giving the number of qubits or bits in the register. Loaders
must ignore unknown fields within a register entry; future versions may add attributes.
An optional purpose field provides a semantic annotation for the register:
{"size": 3, "purpose": "syndrome"}
The following values are defined for v0.1:
|
Applies to |
Meaning |
|---|---|---|
|
|
Physical data qubits encoding logical information, or the bits holding their measurement outcomes |
|
ancilla qregs |
Syndrome extraction ancilla |
|
ancilla qregs, cregs |
Flag qubits or bits for fault-tolerant protocols |
|
ancilla qregs |
CAT/GHZ state ancilla |
|
ancilla qregs, cregs |
State verification ancilla or outcome bits |
|
ancilla qregs |
Magic state injection ancilla |
|
|
Logical measurement outcome bits |
|
|
Bits of a transversal readout (see Readout declarations, §3) |
|
any |
Non-standard use; pair with optional |
For data_qreg, purpose must be absent or "logical_data". Any other value is a
validation error.
Syndrome outcome bits carry "syndrome" as well, but only on an "output"-scoped dynamic
classical register declared by an operation variant (§3). A register_template creg, at
either level, holds classical state across operation invocations, whereas a syndrome creg
is created fresh for the round whose outcomes it holds. "logical_measurement" follows the
same producer path: it annotates the "output"-scoped result_creg a logical_measurement
variant declares, and register_template cregs exclude it for the reason they exclude
"syndrome". "transversal_readout" is placed as "syndrome" is: only on an
"output"-scoped dynamic classical register declared by an operation variant, and never on
a register_template creg.
purpose is purely informational; it does not affect loading or circuit execution.
Consumers may treat it as a hint (e.g. to identify which of a variant’s cregs entries
holds syndrome bits without parsing the QASM), but must not require it to be present. As
with data_qreg, "logical_data" and "logical_measurement" are reserved to the
registers named in their Applies to column above; carrying either on any other register
is a validation error.
Readout registers are identified by the variant fields syndrome_cregs and
transversal_readout_cregs (§3), not by purpose. "transversal_readout" is neither
reserved nor required: a register may carry it without being named in either field, and a
register named in transversal_readout_cregs may omit it. The two readout purposes do not
cross: a register named in transversal_readout_cregs does not carry "syndrome", and a
register named in syndrome_cregs does not carry "transversal_readout".
When purpose is "custom", an optional purpose_description field (string) provides a
human-readable explanation of the register’s role. purpose_description is ignored unless
purpose is "custom".
{"size": 5, "purpose": "custom", "purpose_description": "Ancilla for lattice surgery merge"}
Register names across data_qreg, ancilla_qregs, and cregs (at both levels combined)
must be unique. Additionally, within a single operation variant, dynamic register names
(scratch/output) must not collide with each other or with any inherited template register
name used in that variant. How circuit fragments reference these names is described in §3.
§3 operations: Circuit Implementations¶
Circuit implementations are provided as OpenQASM 3.0 fragments. Each fragment references
registers by the names declared in its variant’s qregs and cregs maps; those
declarations define the registers the names denote.
Register declarations¶
Every operation variant declares the registers it uses through qregs (quantum registers)
and cregs (classical registers) maps. Either map may be omitted if empty. The key in each
entry is the register name as used in the QASM fragment; the value describes the register’s
origin and lifetime via a scope field.
"qregs": {
"data_qreg": {"scope": "block", "ref": "data_qreg"},
"syndrome": {"scope": "block", "ref": "syndrome"},
"shared_cat": {"scope": "global", "ref": "shared_cat"},
"fresh_anc": {"scope": "scratch", "size": 4}
},
"cregs": {
"syn_bits": {"scope": "output", "size": 6},
"temp_bits": {"scope": "scratch", "size": 4}
}
Scope values:
|
Category |
Meaning |
|
|
|---|---|---|---|---|
|
inherited |
References a register from |
required |
omitted |
|
inherited |
References a register from |
required |
omitted |
|
dynamic |
Created per invocation with no initial state guaranteed; a fragment resets each qubit of a |
absent |
required |
|
dynamic |
Created per invocation with no initial state guaranteed; a fragment resets each qubit of an |
absent |
required |
Inherited registers ("global" / "block"): ref gives the register name as declared
in register_template. The QASM name (key) and ref may differ, allowing a template
register to be aliased to a different name in the circuit fragment. The purpose annotation
is inherited from the template declaration and must not be overridden in the operation entry.
Dynamic registers ("scratch" / "output"): size gives the number of qubits or
bits. Neither dynamic scope guarantees an initial state, so a fragment resets each qubit of a
"scratch" or "output" quantum register before its first use (see the helper reset rule under
Base variant fields below). "scratch" registers are temporary: their contents carry no meaning
across operation calls, so a consumer is free to pool and reuse their storage.
"output" registers persist after the operation call; they are available for downstream
consumption (e.g. syndrome bits for a decoder, measurement outcomes for a compiler).
Dynamic registers may carry a purpose annotation declared directly on the operation entry,
since they have no template declaration to inherit from. A classical register annotated
"syndrome" or "transversal_readout" must be "output"-scoped: its bits are read after
the operation returns.
Name set equality. The set of register names declared in qregs ∪ cregs must
equal the set of register names declared in the QASM fragment (qreg name[N]; and
creg name[N]; declarations). A QASM register name absent from the variant’s maps, or a variant
register name absent from the QASM, is an error (§8).
Multi-block operations (used by logical_gates and logical_measurement, described
below): per-block inherited registers carry a block_index field naming the block label
whose operands the register belongs to:
"data_qreg_0": {"scope": "block", "block_index": 0, "ref": "data_qreg"},
"data_qreg_1": {"scope": "block", "block_index": 1, "ref": "data_qreg"}
Operation types¶
operations contains one key per operation type. The following types are defined:
Operation type |
Required |
Container |
Description |
|---|---|---|---|
|
yes |
keyed default/variants (by state) |
Prepare a logical state from physical |0⟩ qubits |
|
yes |
flat default/variants |
Extract stabilizer syndromes without disturbing logical information |
|
yes |
logical-addressing |
Apply logical gate operations (see below for distinct structure) |
|
yes |
keyed default/variants (by basis) |
Measure all physical qubits, destroying the code block |
|
no |
logical-addressing |
Non-destructive measurement of a subset of logical qubits within a block |
|
no |
keyed default/variants (by state) |
Reset a code block to a known logical state |
All four required types must be present. Optional types are omitted entirely if not provided.
Unknown keys inside operations are silently ignored; this is the forward-compatibility
mechanism for new operation types in future versions.
Container types: Three container shapes appear in operations, each addressing a
variant group (see Terminology) in a different way:
Flat default/variants: used by
syndrome_measurement. A single{default, variants}container at the operation’s top level.Keyed default/variants: used by
state_preparation,reset(keyed by target logical state), anddata_measurement(keyed by measurement basis). The operation’s top level is a map from the key to an inner{default, variants}container.Logical-addressing: used by
logical_gatesandlogical_measurement, indexed by gate name or observable and by operand shape (documented in their respective sections).
Flat default/variants container¶
Used by syndrome_measurement. Each operation type using this container is an object with
two fields:
default(string, required): the variant key to use when the consumer has no preference. Must refer to an existing key invariants.variants(object, required): a map from variant key (a short identifier, e.g."non_ft","flagged") to a variant object.
"syndrome_measurement": {
"default": "non_ft",
"variants": {
"non_ft": { ... },
"flagged": { ... }
}
}
An operation with a single variant still uses this structure; default names that single
variant.
Keyed default/variants container¶
Used by state_preparation, reset, and data_measurement. The operation’s top
level is a map from a target key (a string identifying the prepared state or measurement
basis) to an inner {default, variants} container with the same shape as the flat container.
┌──────────────────────────────────────────────────────────┐
│ <operation_type> │
│ │
│ "<target_key_0>" │
│ ├── default ── "<variant_key>" │
│ └── variants │
│ └── "<variant_key>" ── { base variant fields } │
│ │
│ "<target_key_1>" │
│ ├── default ── ... │
│ └── variants ── ... │
└──────────────────────────────────────────────────────────┘
"state_preparation": {
"0": {
"default": "non_ft",
"variants": {
"non_ft": { ... },
"ft_verified": { ... }
}
},
"+": {
"default": "transversal",
"variants": { "transversal": { ... } }
}
}
The target-key alphabets are operation-specific and documented in each operation’s subsection below. The inner container follows the flat default/variants rules.
Base variant fields¶
Every variant object contains the following fields (operation-specific fields are documented per operation type below):
Field |
Type |
Required |
Description |
|---|---|---|---|
|
string |
no |
Human-readable summary of the variant |
|
boolean |
yes |
Whether this variant provides fault-tolerant guarantees |
|
object |
no |
Quantum registers used (see Register declarations above) |
|
object |
no |
Classical registers used (see Register declarations above) |
|
string |
yes |
OpenQASM 3.0 circuit fragment |
|
array of strings |
no |
Citation keys resolving into |
|
list of objects |
no |
Output registers holding one bit per check; see Readout declarations below |
|
list of objects |
no |
Output registers holding one bit per block qubit read; see Readout declarations below |
qregs and cregs follow the scope-based model described in the Register declarations
subsection. Either may be omitted if the variant uses no registers of that type.
syndrome_cregs and transversal_readout_cregs may appear on a variant of every operation
kind. Readout declarations below specifies them, including the requirements that depend on the
kind; syndrome_measurement requires at least one of the two.
qasm is an OpenQASM 3.0 fragment. In an inline container the value is always an inline
string. In an archive container the value may be an inline string or a $ref object (e.g.
{"$ref": "circuits/syndrome_measurement_sequential.qasm"}) pointing to a file inside the archive. Inline
and externalized QASM may be freely mixed within a single archive.
Time-step convention: barrier instructions in QASM fragments delineate time steps.
Gates between two consecutive barriers (or between the start of the fragment and the first
barrier, or between the last barrier and the end) are understood to execute simultaneously
within a single time step. This convention allows consumers to reconstruct the intended gate
schedule, which is a code-implementation design choice that affects fault-tolerance
properties and cannot be inferred from the gate list alone. It is particularly important for
syndrome_measurement circuits, where the CNOT ordering determines which errors can spread
undetectably. Consumers building Stim circuits should map each time-step boundary to a TICK
instruction; qubits idle during a time step are candidates for idle-noise insertion.
A QASM fragment with no barrier instructions makes no scheduling claim: the consumer may
assume sequential execution or apply its own parallelization heuristics.
Fragment boundary rule: A QASM fragment must not begin or end with a barrier
statement, read through control flow (ignoring leading/trailing whitespace, blank lines,
and line comments): its first statement is not a barrier and, when that statement is a
control-flow statement, no block of it begins with one, recursively; likewise for the last
statement and the last statement of each block.
Inter-fragment synchronization is the consumer’s responsibility; a consumer that composes
fragments into a physical circuit inserts boundary barriers between adjacent fragments;
fragments that already carry boundary barriers would produce duplicate time-step markers.
Inner barriers separating time steps within the fragment are unchanged by this rule.
Helper reset rule: A helper is a quantum register the variant declares with
scope: "scratch". No initial state is guaranteed for a helper, nor for a quantum register the variant
itself declares with scope: "output", so a fragment must reset each qubit of such a register
before its first use: each such qubit the fragment touches is first touched by a reset
statement outside any if statement, a barrier not counting as a touch, and a first touch inside
an if statement, a reset included, counts as not reset. No scope lets a fragment name another
operation’s dynamic register, so the rule binds the fragment that creates the register.
Every other quantum register is persistent and outside this rule: the data registers (one per
operand block on a multi-block variant) and every other inherited "block" or "global"
register, such as a syndrome ancilla register declared in register_template. The format does not
require a fragment to reset a persistent register, and a fragment may still reset one.
state_preparation keeps its own input assumption: its data qubits start in physical |0⟩ (see
state_preparation below).
Readout declarations¶
Two variant fields declare which of a variant’s classical registers carry check values (see
Terminology): syndrome_cregs, one bit per check, and transversal_readout_cregs, one bit per
block qubit read. Either field may appear on a variant of every operation kind; the requirements
that depend on the kind are stated below and, where a kind adds its own, in that kind’s subsection.
The fields carry claims about the variant’s
fragment: the format requirements of §8 check their structure only, and a document whose claim is
false is valid and wrong.
A declaration states that its register is a check readout. On the unconditioned fragment, each
bit of a syndrome_cregs register equals the value of one check (for gauge sources, see “Gauge
sources” below); for each check a transversal_readout_cregs entry declares, the parity of the
register’s bits over the check’s support equals the check’s value, whatever its Pauli on each
qubit, since the fragment chooses the basis in which it reads each qubit. Check values are taken in
the entry’s frame (see “Frames” below).
syndrome_cregs entries:
Field |
Type |
Required |
Description |
|---|---|---|---|
|
string |
yes |
Name of a creg declared in the variant’s |
|
string |
yes |
Field name in |
|
list of int |
no |
0-indexed rows of the source field, in bit order; omit to declare every row in order |
|
integer |
by kind |
Operand block whose checks the register holds (see “Both fields” below) |
|
string |
by kind |
|
Bit i of the register is the value of check code.<source>[indices[i]], or of row i of
code.<source> when indices is absent. The register size equals len(indices), or the number of
rows of code.<source> when indices is absent. Entries of indices may repeat: each repeat is a
separate measurement of the same check. A syndrome_cregs entry has no qubits key, and a
register is named in at most one entry of the field. An empty list, "syndrome_cregs": [],
declares no check readout: it satisfies the requirement of a syndrome_measurement variant to
declare at least one of the two fields, and on a data_measurement variant it replaces the implied
readout, as any present field does (see data_measurement below).
transversal_readout_cregs entries:
Field |
Type |
Required |
Description |
|---|---|---|---|
|
string |
yes |
Name of a creg declared in the variant’s |
|
string |
yes |
Field name in |
|
list of int |
no |
Strictly increasing 0-indexed rows of the source field the entry declares; omit to declare every row |
|
list of int |
no |
|
|
integer |
by kind |
As for |
|
string |
by kind |
As for |
qubits holds one entry per register bit, the entries distinct and each in 0 .. code.n - 1; the
register size equals len(qubits), or code.n when qubits is absent. indices selects checks
only and its order carries no meaning, so it is strictly increasing: [2, 0] and [0, 0] are
invalid. Every declared check’s support lies within the qubits the register reads; a partial
qubits without indices is therefore invalid when a row of the source acts on a qubit the
register does not read. A register may appear in several entries, for example one per source in a
readout in mixed bases; such entries agree on block_index and qubits (an absent qubits
agrees with one listing 0 to the register’s size minus one), and no check of a source is declared
twice for one register.
Both fields:
A register appears in at most one of the two fields.
Every register named in either field is
"output"-scoped: its bits are read after the operation returns, while a"scratch"register may be pooled and carries no meaning across calls.Every bit of a declared register is written by a measurement somewhere in the fragment, branch bodies included, judged on the fragment’s text. A bit written only inside an
ifstatement is not measured on the unconditioned fragment, so a declaration that relies on it is false.A
data_measurementvariant’sresult_cregmay appear intransversal_readout_cregsonly; alogical_measurementvariant’sresult_cregappears in neither field.block_indexnames the operand block whose checks the register holds: one of the operand group’sblocklabels, matched as forblock_indexon ascope: "block"register, where only which operands share a label matters. It is required on every entry of alogical_gatesorlogical_measurementvariant and forbidden on every other kind.
Valid sources: source must be one of the fields present in the code section. The valid
values depend on code_type and are the same for both fields:
|
Valid |
|---|---|
|
|
|
|
|
|
|
|
Subsystem code types read checks from gauge generators, so the stabilizer-derived fields (H_X /
H_Z, stabilizer_generators) are not valid source values for subsystem codes.
Frames: Each entry names its checks in the entry frame or the exit frame (see Terminology). The
frame fixes the moment at which the checks are named, not where the bits are measured: a readout
taken after gates that transform the checks names them as they are in the declared frame, wherever
in the fragment the measurement happens. For a check the fragment leaves unchanged, both frames
name the same check. The exit frame also lets any kind name a check of a block the operation
produces afresh, which has no entering counterpart. An entry without frame takes the default of
its variant’s kind:
Operation kind |
Default |
|---|---|
|
|
|
|
|
none: every entry carries |
The entry frame is the recommended one wherever it can express a readout. The exit frame serves
checks the operation creates, and readouts taken after a gate inside the fragment that combines
checks, such as a transversal s or a transversal CX. A transversal h that maps the code onto
itself only relabels its checks, so a readout after it stays in the entry frame, over the
relabelled source (see the frames example below).
Sign contract: On the unconditioned fragment and in the declared frame, the parity of the bits a declaration gives for a check is 0 exactly when the check is +1 (see Check value in Terminology). A declaration whose bits give the inverted value is false.
Gauge sources: A syndrome_cregs entry over gauge_X, gauge_Z or gauge_generators keeps
its per-bit meaning, each bit the outcome of its gauge row. Since a gauge check that is not itself a
stabilizer has no defined value on a code state, the frame and the sign contract apply to each set of declared gauge rows
whose product is a stabilizer: the parity of their bits is that stabilizer’s value. A
transversal_readout_cregs entry over a gauge source follows the same rule, applied to the
parities of its rows.
Blocks left in a code state: Run without noise on its kind’s input (blocks in a code state,
physical |0⟩ for state_preparation, any state for reset), conditioned statements included, a
variant leaves every block whose data register it declares in a code state, except the block a
data_measurement variant measures; helper blocks the fragment prepares and measures are not
covered. A fragment that leaves such a block outside a code state does not implement its
operation.
What each field can express: syndrome_cregs gives every code type full coverage, one bit per
check from an extraction round. transversal_readout_cregs gives every code type a direct readout
of the checks that agree with the register’s per-qubit bases, and CSS codes also a readout through
a helper block coupled transversally to the data. Neither field expresses:
a list of bits per check, or flag bits: flag bits and other auxiliary classical outputs are listed in neither field, and are declared as separate
"output"-scope cregs (for example withpurpose: "flag");checks that act differently on a qubit they share, through one register: a register reads each qubit once in one basis, so such checks need separate readouts, and a readout through a helper that reveals the checks of a non-CSS code splits each check across two registers, which neither field can declare;
a readout equal, in the declared frame, to a product of checks, across blocks or within one block; declaring one factor of such a product is false.
Three cases are easily misdeclared. On a register that reads every qubit in one basis, a row that
mixes X and Z, such as the generator XZZXI of the [[5,1,3]] code, is no readout, and selecting
rows through indices does not make one: read in Z, no generator of that code is a readout. After
a transversal CX inside the fragment, bits reading the target block in Z equal, in the entry frame,
a product of Z checks on both blocks, which no single-block entry declares, and splitting the
product into one entry per block is false. The author declares such bits in the exit frame, where
they are the read block’s own Z checks. On a CSS code whose H_X equals its H_Z, such as the
Steane code, bits reading every qubit in Y have over row k a parity set by the product of X check
k and Z check k, not by either check alone, so declaring them over H_X or over H_Z is
false.
Worked examples¶
Steane-style round (syndrome_measurement): a helper block prepared in |+_L⟩ copies the
data’s X errors and is read in Z into c_x; a second helper block prepared in |0_L⟩ copies the Z
errors and is read in X into c_z.
"transversal_readout_cregs": [
{"name": "c_x", "source": "H_Z"},
{"name": "c_z", "source": "H_X"}
]
The register names follow the errors each helper copies, not the checks its bits read: c_x is
read in Z, so its parities are Z checks, and declaring it over H_X is false. The round leaves
every check unchanged, so the declaration holds in the default entry frame and in the exit frame
alike.
Projection preparation (state_preparation, key "0"): the fragment resets every data qubit,
which fixes every Z check, measures each X check through one helper qubit into c_synd, and
applies the Z correction the outcomes determine through conditioned statements.
"syndrome_cregs": [{"name": "c_synd", "source": "H_X"}]
The entry carries no frame, so it is in the exit frame, the default on state_preparation. On
the unconditioned fragment the X checks of the produced state are random, and c_synd[k] is the
raw measured parity, the value of X check k of the produced state; the correction that sets the
X checks to +1 is conditioned, outside the unconditioned fragment. In the entry frame the
declaration is false: the reset discards the entering state.
Teleported s (logical_gates, key s, one operand on block 0): a helper block prepared in
|+i_L⟩ is coupled to the data by a transversal CX, the data as control, and read in Z into
c_gate; a conditioned logical Z completes the gate.
"transversal_readout_cregs": [{"name": "c_gate", "source": "H_Z", "block_index": 0}]
After the CX, the helper’s parity over the support of Z check k is the data’s Z check k times
the helper’s own, which is +1 in the helper’s code state, so the parities are the data’s Z checks.
block_index names the data’s operand block, as logical_gates requires.
Transversal data measurement (data_measurement, key "Z", result_creg c_data_meas):
the fragment measures every data qubit in Z.
"transversal_readout_cregs": [{"name": "c_data_meas", "source": "H_Z"}]
For a "css" code this is also the readout the variant implies when it carries neither field: the
result_creg over H_Z under key "Z", over H_X under "X" (data_measurement below states
the rule for every code type). "transversal_readout_cregs": [] declares no readout.
Frames: a transversal h followed by a check readout (logical_gates, key h, one operand
on block 0): on the Steane [[7,1,3]] code, whose H_X and H_Z both have the rows 1111000,
0110110 and 0011011, the fragment encodes the helper in |0_L⟩ with an encoding circuit and turns
it into |+_L⟩ with a transversal h, applies the logical h to the data, couples data to helper by
a transversal CX, and reads the helper in Z.
OPENQASM 3.0;
include "stdgates.inc";
qubit[7] q_data;
qubit[7] a_read;
bit[7] c_read;
reset a_read;
h a_read[2];
h a_read[5];
h a_read[6];
cx a_read[2], a_read[0];
cx a_read[6], a_read[3];
cx a_read[5], a_read[1];
cx a_read[3], a_read[1];
cx a_read[1], a_read[4];
cx a_read[2], a_read[1];
cx a_read[2], a_read[3];
cx a_read[5], a_read[2];
h a_read;
h q_data;
cx q_data, a_read;
c_read = measure a_read;
"transversal_readout_cregs": [{"name": "c_read", "source": "H_X", "block_index": 0}],
"qregs": {
"q_data": {"scope": "block", "block_index": 0, "ref": "data_qreg"},
"a_read": {"scope": "scratch", "size": 7}
},
"cregs": {
"c_read": {"scope": "output", "size": 7}
}
The bits of c_read are helper outcomes. After the data’s h, the CX copies the data’s X errors
onto the helper, so the helper’s parity over row k is the data’s Z check k times the helper’s
own, which is +1 in the helper’s code state: the parity is Z check k of the produced block. The
h turns X check k of the entering block into that Z check, so the parity is the value of X
check k as the block enters: in the entry frame, the default on logical_gates, the entry names
H_X. Over H_Z in the entry frame the declaration is false, since the entering Z checks become
the produced X checks, which no bit reads. Over H_Z it is true only with "frame": "exit",
naming the same bits as the Z checks of the produced block. The logical qubit is carried through
the readout, not measured.
Permuted qubits (data_measurement, key "Z", result_creg c_perm, on the same code):
bit 5 reads qubit 6, bit 6 reads qubit 5, and every other bit i reads qubit i.
"transversal_readout_cregs": [{"name": "c_perm", "source": "H_Z", "qubits": [0, 1, 2, 3, 4, 6, 5]}]
Row 1 of H_Z, 0110110, acts on qubits 1, 2, 4 and 5, so its value is the parity of bits 1, 2,
4 and 6. Without qubits the entry would take bit i to read qubit i, which makes it false on
row 1.
state_preparation¶
Prepares a logical state from physical |0⟩ qubits. The QASM fragment assumes all qubits in the data register start in |0⟩; it applies the encoding circuit to produce the target logical state.
Uses the keyed default/variants container, keyed by the target logical state.
Target state alphabet:
Key |
Prepared logical state |
|---|---|
|
|0_L⟩ |
|
|1_L⟩ |
|
|+_L⟩ |
|
|-_L⟩ |
|
|+i_L⟩ |
|
|-i_L⟩ |
"j" is chosen for |-i_L⟩ rather than "-i" to keep every single-qubit state a single
character, so multi-qubit keys unambiguously concatenate one character per logical qubit.
For k=1 codes the key is a single character from the alphabet above. For k>1 codes the key
is a length-k string where character i specifies the target state for the i-th logical
qubit of the block, in the block-position order established by code.logical_operators
(see §1). For example, a k=2 code with key "0+" prepares |0_L⟩⊗|+_L⟩.
Variant bodies follow the base variant fields (description, fault_tolerant, qregs,
cregs, qasm). There is no basis field inside a variant body; the target state is
fully specified by the outer key.
Every variant must declare a qregs entry with scope: "block" and ref: "data_qreg": the
encoding circuit acts on the full data register of one code block.
A readout declaration on a state_preparation variant names its checks in the exit frame,
the checks of the prepared state, unless the entry carries frame (see the Frames table
under Readout declarations above).
Example:
"state_preparation": {
"0": {
"default": "non_ft",
"variants": {
"non_ft": {
"description": "Non-FT preparation of |0_L⟩",
"fault_tolerant": false,
"qregs": {
"data_qreg": {"scope": "block", "ref": "data_qreg"}
},
"qasm": "OPENQASM 3.0;\nqubit[7] data_qreg;\n..."
},
"ft_verified": {
"description": "FT preparation of |0_L⟩ with verification",
"fault_tolerant": true,
"qregs": {
"data_qreg": {"scope": "block", "ref": "data_qreg"},
"verif_anc": {"scope": "scratch", "size": 3}
},
"cregs": {
"verif_bits": {"scope": "scratch", "size": 3}
},
"qasm": "OPENQASM 3.0;\n..."
}
}
}
}
syndrome_measurement¶
Measures stabilizer syndromes without disturbing the logical information in the code block. The QASM fragment performs the syndrome extraction circuit and writes outcomes to classical registers.
Readout fields:
Field |
Type |
Required |
Description |
|---|---|---|---|
|
list of objects |
at least one of the two |
Identifies which output registers hold one bit per check and maps them to code fields |
|
list of objects |
at least one of the two |
Identifies which output registers hold a transversal readout and maps them to code fields |
Every syndrome_measurement variant must declare syndrome_cregs,
transversal_readout_cregs, or both. Both are base variant fields (see Base variant fields
above).
Repetition of syndrome measurement circuits is controlled by the error_correction_cycle
section (§6), not by individual syndrome measurement variants.
The entries of both fields, their valid sources, bit order and register sizes are specified under Readout declarations above.
Example (CSS code):
"syndrome_measurement": {
"default": "non_ft",
"variants": {
"non_ft": {
"description": "Non-FT sequential syndrome extraction",
"fault_tolerant": false,
"syndrome_cregs": [
{"name": "x_syn", "source": "H_X"},
{"name": "z_syn", "source": "H_Z"}
],
"qregs": {
"data_qreg": {"scope": "block", "ref": "data_qreg"},
"syndrome": {"scope": "block", "ref": "syndrome"}
},
"cregs": {
"x_syn": {"scope": "output", "size": 3, "purpose": "syndrome"},
"z_syn": {"scope": "output", "size": 3, "purpose": "syndrome"}
},
"qasm": "OPENQASM 3.0;\n..."
}
}
}
Design intent and recommended composition¶
The intent of syndrome_measurement is to expose the pieces of the
extraction circuit that are reused across cycle variants or steps, so
each piece can be named, addressed by error_correction_cycle.steps,
and composed into a full round. Each piece is one
syndrome_measurement variant; error_correction_cycle.variants.<name>.steps
chains them in order, with optional repeat for distance-scaled
rounds (see §6).
Where to draw the boundary between pieces follows the reuse pattern,
not a fixed granularity. The finest decomposition is per-stabilizer
(or per-row of code.H_X, code.H_Z, or code.stabilizer_generators):
each variant encodes the extraction circuit for a single generator,
and the EC cycle assembles full rounds, split X/Z rounds, Floquet
sequences, or partial-syndrome rounds without rewriting any QASM.
Coarser groupings (per X-block, per Z-block, per color class, per
ancilla group) are appropriate when the grouping is always measured
together; expose each as its own variant so the cycle can still
reorder or repeat the groups.
Embedding a full syndrome extraction as a single QASM string
inside one syndrome_measurement variant is also permitted. The
schema does not constrain the size or scope of the QASM fragment, so
a single variant may declare syndrome_cregs covering every row of
H_X and H_Z and emit the entire extraction circuit at once. This
form is useful when transcribing a published single-circuit figure
verbatim, for example, Landahl, Anderson, and Rice (arXiv:1108.5738,
Fig. 5), which presents a fault-tolerant extraction as one composed
circuit. The tradeoff is composability: a full-syndrome variant
cannot be reordered or interleaved through
error_correction_cycle.steps, so alternative schedules cannot be
expressed by composing the same variant with others.
Choose the variant boundary by what is shared. Where multiple cycle
variants or steps would use the same sub-circuit, factor it out as
its own syndrome_measurement variant so the composition mechanism
can do the assembly. Where the extraction is documented or designed
as a single indivisible unit and no piece is reused elsewhere, the
full-syndrome form is the natural choice.
logical_gates¶
Logical gate operations on one or more code blocks. Uses a logical-addressing container: the top level maps gate names to a list of operand groups, each containing variants.
Structure:
"logical_gates": {
"<gate_name>": [
{
"operands": [ ... ],
"default": "<variant_key>",
"variants": { "<variant_key>": { ... }, ... }
},
...
],
...
}
Gate name is a lowercase string identifying the logical gate (e.g. "h", "cx", "s",
"t"). The vocabulary is open; any name is valid. Recommended names align with standard gate
names for interoperability.
Identity is supplied implicitly by the consumer and is not looked up here: omitting it
from logical_gates is conforming, and a declared entry keyed "id" is not consulted (its
implementation is discarded).
Operand group fields:
Field |
Type |
Required |
Description |
|---|---|---|---|
|
list of objects |
yes |
Logical qubit arguments to the gate (see below) |
|
string |
yes |
Default variant key |
|
object |
yes |
Map from variant key to variant object |
operands: An ordered list describing each logical qubit argument to the gate. Each entry
is an object with:
Field |
Type |
Required |
Description |
|---|---|---|---|
|
integer |
yes |
Code block label, a non-negative integer that is arbitrary beyond the pattern of equal and distinct values it induces across the group’s operands |
|
integer or null |
yes |
Logical qubit index within the block (0-indexed); |
|
string |
no |
Informational role label (e.g. |
Each logical_qubit value (when not null) must be < code.k. The block values in
operands correspond to block_index values in the variant’s qregs register declarations:
operands sharing a block value act on the same block instance. A register declaring
block_index: L is therefore wired to the block instance the operands labelled L act on,
whatever non-negative integer L is. The number of distinct
block values determines how many code block instances the gate involves. Every
scope: "block" register in a logical_gates or logical_measurement variant must carry a
block_index field, even for single-block gates, so registers match unambiguously to
operands.
Variant fields within each operand group follow the base variant schema: description,
fault_tolerant, qregs, cregs, qasm.
Lookup: Given a gate name and the consumer’s concrete operands (each a (block_instance, logical_qubit_index) pair):
Normalize block indices. Assign abstract indices 0, 1, 2, … to the consumer’s distinct block instances in the order they first appear in the operand list. Two operands on the same block instance get the same abstract index; operands on different instances get different indices. This produces an abstract operand tuple comparable to the file’s
operandslists.Match block structure. Filter to operand groups whose
operandslist has the same length and the same pattern ofblockvalues (same-index positions share the sameblockvalue, different-index positions have differentblockvalues).Prefer exact logical qubit match. Among the remaining groups, prefer one where every
logical_qubitvalue equals the consumer’s logical qubit index at that position.Fall back to wildcards. If no exact match exists, accept a group where unmatched positions have
logical_qubit: null. If multiple wildcard groups match, prefer the one with the most non-null (exact) positions. Several matching groups sharing that highest count are ambiguous: the lookup errors rather than resolving them by declaration order. Validation flags a pair of groups that can tie this way: as an error when no further group over the sameblockpartition both pins more positions and agrees with the pair wherever they and it pin, since nothing declared can then outrank the pair, and as a warning when such a group exists and may resolve the calls the pair would tie on. The lookup error is therefore reachable only for operand groups handed to a consumer without validation, or for a declaration whose warning was left unaddressed.Error if no operand group matches after steps 3 to 4.
Within the matched operand group, the consumer selects a variant by name or uses default.
Worked example: A consumer requests cx(block_A, qubit 0, block_B, qubit 2). Step 1
assigns block_A → 0, block_B → 1, producing abstract operands [(0, 0), (1, 2)]. Step 2
filters to operand groups with two entries whose block values are distinct. Step 3 looks
for logical_qubit values [0, 2]. If no exact match, step 4 accepts [null, null] (the
wildcard group from the inter-block cx example above).
Example: single-qubit gate (wildcard):
"h": [
{
"operands": [{"block": 0, "logical_qubit": null}],
"default": "transversal",
"variants": {
"transversal": {
"description": "Transversal Hadamard",
"fault_tolerant": true,
"qregs": {
"data_qreg": {"scope": "block", "block_index": 0, "ref": "data_qreg"}
},
"qasm": "OPENQASM 3.0;\nqubit[7] data_qreg;\nh data_qreg[0]; ..."
}
}
}
]
Example: two-qubit inter-block gate:
"cx": [
{
"operands": [
{"block": 0, "logical_qubit": null, "role": "control"},
{"block": 1, "logical_qubit": null, "role": "target"}
],
"default": "transversal",
"variants": {
"transversal": {
"description": "Transversal CNOT",
"fault_tolerant": true,
"qregs": {
"data_qreg_0": {"scope": "block", "block_index": 0, "ref": "data_qreg"},
"data_qreg_1": {"scope": "block", "block_index": 1, "ref": "data_qreg"}
},
"qasm": "OPENQASM 3.0;\nqubit[7] data_qreg_0;\nqubit[7] data_qreg_1;\ncx data_qreg_0[0], data_qreg_1[0]; ..."
}
}
}
]
Example: two-qubit intra-block gate (k>1):
"cx": [
{
"operands": [
{"block": 0, "logical_qubit": 0, "role": "control"},
{"block": 0, "logical_qubit": 2, "role": "target"}
],
"default": "native",
"variants": {
"native": {
"description": "Intra-block CNOT between logical qubits 0 and 2",
"fault_tolerant": true,
"qregs": {
"data_qreg": {"scope": "block", "block_index": 0, "ref": "data_qreg"}
},
"qasm": "OPENQASM 3.0;\nqubit[7] data_qreg;\ncx data_qreg[0], data_qreg[3]; ..."
}
}
}
]
Authoring guidance: within-block multi-qubit gates. The wildcard rule carries two conditions. Full-block coverage is structural and validated; permutation invariance of the operation over the block’s logical-qubit set is a semantic claim no validator can check. A within-block multi-qubit gate declared with wildcards therefore matches every operand order a consumer writes, while its variant emits one fixed wiring, so a call whose pairing differs from the one the variant body implements compiles to that fixed wiring instead of being rejected. Declare concrete operand groups for such gates, one per pairing the code implements: a pairing that is absent then matches nothing and raises.
logical_measurement (optional)¶
Non-destructive measurement of one or more logical qubits within a block, or joint measurement of a multi-qubit Pauli observable. The code block survives the measurement; the measured logical qubits collapse to an eigenstate of the observable.
Uses the same logical-addressing container as logical_gates, but keyed by observable instead of gate
name.
Structure:
"logical_measurement": {
"<observable>": [
{
"operands": [ ... ],
"default": "<variant_key>",
"variants": { "<variant_key>": { ... }, ... }
},
...
],
...
}
Observable key is an uppercase Pauli string (alphabet {I, X, Y, Z}), where character i
gives the Pauli basis for operand i. Length equals the number of operands. Examples: "Z"
(single-qubit Z measurement), "XX" (joint X⊗X measurement).
Operand group fields are the same as logical_gates: operands, default, variants.
Lookup follows the same algorithm.
Operation-specific variant field:
Field |
Type |
Required |
Description |
|---|---|---|---|
|
string |
yes |
Name of the |
result_creg names a classical register declared in the variant’s cregs with
scope: "output". For a single Pauli product observable the register has size 1.
result_creg holds the outcome in one bit, so a per-qubit readout of a helper block cannot
serve as the outcome: the fragment folds the parity of the helper’s bits into the outcome bit
of result_creg. It may still declare the helper’s checks through transversal_readout_cregs,
on a register other than result_creg (see Readout declarations above).
Outcome wiring. A consumer invokes a logical measurement either with a tuple of
externally-managed classical bits whose length matches the result_creg size (the outcome
is written directly into those bits; no separate creg is materialized in the consumer’s
output circuit), or with an empty bit tuple, in which case the consumer materializes the
declared result_creg itself and retains it for downstream use. Any other bit-tuple length
is an error at the consumer layer. This contract lets a downstream compiler route
measurement outcomes into user-visible classical registers or into compiler-managed
internal registers without a format-level distinction.
Example:
"logical_measurement": {
"Z": [
{
"operands": [{"block": 0, "logical_qubit": null}],
"default": "ancilla_based",
"variants": {
"ancilla_based": {
"description": "Ancilla-based non-destructive Z measurement",
"fault_tolerant": false,
"result_creg": "meas_result",
"qregs": {
"data_qreg": {"scope": "block", "block_index": 0, "ref": "data_qreg"},
"meas_anc": {"scope": "scratch", "size": 1}
},
"cregs": {
"meas_result": {"scope": "output", "size": 1}
},
"qasm": "OPENQASM 3.0;\n..."
}
}
}
]
}
data_measurement¶
Measures all physical qubits in a single code block, destroying the encoded state. This operation always operates on exactly one block; multi-block data measurement is not supported (measure each block separately). Partial-block data measurement (measuring a strict subset of the block’s logical qubits) is likewise not representable in v1; measure the full block and derive any partial logical outcome from the raw bitstring. The consumer decodes the raw physical outcomes to extract logical measurement results.
Uses the keyed default/variants container, keyed by the measurement basis.
Basis alphabet:
Key |
Measurement basis |
|---|---|
|
Z-basis (computational) |
|
X-basis |
|
Y-basis |
The basis key determines which check matrix and logical operator the consumer uses for
decoding (e.g. Z-basis measurement uses H_Z for error detection and
logical_operators["Z"] for logical outcome extraction). For k>1 codes the basis applies
uniformly to all logical qubits in the block; per-qubit basis selection is not supported
in v1.
Operation-specific variant field:
Field |
Type |
Required |
Description |
|---|---|---|---|
|
string |
yes |
Name of the |
result_creg names a classical register declared in the variant’s cregs with
scope: "output". Its size must equal code.n. The variant body has no basis field;
the measurement basis is fully specified by the outer key.
Every variant must declare a qregs entry with scope: "block" and ref: "data_qreg": the
measurement covers the full data register of one code block.
Implied readout: A variant may declare the checks its result_creg reads through
transversal_readout_cregs (see Readout declarations above). A variant that carries neither
syndrome_cregs nor transversal_readout_cregs implies a readout instead, set by
code_type and the basis key:
|
Key |
Key |
Key |
|---|---|---|---|
|
|
|
none |
|
|
|
none |
|
none |
none |
none |
An implied readout means the same as the transversal_readout_cregs entry
{"name": <result_creg>, "source": <source>} in the default entry frame. For
"subsystem_css" its values are those of the stabilizers that products of gauge rows form, as
“Gauge sources” under Readout declarations states. When syndrome_cregs is also absent, an
absent transversal_readout_cregs implies the readout, while "transversal_readout_cregs": []
is an explicit declaration of no readout. Any declaration in either field, an empty list
included, replaces the implied readout entirely: the variant then declares exactly what its
fields state.
Example:
"data_measurement": {
"Z": {
"default": "z_basis",
"variants": {
"z_basis": {
"description": "Transversal Z-basis measurement",
"fault_tolerant": false,
"result_creg": "data_bits",
"qregs": {
"data_qreg": {"scope": "block", "ref": "data_qreg"}
},
"cregs": {
"data_bits": {"scope": "output", "size": 7}
},
"qasm": "OPENQASM 3.0;\nqubit[7] data_qreg;\nbit[7] data_bits;\nmeasure data_qreg -> data_bits;"
}
}
}
}
reset (optional)¶
Resets a code block to a known logical state from an arbitrary state. The QASM fragment
typically includes physical reset instructions followed by an encoding circuit. Unlike
state_preparation, which assumes physical |0⟩ input, reset takes qubits in an arbitrary
state.
Uses the keyed default/variants container, keyed by the target logical state. The
target-state alphabet and k>1 multi-character key rule are identical to state_preparation
(see above). The variant body has no basis field; the target state is fully specified
by the outer key.
Every variant must declare a qregs entry with scope: "block" and ref: "data_qreg": the
reset acts on the full data register of one code block.
Every readout entry on a reset variant, in either field, carries frame: the kind has no
default frame (see the Frames table under Readout declarations above).
Example:
"reset": {
"0": {
"default": "non_ft",
"variants": {
"non_ft": {
"description": "Physical reset followed by non-FT state preparation",
"fault_tolerant": false,
"qregs": {
"data_qreg": {"scope": "block", "ref": "data_qreg"}
},
"qasm": "OPENQASM 3.0;\nqubit[7] data_qreg;\nreset data_qreg;\n// ...encoding circuit..."
}
}
}
}
§4 properties: Metadata and Provenance¶
The properties section is an optional free-form key-value store for provenance and citation
metadata. No key is required. Unknown keys are accepted without error.
The following keys are conventionally supported with standardized semantics:
"properties": {
"uuid": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
"author": ["A. M. Steane"],
"creator": "my-qecx-toolkit 1.0.0",
"license": "CC-BY-4.0",
"created_date": "2024-09-15",
"references": [
{
"key": "steane_1996",
"title": "Error correcting codes in quantum theory",
"doi": "10.1103/PhysRevLett.77.793",
"arxiv": "quant-ph/9601029",
"note": "Defines the [[7,1,3]] Steane code"
}
]
}
Key |
Type |
Description |
|---|---|---|
|
string |
UUIDv4 for content-addressable identification |
|
string or list |
Author(s) or organization who created this file |
|
string |
Software tool and version that produced this file |
|
string |
SPDX license identifier or URL |
|
string |
ISO 8601 date |
|
array of |
Bibliographic references; see §4.1. |
These keys are purely informational and do not affect loading behavior.
§4.1 reference_entry: Bibliographic reference schema¶
Each entry in properties.references is an object with the following fields
(all individually optional, but at least one of doi, arxiv, or url must
be present):
Field |
Type |
Required |
Description |
|---|---|---|---|
|
string |
Yes |
Stable identifier used to cite this entry from variants. Must match |
|
string |
No |
Paper / resource title for human readability. |
|
string |
No |
DOI without URL prefix (e.g. |
|
string |
No |
arXiv identifier (e.g. |
|
string |
No |
Direct URL, used as a fallback when no DOI or arXiv identifier exists. |
|
string |
No |
Short human-readable note describing the reference’s role. |
|
string |
No |
Verbatim author list supplied by the file, rendered as-is by tools (no structured author array). |
|
integer |
No |
Publication year. |
additionalProperties is false on each entry; unknown fields are rejected.
Rendering (non-normative): tools may present an entry as a citation that
combines authors, year, title, and the available identifiers (doi,
arxiv, url). The exact citation layout is the consuming tool’s concern and
is not fixed by this format.
Ordering convention: by convention, the first entry in references is
the primary (code-defining) reference; subsequent entries are auxiliary
(e.g. FT schedule source, state-preparation synthesis source). This is a
documentation convention and not enforced by the validator.
Variant-level citations: any variant object (inside
state_preparation, syndrome_measurement, error_correction_cycle,
logical_gates, logical_measurement, reset, or
data_measurement) may include a references field whose value is
an array of strings. Each string must resolve to the key of some entry in
the top-level properties.references list. The semantic validator enforces
this resolution; JSON Schema enforces only that the value is a list of
strings. Use variant-level references to cite papers that apply only to
that particular variant (e.g. the FT Clifford schedule used by one
syndrome_measurement variant).
Archive-container externalization¶
The section’s one unit of externalization is the references list, with the canonical
member references.json. The metadata fields around it are floor: no canonical member form
carries them. A $ref may equally stand at the whole section (properties.json) or at a
single entry (references/<key>.json); those coarser and finer spellings are legal
non-canonical forms of the same content.
§5 qubit_layout: Spatial Geometry and Coordinates¶
An optional top-level section providing spatial and structural metadata for codes with geometric structure (surface codes, color codes, etc.). Useful for decoders that exploit spatial information (MWPM, Union-Find) and for visualization tools.
"qubit_layout": {
"tiling_type": "4.8.8",
"topology": "planar",
"cell_complex": {
"num_vertices": 12,
"edges": [[0, 1], [1, 2], [0, 3], [1, 3], [1, 4], [2, 4]],
"faces": [
{"vertices": [0, 1, 4, 3], "color": 0},
{"vertices": [1, 2, 5, 4], "color": 1},
{"vertices": [3, 4, 7, 6]}
]
},
"embedding": {
"dimension": 2,
"coordinate_type": "cartesian",
"vertex_coordinates": [[0.0, 0.0], [1.0, 0.0], [2.0, 0.0], [0.5, 0.5], [1.5, 0.5]]
},
"qubit_placement": {
"data_qreg": {"cell": "vertex", "mapping": [0, 1, 2, 3, 4, 5, 6]},
"syndrome": {"cell": "face", "mapping": [0, 1, 2]},
"aux_reg": {"coordinates": [[5.0, 3.0], [6.0, 3.0]]}
}
}
Field |
Type |
Required |
Description |
|---|---|---|---|
|
string |
no |
Tiling/tessellation type (e.g. |
|
string |
no |
Manifold topology (e.g. |
|
object |
no |
Combinatorial cell complex structure (vertices, edges, faces) |
|
object |
no |
Geometric embedding of the cell complex; requires |
|
object |
no |
Maps registers to cell complex elements or provides explicit coordinates; a |
All fields are optional. A file may provide only descriptive metadata (tiling_type,
topology), only qubit_placement with explicit coordinates (no cell complex), or only a
cell_complex that consumers walk directly. A cell_complex with no qubit_placement
draws a warning: the geometry carries no register.
tiling_type and topology are free-form strings. The values listed above are
conventional; consumers should accept unknown values without error.
cell_complex¶
A pure combinatorial structure representing the code’s geometric tiling as a cell complex (vertices = 0-cells, edges = 1-cells, faces = 2-cells). The cell complex captures connectivity and face structure that is not derivable from the algebraic code definition.
Field |
Type |
Required |
Description |
|---|---|---|---|
|
integer |
yes |
Total number of vertices (0-cells) |
|
array of [int, int] |
yes |
Vertex index pairs; each pair defines an edge (1-cell) |
|
array of objects |
no |
Face (2-cell) definitions |
When faces is absent, the structure degenerates to a graph. Each edge is an unordered pair
of vertex indices in [0, num_vertices).
Each face object has the following fields:
Field |
Type |
Required |
Description |
|---|---|---|---|
|
array of int |
yes |
Ordered vertex indices forming the face boundary |
|
integer |
no |
Coloring assignment (e.g. 0/1/2 for a 3-coloring). Required by Chromobius for color codes |
Design principle: only non-derivable annotations. The color field is the only face
annotation because it represents an arbitrary choice (multiple valid colorings exist for a
given cell complex). Other properties are derivable from the cell complex topology and are
therefore excluded to avoid consistency obligations:
Boundary detection: An edge is a boundary edge iff it belongs to exactly one face. A face is a boundary face iff it has at least one boundary edge. A vertex is a boundary vertex iff it is an endpoint of a boundary edge.
Face type / shape: Derivable from the vertex count of the face (e.g. 4 vertices → square, 8 → octagon).
embedding¶
A geometric embedding of the cell complex into Euclidean space. Requires cell_complex to
be present.
Field |
Type |
Required |
Description |
|---|---|---|---|
|
integer (>= 1) |
yes |
Embedding space dimension; validates coordinate tuple lengths |
|
string |
yes |
Coordinate system (e.g. |
|
array of arrays of number |
yes |
One coordinate tuple per vertex; array length = |
qubit_placement¶
Maps registers to cell complex elements or provides explicit coordinates for qubits not
placed on the cell complex. A cell_complex with no placements draws a warning.
Each key is a register name that must exist in register_template (from either global or
per_code_block scope). Each value takes one of two forms:
Cell-placed: qubit is located on a cell complex element:
{"cell": "vertex", "mapping": [0, 1, 2, 3]}
Field |
Type |
Description |
|---|---|---|
|
|
Type of cell complex element |
|
array of int |
Element indices; |
For "vertex", indices are in [0, num_vertices). For "edge", indices are positions in
the edges array. For "face", indices are positions in the faces array. A cell placement
requires cell_complex; a register placed by explicit coordinates does not.
Explicit coordinates: qubit is not on the cell complex:
{"coordinates": [[5.0, 3.0], [6.0, 3.0]]}
Field |
Type |
Description |
|---|---|---|
|
array of arrays of number |
Coordinate tuples; array length = register size. If |
Derived qubit positions: When a register is cell-placed and an embedding is present,
qubit positions are derived from the cell complex geometry:
vertex →
vertex_coordinates[mapping[i]]edge → midpoint of the two endpoint coordinates
face → centroid of the face’s vertex coordinates
Archive-container externalization¶
The section’s units of externalization are its fields holding unbounded collection content:
cell_complex.edges→layout/edges.jsoncell_complex.faces→layout/faces.jsonembedding.vertex_coordinates→layout/vertex_coordinates.jsonqubit_placement→layout/qubit_placement.json
A $ref may equally stand at cell_complex, at embedding, or at the whole section
(layout/cell_complex.json, layout/embedding.json, layout/qubit_layout.json); those are
legal non-canonical forms beside the canonical leaf members above. The coordinate arrays of a
single placement entry are floor, not a unit: see “Externalization granularity” under
Containers.
No-graph scenario¶
For codes without meaningful geometry (e.g. random QLDPC codes), qubit_layout may be
omitted entirely. Alternatively, qubit_placement may provide only explicit coordinates
(without a cell_complex) for visualization purposes, e.g. from a graph layout algorithm.
§6 error_correction_cycle: EC Cycle Composition¶
A required top-level section that defines how syndrome measurement variants are composed into
complete error correction cycles. This section bridges the gap between individual syndrome
measurement circuits (defined in operations) and the full protocol that a decoder or
simulator needs to execute.
"error_correction_cycle": {
"default": "ft_standard",
"variants": {
"ft_standard": {
"description": "Standard FT cycle: d rounds of full syndrome extraction",
"fault_tolerant": true,
"steps": [
{"measurement": "full_syndrome", "repeat": {"ref": "code.d"}}
]
},
"split_xz": {
"description": "Alternating X/Z rounds, repeated d times",
"fault_tolerant": true,
"steps": [
{"measurement": "x_stabilizers"},
{"measurement": "z_stabilizers"}
],
"repeat": {"ref": "code.d"}
},
"non_ft": {
"description": "Single round, no repetition",
"fault_tolerant": false,
"steps": [
{"measurement": "non_ft_full"}
]
}
}
}
The section is a single variant group (see Terminology), following the same
default/variants container structure as syndrome_measurement (see §3).
Field |
Type |
Required |
Description |
|---|---|---|---|
|
string |
yes |
Name of the default cycle variant |
|
object |
yes |
At least one named cycle variant |
Each cycle variant has the following fields:
Field |
Type |
Required |
Description |
|---|---|---|---|
|
string |
no |
Human-readable description |
|
boolean |
no |
Whether this cycle provides fault-tolerance guarantees |
|
array of objects |
yes |
Ordered sequence of measurement steps (min 1) |
|
integer or ref |
no |
Number of times to repeat the entire step sequence (default: 1) |
|
array of strings |
no |
Citation keys resolving to entries in |
Each step object has the following fields:
Field |
Type |
Required |
Description |
|---|---|---|---|
|
string |
yes |
Name of a variant in |
|
integer or ref |
no |
Number of times to repeat this step within the sequence (default: 1) |
Parametric references¶
The repeat field accepts either a concrete integer or a reference object that resolves
to an integer value from the code or qubit_layout section:
"repeat": 3 // concrete integer
"repeat": {"ref": "code.d"} // reference to code distance
"repeat": {"ref": "code.n"} // reference to physical qubit count
The ref value uses dot-notation to address fields in the document. The path’s leading
segment must name the code or the qubit_layout section; a path led by any other section
does not resolve. The anchor set is defined per format version and may grow in a later
version. The referenced field must resolve to a plain integer. When code.d is an
asymmetric distance object (e.g. {"X": 3, "Z": 5}), the reference must use the specific
sub-path: {"ref": "code.d.X"} or {"ref": "code.d.Z"}. A ref that resolves to a
non-integer value is a validation error.
Execution semantics¶
A cycle variant’s execution proceeds as follows:
For each repetition of the cycle (controlled by the cycle-level
repeat):Execute each step in
stepsorder.For each step, execute the referenced
syndrome_measurementvariant the number of times indicated by the step’srepeat.
For example, the split_xz variant above with "repeat": {"ref": "code.d"} (where d = 3)
produces the sequence: x_stabilizers, z_stabilizers, x_stabilizers, z_stabilizers, x_stabilizers, z_stabilizers (6 total measurement rounds).
Use cases¶
Standard FT protocol: Single variant repeated d times.
Split X/Z measurement: Separate X-stabilizer and Z-stabilizer variants, alternated.
Floquet codes: Multiple distinct 2-body measurement variants forming a periodic schedule, repeated d times.
Partial measurement protocols: Variants that measure subsets of stabilizers, composed into a complete cycle.
For guidance on factoring syndrome_measurement variants so they
compose cleanly with steps (and on when a single-stabilizer or
full-circuit form is appropriate), see §3 Design intent and
recommended composition.
§7 decoder_config: Syndrome-Decoder Declaration¶
An optional top-level section that declares which syndrome decoders a code implementation
supports and, for each, carries the per-detector metadata that decoder needs. The section
maps a decoder slug (a short decoder name such as pymatching or chromobius) to a
config body. The presence of a slug is itself the capability declaration: a slug with an
empty body ("pymatching": {}) means “this code supports this decoder, with no extra
metadata”; a slug with a populated body ("chromobius": { ... }) means “supported, and here
is its configuration.” A file that omits decoder_config entirely declares no decoders; it
is fully valid.
"decoder_config": {
"chromobius": {
"parameters": {
"max_weight": 4
},
"color": {
"H_X": [0, 0, 1, 2, 1, 2, 2, 0],
"syndrome_measurement": {
"split_xz": {
"x_syn": [0, 0, 1, 2]
}
}
}
},
"pymatching": {}
}
Top-level fields¶
Field |
Type |
Required |
Description |
|---|---|---|---|
(slug) |
object |
n/a |
One entry per supported decoder; the key is the decoder slug and the value is its config body. Any number of slugs may appear; an empty |
Each slug’s config body is an object with one reserved key and any number of per-detector tags:
Field |
Type |
Required |
Description |
|---|---|---|---|
|
object |
no |
Free map of global, non-per-detector settings for this decoder (e.g. a weight bound). Opaque to the generic layer; interpreted by the decoder |
(tag) |
object |
no |
A per-detector tag (e.g. |
Parametric references¶
Like the repeat field in error_correction_cycle (see §6), a value may be supplied as a
reference object {"ref": "<dot.path>"} that resolves against the document at load time.
The decoder_config references generalize the integer-only repeat reference along one
axis: a path may contain at most one * projection segment. The leading-segment rule of
§6 holds here too: a path must be led by the code or the qubit_layout section.
{"ref": "code.d"} // scalar: resolves to one value
{"ref": "qubit_layout.cell_complex.faces.*.color"} // list: maps over faces, one color each
A path with no * resolves to a scalar; a path with a single * segment maps the suffix over
the list at that position and resolves to a list (one element per item). A scalar reference is
usable as one element of a value list; a list reference is usable as a whole-value entry. The
referenced values carry the tag’s own type (the integer-only constraint that applies to
repeat does not apply here). A reference that cannot be resolved, or whose resolved length
disagrees with the syndrome source or register it anchors, is a validation error.
Relationship to the data decoder (Appendix A)¶
This section is the syndrome-side decoder declaration: it concerns the decoders that act
on syndrome bits produced by syndrome_measurement. It is orthogonal to the final-readout
data decoder described in Appendix A, which is derived from the code section (its check
matrices and logical operators) rather than declared here. Neither references the other; a
file may carry one, both, or neither.
Validation¶
decoder_config is validated in two semantic tiers:
A decoder-agnostic tier checks the structure that holds for any decoder: every anchor key is a valid syndrome source for the code (or the reserved
syndrome_measurement), everysyndrome_measurementoverride names a real variant and a classical register listed in that variant’ssyndrome_cregs, every resolved value list has the length its anchor requires, and every reference resolves.A decoder-specific tier checks, per slug in the reserved decoder set (below), the tags and value types that decoder requires. A slug outside the reserved set is accepted with the decoder-agnostic tier only, plus a warning that decoder-specific validation does not run for it; the file stays valid.
The reserved decoder set and each decoder’s requirements:
Slug |
Decoder |
Requirements |
|---|---|---|
|
BP-OSD |
no required tags; any tags it carries get the decoder-agnostic checks only |
|
Chromobius |
a |
|
PyMatching |
no required tags; any tags it carries get the decoder-agnostic checks only |
|
Tesseract |
no required tags; any tags it carries get the decoder-agnostic checks only |
Consumption¶
A consumer reads two surfaces from this section. The set of supported decoders and their
global parameters answers “which decoders can run on this code.” The per-detector tags,
resolved against each syndrome register’s source and indices, answer “what metadata does
each syndrome bit carry,” so a detector built from a syndrome bit inherits that bit’s tag
values. Selecting and running a decoder is a consumer concern; the format only declares the
support and the metadata.
Optional additive section¶
decoder_config is an optional additive section. A file that omits it is fully
valid, exactly as for qubit_layout and properties. Because the top-level document is an
open object, an optional section adds no requirement to files that omit it; introducing one
therefore does not raise the minimum spec version a file must declare.
§8 Format Requirements¶
This section is the normative catalogue of the format’s requirements. Each row states one
requirement: its stable ID, the Requirement a conforming document must satisfy, the
Violation condition under which the requirement fails, and the Severity of that failure.
An ID is a stable identifier for its requirement and does not change once assigned.
Each requirement is checked when a document is loaded; the Severity column states whether an
unmet requirement invalidates the document (Error), is only reported (Warning), or is
tolerated for forward compatibility (Ignored).
Top-level and versioning¶
ID |
Requirement |
Violation |
Severity |
|---|---|---|---|
|
A file’s major schema version must be one the consumer supports. |
Major version unsupported by the consumer |
Error |
|
A file’s minor schema version must not exceed the consumer’s supported minor version for its major. |
File minor > the consumer’s supported minor |
Warning |
|
A document must declare all required top-level keys: |
Any of |
Error |
|
An unrecognized top-level key is permitted and ignored, preserving forward compatibility. |
None; a key not in the defined set is tolerated |
Ignored (forward compat) |
code section¶
ID |
Requirement |
Violation |
Severity |
|---|---|---|---|
|
A |
Mandatory field missing for declared |
Error |
|
|
Any ≤ 0 or non-integer (for integer |
Error |
|
For a |
|
Error |
|
For a |
A |
Error |
|
Every check or gauge matrix must have |
Number of columns ≠ |
Error |
|
A sparse check or gauge matrix’s declared |
|
Error |
|
|
|
Error |
|
Every |
Any Pauli string length ≠ |
Error |
|
Every stabilizer generator Pauli string must have length |
Any Pauli string length ≠ |
Error |
|
|
|
Error |
|
|
|
Error |
register_template section¶
ID |
Requirement |
Violation |
Severity |
|---|---|---|---|
|
|
|
Error |
|
|
|
Error |
|
|
|
Error |
|
Register names across |
Duplicate name across |
Error |
|
A user-named |
A register name does not match |
Error |
|
|
|
Error |
|
A |
An |
Error |
|
A |
|
Error |
operations section: general¶
ID |
Requirement |
Violation |
Severity |
|---|---|---|---|
|
|
Any of |
Error |
|
An operation container’s |
|
Error |
|
Every operation variant must declare a |
Variant lacks |
Error |
|
A variant’s QASM fragment must parse. |
QASM fragment fails to parse |
Error |
|
A variant’s QASM fragment must not begin or end, ignoring blank lines and comments, with a |
Variant QASM fragment’s first or last statement, or the first or last statement of a block of a leading or trailing control-flow statement at any depth, is |
Error |
|
A variant’s QASM fragment must keep its control flow within the conditional profile: |
Variant QASM fragment parses and carries a loop, a |
Error |
|
Each qubit of a quantum register the variant itself declares with |
Variant QASM fragment parses and a touched qubit of a |
Error |
Operation register declarations (qregs/cregs)¶
ID |
Requirement |
Violation |
Severity |
|---|---|---|---|
|
An inherited register’s |
|
Error |
|
An inherited register’s |
An inherited register’s |
Error |
|
An inherited ( |
An inherited register declaration carries a |
Error |
|
A |
|
Error |
|
A register’s QASM declaration size must equal the size implied by its scope (inherited: template size; dynamic: declared size). |
Register size in QASM declaration differs from size implied by scope (inherited: template size; dynamic: declared size) |
Error |
|
Every register name the QASM fragment declares must appear in |
QASM declares a register name not in |
Error |
|
Every register name a variant declares in |
Variant declares a register name not in QASM |
Error |
|
Every qubit or clbit the QASM fragment declares must belong to a named register; a loose bit that the register-keyed |
QASM declares a loose bit (qubit or clbit) belonging to no register, which the register-keyed |
Error |
|
A |
A |
Error |
|
A |
A |
Error |
|
A |
A |
Error |
|
The purposes |
A register other than the designated readout register declares |
Error |
|
A |
|
Error |
|
A |
|
Error |
Readout declarations¶
ID |
Requirement |
Violation |
Severity |
|---|---|---|---|
|
Each |
|
Error |
|
Each |
|
Error |
|
A register must be named in at most one |
Two |
Error |
|
A |
A |
Error |
|
The size of the register a |
Register size ≠ number of rows/elements in |
Error |
|
Every index in a |
Any index in |
Error |
|
Each |
|
Error |
|
Each |
|
Error |
|
The size of the register a |
Register size ≠ |
Error |
|
The entries of a |
An entry of |
Error |
|
Every entry of a |
Any entry of |
Error |
|
A |
An entry of |
Error |
|
Every index in a |
Any index in |
Error |
|
The support of every check a |
A declared row of |
Error |
|
|
Two entries naming one register select a common row of the same |
Error |
|
|
Two entries naming one register carry different |
Error |
|
A register must appear in at most one of a variant’s |
A register is named in both the |
Error |
|
A register named in |
A |
Error |
|
A |
A |
Error |
|
Every |
An entry of either field in a |
Error |
|
A |
|
Error |
|
A |
|
Error |
|
Every |
An entry of either field in a |
Error |
|
Every bit of a register named in |
Variant QASM fragment parses and a bit of a register named in either field is the target of no |
Error |
state_preparation / reset¶
ID |
Requirement |
Violation |
Severity |
|---|---|---|---|
|
Every outer key must consist only of characters from |
Any outer key contains a character outside |
Error |
|
Every outer key’s length must equal |
Outer-key length ≠ |
Error |
Data-register binding (state_preparation / reset / data_measurement)¶
ID |
Requirement |
Violation |
Severity |
|---|---|---|---|
|
A variant must declare a |
A variant declares no |
Error |
syndrome_measurement¶
ID |
Requirement |
Violation |
Severity |
|---|---|---|---|
|
Every |
Variant lacks both the |
Error |
logical_gates / logical_measurement¶
ID |
Requirement |
Violation |
Severity |
|---|---|---|---|
|
The value for each gate name must be a list. |
Value for a gate name is not a list |
Error |
|
Every operand group must declare |
Operand group lacks |
Error |
|
Every non-null |
Any |
Error |
|
A |
|
Error |
|
A |
Key is not a valid uppercase Pauli string ( |
Error |
|
A |
Key length ≠ number of operands |
Error |
|
A |
|
Error |
|
No two operand groups under one gate name / observable may share the same |
Two operand groups under the same gate name / observable share the same |
Error |
|
No two operand groups under one gate name / observable may take the same number of operands over the same |
Two operand groups under the same gate name / observable take the same number of operands over the same |
Error, or Warning when a further group over the same partition pins more positions and agrees with the pair wherever they and it pin, so it may outrank them |
|
When |
At |
Warning |
|
Within one |
A block’s operands are neither all-concrete nor a full-block |
Error |
|
Within one |
An operand group pins the same |
Error |
|
The identity gate is supplied implicitly by the consumer and is never looked up from |
|
Warning |
data_measurement¶
ID |
Requirement |
Violation |
Severity |
|---|---|---|---|
|
Every outer key must be one of |
Outer key is not in |
Error |
|
A |
|
Error |
|
A |
Register size ≠ |
Error |
properties section¶
ID |
Requirement |
Violation |
Severity |
|---|---|---|---|
|
Every entry in |
Two or more entries in |
Error |
|
Every string in a variant-level |
A variant’s |
Error |
|
Every entry in |
A |
Error |
qubit_layout section¶
cell_complex¶
ID |
Requirement |
Violation |
Severity |
|---|---|---|---|
|
Every vertex index in an edge must be less than |
Any vertex index in an edge ≥ |
Error |
|
Every vertex index in a face must be less than |
Any vertex index in a face ≥ |
Error |
|
A face’s |
|
Error |
embedding¶
ID |
Requirement |
Violation |
Severity |
|---|---|---|---|
|
|
|
Error |
|
|
|
Error |
|
Every coordinate tuple must have length equal to |
Any tuple length ≠ |
Error |
qubit_placement¶
ID |
Requirement |
Violation |
Severity |
|---|---|---|---|
|
When |
|
Warning |
|
Every |
Key not in |
Error |
|
An entry declaring |
Entry declares |
Error |
|
A |
|
Error |
|
Explicit |
Explicit |
Error |
|
When |
|
Error |
|
When |
|
Error |
|
When |
|
Error |
|
When |
|
Error |
|
When |
|
Error |
|
Explicit |
Explicit |
Error |
error_correction_cycle section¶
ID |
Requirement |
Violation |
Severity |
|---|---|---|---|
|
|
|
Error |
|
Each step’s |
|
Error |
|
A |
|
Error |
|
A |
|
Error |
decoder_config section¶
The decoder-agnostic requirements below apply to any decoder; the decoder-specific requirements (that a recognized decoder carries every tag it requires, and that its tag values have an accepted type) apply only per recognized slug.
ID |
Requirement |
Violation |
Severity |
|---|---|---|---|
|
A declared tag’s anchor map must carry at least one anchor. |
A tag’s anchor map is empty; a tag must carry at least one anchor. An empty config body (a slug declaring no tags) is not affected |
Error |
|
Every anchor key under a tag must be a valid syndrome source for the |
An anchor key under a tag is neither a valid syndrome source for the |
Error |
|
A source anchor’s resolved value list must have one entry per syndrome operator of that |
A source anchor’s resolved value list length ≠ the number of syndrome operators in that |
Error |
|
A |
A |
Error |
|
A |
A |
Error |
|
A |
A |
Error |
|
A |
A |
Error |
|
Every parametric reference in the section must resolve, and a whole-value reference must resolve to a list. |
A parametric reference in the section does not resolve, or a whole-value reference resolves to a value that is not a list |
Error |
|
A decoder slug should be one the consumer recognizes, so decoder-specific requirements can be checked for it. |
A decoder slug outside the reserved set (§7 Validation); decoder-specific validation does not run for it |
Warning |
|
A recognized decoder must carry every tag it requires. |
A recognized decoder is missing a tag it requires |
Error |
|
A recognized decoder’s tag values must have a type that decoder accepts. |
A recognized decoder’s tag value has a type the decoder does not accept |
Error |
Archive container¶
ID |
Requirement |
Violation |
Severity |
|---|---|---|---|
|
In an inline-container document, no field value may be a |
Any field value is a |
Error |
|
Every file path referenced in |
File path reference in |
Error |
§9 Versioning and Compatibility¶
Compatibility model¶
Backward compatibility is the primary guarantee: a consumer supporting version X.Y must accept any valid file with version X.Z where Z ≤ Y. A v0.2 consumer reads v0.1 files without error; a v0.1 consumer reads v0.1 files.
A consumer silently ignores any unknown top-level key within its supported major version.
Forward tolerance is best-effort: a v0.1 consumer encountering a v0.2 file should report the version mismatch clearly (not crash silently), but is not required to load or validate v0.2 features. The recommended behavior is a warning identifying the version gap; the consumer may then attempt best-effort validation of the parts it understands.
Major versions (0.x → 1.0) are breaking. A consumer must reject files with an unsupported major version with a clear error.
Minor versions (0.1 → 0.2) are backwards-compatible. The guarantee: any valid v0.1 file is also valid under the v0.2 spec.
Rules for minor version changes¶
A minor version increment must not:
Remove or rename existing fields
Add new required top-level keys or required fields in existing sections
Change the type or semantics of existing fields in incompatible ways
Narrow the set of accepted values for existing fields
A minor version increment may:
Add new optional top-level sections (e.g.
lattice_surgery)Add new optional fields to existing objects
Add new optional operation types in
operations(e.g.verification,ancilla_preparation)Add new values to informational enums (e.g. new
purposevalues); old consumers that don’t recognise the value may safely ignore itWiden the accepted values for existing fields (e.g. extend
basisto accept multi-character strings like"ZX"): old consumers reject the new values, which is expected; a v0.2 file using only v0.1-compatible values in all existing fields is indistinguishable from a v0.1 file except for the version string
When is a change major?¶
A change requires a major version increment if it would cause a valid older-version file to become invalid under the new spec, or if it requires old consumers to change their processing logic for existing fields. In particular:
Adding a new
code_typeis a major change: it introduces new conditional required fields and new validation rules that old consumers cannot derive.Restructuring required sections (e.g. changing the
operationscontainer model) is major.Changing the meaning of an existing field is major.
Key test for minor compatibility: Take any valid v0.2 file. Replace all v0.2-specific field values with v0.1-compatible values (or remove v0.2-only optional fields). The resulting file must pass a v0.1 validator with no errors. If this test fails, the change is major.
qec_version semantics¶
The value declares the minimum spec version needed to fully interpret all features in the
file. A file that uses only v0.1 features should declare "0.1" even if the producing tool
supports v0.2. This minimises spurious version warnings when the file is consumed by older
consumers.
Schema design guidelines¶
These guidelines apply when creating or updating a JSON Schema for a new format version.
Closed objects: Use
additionalProperties: falseon objects with a well-defined, closed structure (e.g.binary_matrix_sparse,distance). This catches typos and structural errors in files targeting that version.Open objects: Use
additionalProperties: trueon objects that are intentionally open-ended (e.g.properties_section,code_section, top-level document).Extending closed objects: When a new minor version adds fields to a previously-closed object, the new version’s schema adds those fields and keeps
additionalProperties: falsefor the new field set. The old schema’sfalsecorrectly rejects unknown fields for its version; this is by design, not a bug.Enum constraints: Reflect what a consumer of the version can process. New enum values in a new version appear in the new schema.
Version field: The
qec_versionfield is validated by format (well-formed"major.minor"string), not by exact match. Version compatibility, major-version rejection, and minor-version warnings are validation-time checks against the consumer’s supported version.
Non-normative Notes¶
QASM feature scope. The format requires OpenQASM 3.0 for circuit fragments. Beyond the
requirements the operations rule table states, among them the conditional control-flow
profile set out under Conditional control flow below, a fragment may use advanced language
features such as subroutines or timing. Such a fragment is valid QASM, but a consumer that
implements only a simpler subset of OpenQASM 3.0 may be unable to parse it. Authors targeting
broad interoperability keep fragments within widely supported language features.
Conditional control flow. A fragment may carry an if statement, with or without an else.
Either branch may be empty, and either may hold further if statements, to any depth. A branch
body may hold whatever the fragment may hold outside it, gates, measurements, resets and
barriers included. The condition takes one of two forms.
The first tests a single classical bit against a boolean and may be written as a bare bit
(if (c[0])), as a negated bit (if (!c[0]) or if (~c[0])), or as an equality or inequality
against a boolean constant in either operand order (if (c[0] == true), if (false != c[0]));
these spellings reduce to two conditions, the bit being true and the bit being false. The second
form tests one whole classical register against an integer constant, again in either operand
order (if (c == 3), if (3 == c)). Every bit a condition reads belongs to exactly one register
the fragment declares.
Validation reports an error for every other control-flow construct and every other condition
form: while and for loops, box statements, switch statements, a bit compared to another
bit, an ordering comparison, a compound boolean or bitwise operator, arithmetic, a register
compared to anything but an integer constant, a bit compared to an integer, a bare register
(if (c)), a slice of a register (if (c[0:1] == 3)), and a condition on a bit that no
declared register carries. Forms a consumer cannot parse at all, switch statements among
them, are reported as unparsable rather than under the profile rule.
Inside the profile a further boundary separates what a stabilizer simulation can carry from what only compiles and exports. A single-bit condition, an equality on a one-bit register included, whose branch body holds only single-qubit Pauli gates maps onto a Pauli gate controlled by a measurement outcome, which a stabilizer simulator carries directly. An equality on a register wider than one bit constrains every bit of that register at once, and a branch body reaching beyond single-qubit Pauli gates is not a Pauli correction; neither maps onto that form. A fragment using either stays valid and compiles and exports unchanged; its results come from executing the exported circuit and post-processing the outcomes.
How checks change across an operation. A readout declaration names its checks in one frame,
and the format does not declare how the checks entering an operation become the checks leaving
it. That relation follows from the fragment and the code’s checks: propagating each check as a
stabilizer flow through the Clifford fragment with its conditioned statements removed (the
unconditioned fragment) gives, for each entering check the fragment carries through, the leaving
check or product of checks it becomes; a check the fragment discards, as a reset does, becomes
none. A consumer without a Clifford simulator can use every readout declaration inside one
operation, but cannot pair a check’s values across an operation that relabels, combines or
replaces checks, such as a transversal h, a transversal CX or a reset.
Appendix A: Decoding Guidance (non-normative)¶
This appendix describes how a consumer derives error syndromes and logical measurement
outcomes from the data in the code section. It is informational; the format does not
prescribe a specific decoder.
Notation: For a Pauli string P of length n, let X(P) denote the binary vector
where X(P)[i] = 1 iff P[i] ∈ {X, Y}, and Z(P) where Z(P)[i] = 1 iff
P[i] ∈ {Z, Y}. All arithmetic is mod 2.
Data measurement: CSS codes ("css", "subsystem_css")¶
Given a Z-basis measurement outcome vector m (length n):
Error syndrome:
s = H_Z · m, one bit per row ofH_Z; detects X errors (bit flips)Logical Z outcome for qubit i:
Z(logical_operators["Z"][i]) · m
Given an X-basis outcome vector m:
Error syndrome:
s = H_X · m, one bit per row ofH_X; detects Z errors (phase flips)Logical X outcome for qubit i:
X(logical_operators["X"][i]) · m
For subsystem CSS codes the syndrome measurement extracts syndromes from gauge generators,
so gauge_X/gauge_Z are used in place of H_X/H_Z.
Data measurement: general stabilizer codes ("stabilizer", "subsystem_stabilizer")¶
Symplectic representation¶
Each stabilizer generator g_j (j = 1, …, n−k) has an X-component vector X(g_j) and
a Z-component vector Z(g_j) as defined above. Collect these into two binary matrices:
A (size
[s, n]): row j isX(g_j)B (size
[s, n]): row j isZ(g_j)
where s = len(stabilizer_generators). For "stabilizer" codes, s = n − k.
For CSS codes every row of A or B (but not both) is zero; for general codes rows may be non-zero in both A and B.
Why the simple formulas fail for mixed-weight generators¶
A computational-basis state |m⟩ is an eigenstate of a Pauli operator P = X^a Z^b
only when a = 0 (i.e. P is purely Z-type), in which case the eigenvalue is
(−1)^{b · m}. For a generator g = X^a Z^b with a ≠ 0:
g |m⟩ = (−1)^{b · m} |m ⊕ a⟩ ≠ ±|m⟩
The state |m⟩ is not an eigenstate of g, so Z(g) · m does not correspond to a
stabilizer eigenvalue. Within the code space, the value of Z(g) · m varies across the
computational-basis support of a single logical state; it is a stochastic quantity, not
a deterministic syndrome bit. (Specifically, the orbit of the stabilizer group’s
X-components maps m → m ⊕ a_k, which shifts Z(g_j) · m by Z(g_j) · X(g_k);
this quantity is non-zero for at least some pairs j ≠ k in any non-CSS code.)
What is extractable from single-basis measurement¶
A Z-basis measurement of all n qubits yields n outcome bits. The deterministic
information, values that are the same for every m in the support of a given codespace
state that is a logical-Z eigenstate (with a given error), is the coset of m in
Z₂ⁿ / row_space(A). (For a general superposition of logical-Z eigenstates, only the
r_Z syndrome bits are deterministic across the full support; the logical-Z bits vary
between cosets.) This provides
exactly n − rank(A) deterministic bits, decomposing as:
Component |
Count |
Description |
|---|---|---|
Logical Z outcomes |
|
One bit per logical qubit |
Error syndrome bits |
|
Detect X errors (bit flips) |
(For "stabilizer" codes, s = n − k, so r_Z = n − k − rank(A). For
"subsystem_stabilizer" codes, s < n − k and the remaining n − rank(A) − k − r_Z
deterministic bits correspond to gauge degrees of freedom.)
The remaining rank(A) syndrome bits, needed to detect Z errors and the Z-component of
Y errors, are inaccessible from Z-basis measurement alone. Symmetrically, X-basis
measurement yields n − rank(B) deterministic bits: k logical X outcomes and
r_X = s − rank(B) syndrome bits detecting Z errors.
Summary:
Measurement basis |
Extractable syndrome bits |
Detects |
Logical outcome |
|---|---|---|---|
Z-basis |
|
X errors |
logical Z |
X-basis |
|
Z errors |
logical X |
For CSS codes rank(A) equals the number of X-type generators and rank(B) equals the
number of Z-type generators, so Z-basis measurement recovers all Z-type syndrome bits and
the formulas reduce to the CSS case above. When r_Z + r_X < s, full syndrome extraction
from single-basis destructive measurement alone is impossible (see “Full syndrome
recovery” below).
Extraction via row reduction¶
Z-basis syndrome extraction:
Form the stabilizer tableau
T = [A | B]with rows(X(g_j) | Z(g_j)).Row-reduce
Tover GF(2) by Gaussian elimination on the left (A) block. Apply each row operation to both halves simultaneously: replacing row j with row j ⊕ row k in A corresponds to replacing generatorg_jwithg_j · g_k, and the B row must be updated toB_j ⊕ B_k.After reduction, let
T' = [A' | B']. Rows whereA'_j = 0correspond to Z-extractable generators: purely Z-type stabilizersg'_j = ±Z^{B'_j}. There are exactlyr_Z = s − rank(A)such rows.For each Z-extractable generator: the syndrome bit is
B'_j · m (mod 2).
Sign caveat: When multiplying generators during row reduction, the product may
acquire a phase. For generators g_j = i^{p_j} X^{a_j} Z^{b_j} and
g_k = i^{p_k} X^{a_k} Z^{b_k}, the product has phase
p_j + p_k + 2(b_j · a_k) (mod 4). If the resulting phase is 2 (mod 4), the reduced
generator has eigenvalue −1 on the codespace, meaning B'_j · m = 1 (not 0) for all m
in the error-free codespace. The consumer should either:
Track phases through the row reduction and use the expected value (0 or 1) as the reference for each syndrome bit, or
Determine the reference empirically from a known codespace state.
X-basis syndrome extraction: Apply the same procedure with the roles of A and B
swapped: row-reduce on the B (right) block. Rows with B'_j = 0 are X-extractable;
syndrome bits are A'_j · m (mod 2).
Logical outcomes¶
The formulas Z(l) · m (Z-basis) and X(l) · m (X-basis) are valid only when the
logical operator l is purely Z-type or purely X-type respectively. If a
logical_operators entry has mixed Pauli weight, the consumer must first obtain a
purely-typed representative.
Purely Z-type logical Z operators always exist. For any [[n,k,d]] stabilizer code,
the purely Z-type elements of the normalizer form a subspace of dimension n − rank(A).
The purely Z-type stabilizers account for s − rank(A) of these dimensions, leaving
exactly k dimensions for independent purely Z-type logical Z operators. (For subsystem
codes with gauge qubits, there are an additional g gauge-Z dimensions.)
Deriving a purely Z-type representative: Given Z̄ = X^γ Z^δ from
logical_operators["Z"], find a stabilizer s whose X-component equals γ:
solve c · A = γ over GF(2) for a coefficient vector c, then
Z̄ · s = Z^{δ ⊕ c·B} is the purely Z-type representative. The logical Z outcome is
then (δ ⊕ c·B) · m (mod 2). (This system is always consistent for a valid logical Z
operator: since a purely Z-type representative Z̄' = Z^{δ'} exists (proven above),
the product Z̄ · Z̄' is a stabilizer with X-component γ, hence
γ ∈ row_space(A).)
If γ = 0 (the stored representative is already purely Z-type), use Z(Z̄) · m
directly; no correction needed.
Symmetrically, purely X-type logical X operators always exist and are derived by the dual procedure (solve against B).
Worked example: [[5,1,3]] five-qubit code¶
Generators: XZZXI, IXZZX, XIXZZ, ZXIXZ.
X-component matrix A and row reduction:
A: Row-reduce A:
[1, 0, 0, 1, 0] [1, 0, 0, 1, 0] (pivot col 0)
[0, 1, 0, 0, 1] → [0, 1, 0, 0, 1] (pivot col 1)
[1, 0, 1, 0, 0] [0, 0, 1, 1, 0] (R3 ⊕ R1, pivot col 2)
[0, 1, 0, 1, 0] [0, 0, 0, 1, 1] (R4 ⊕ R2, pivot col 3)
rank(A) = 4 = s = n − k. Therefore r_Z = s − rank(A) = 4 − 4 = 0.
Result: Z-basis measurement of the five-qubit code yields zero syndrome bits and
only the logical Z outcome. No X-error correction is possible from Z-basis measurement
alone. (By symmetry, rank(B) = 4, so X-basis measurement also yields zero syndrome
bits.)
Logical Z: Z̄ = ZZZZZ has X(Z̄) = [0,0,0,0,0], already purely Z-type.
Logical Z outcome: m_0 ⊕ m_1 ⊕ m_2 ⊕ m_3 ⊕ m_4.
This illustrates the extreme case where a non-CSS code’s stabilizer generators have maximally large X-component rank, leaving no room for syndrome extraction from a single-basis destructive measurement. Error correction for such codes requires ancilla-based syndrome measurement circuits or a decoding Clifford before measurement.
CSS recovery¶
For CSS codes (code_type: "css"), every generator is either purely X-type (b_j = 0)
or purely Z-type (a_j = 0). Therefore:
rank(A)=rank(H_X)(the rank of the X-type parity check matrix), andrank(B)=rank(H_Z). When these matrices have full row rank (the typical case),rank(A)equals the number of X-type generators andrank(B)equals the number of Z-type generators.All Z-type generators are trivially Z-extractable (already have
A'_j = 0); their Z-parts form the rows ofH_Z. The formulas reduce tos = H_Z · m.Logical Z operators for CSS codes are conventionally purely Z-type;
Z(Z̄_i) · mgives the logical outcome directly.
Full syndrome recovery¶
When r_Z + r_X < s, the following approaches provide access to the remaining syndrome
bits:
Decoding Clifford: Apply a Clifford circuit before measurement that rotates the code so all generators become Z-type. The
operationssection may provide such a circuit (e.g. as a"data_measurement"variant with a pre-measurement unitary).Mixed-basis measurement: Measure different subsets of qubits in different bases, with the partitioning informed by the stabilizer structure. The analysis of mixed-basis measurement is code-dependent and beyond the scope of this appendix.
Ancilla-based syndrome extraction: Use the non-destructive
syndrome_measurementcircuits fromoperations, which always provide full syndrome information regardless of code type.
Subsystem codes¶
For "subsystem_stabilizer" codes, the stabilizer group is a subgroup of the gauge
group, with s = len(stabilizer_generators) < n − k independent generators. The
row-reduction procedure applies to stabilizer_generators to identify purely Z-type
stabilizers; alternatively, it may be applied to gauge_generators to identify purely
Z-type gauge operators, from which stabilizer syndromes can be derived (since each
stabilizer is a product of gauge generators).
Syndrome measurement¶
The syndrome_cregs and transversal_readout_cregs fields directly map each output
register to a field in code via the source annotation and the optional indices,
qubits, block_index and frame annotations (see Readout declarations, §3). Each bit of a
syndrome_cregs register is the value of one check; for a transversal_readout_cregs
register, each declared check’s value is the parity of the register’s bits over the check’s
support. For a gauge source, the values are those of the stabilizers that products of
declared gauge rows form (see “Gauge sources” there). Beyond forming these parities, no further
decoding of the readout bits is required; the mapping is explicit. The consumer passes these check values to a decoder
along with the referenced check matrix or generator list.
Logical measurement (non-destructive)¶
The result_creg contains the logical measurement outcome directly. No decoding is
required; the circuit has already extracted the logical eigenvalue via ancilla-based
indirect measurement.
Revision history¶
Format version 0.1¶
Initial version.