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 $ref references where appropriate.

  • code/: algebraic code data externalized from the code section. Binary matrix fields, Pauli string list fields, and each list of logical_operators may be replaced by a $ref pointing to a .json (dense or sparse matrix) or .txt (one Pauli string per line) file.

  • circuits/: OpenQASM 3.0 circuit files externalized from operations. Any "qasm" field may be replaced by a $ref (e.g. {"$ref": "circuits/syndrome_measurement_sequential.qasm"}).

  • layout/: spatial data externalized from qubit_layout. The edges and faces of cell_complex, embedding.vertex_coordinates, and the qubit_placement map may each be replaced by a $ref pointing to a .json file.

  • cycles/, decoders/, references/: one file per error_correction_cycle variant, decoder_config entry, and bibliography entry externalized as a whole object.

  • references.json: the properties.references list externalized as a whole; the properties section may equally stand in properties.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

code

H_X, H_Z, gauge_X, gauge_Z, stabilizer_generators, gauge_generators, logical_operators.X, logical_operators.Z

operations

each variant’s qasm

qubit_layout

cell_complex.edges, cell_complex.faces, embedding.vertex_coordinates, qubit_placement

properties

references

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 of properties, 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 a syndrome_measurement override;

  • 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:

code_type

Required fields (besides n, k, d)

Optional fields

Description

"stabilizer"

stabilizer_generators, logical_operators

General Pauli stabilizer code

"css"

H_X, H_Z, logical_operators

CSS code: all stabilizers are purely X-type or purely Z-type

"subsystem_stabilizer"

gauge_generators, logical_operators

stabilizer_generators

Subsystem/gauge code with general Pauli generators

"subsystem_css"

gauge_X, gauge_Z, logical_operators

H_X, H_Z

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

css

subsystem_css

stabilizer

subsystem_stabilizer

stabilizer_generators

forbidden

forbidden

required

optional

gauge_generators

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 length n over the alphabet {I, X, Y, Z}.

  • External file (archive container only): {"$ref": "code/stabilizers.txt"}, a $ref object 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 where rows is a list of per-row column indices (columns of nonzero entries), and shape is [m, n]. Recommended for QLDPC codes with sparse matrices.

  • External file (archive container only): {"$ref": "code/H_X.json"}, a $ref object pointing to a .json file 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)

"css" with appropriate H matrices

Color codes (triangular, hexagonal)

"css" with 3-colourable stabilizers

General CSS codes (Steane, etc.)

"css"

General stabilizer codes (5-qubit, etc.)

"stabilizer" with Pauli strings

Subsystem / gauge codes (Bacon-Shor, compass)

"subsystem_stabilizer" / "subsystem_css"

QLDPC codes (k=1 or k>1)

"css" with sparse binary H matrices; k>1 fully supported via block-based register model

Floquet / dynamical codes

Planned: floquet_schedule extension in a future version

Concatenated codes

Planned: code_composition extension in a future version


§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 all n physical data qubits in the block. Its size must equal code.n. Operations that act on data qubits reference this register by the name data_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:

purpose

Applies to

Meaning

"logical_data"

data_qreg, and a data_measurement variant’s result_creg

Physical data qubits encoding logical information, or the bits holding their measurement outcomes

"syndrome"

ancilla qregs

Syndrome extraction ancilla

"flag"

ancilla qregs, cregs

Flag qubits or bits for fault-tolerant protocols

"cat"

ancilla qregs

CAT/GHZ state ancilla

"verification"

ancilla qregs, cregs

State verification ancilla or outcome bits

"magic_state"

ancilla qregs

Magic state injection ancilla

"logical_measurement"

"output"-scope dynamic cregs

Logical measurement outcome bits

"transversal_readout"

"output"-scope dynamic cregs

Bits of a transversal readout (see Readout declarations, §3)

"custom"

any

Non-standard use; pair with optional "purpose_description" string

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:

scope

Category

Meaning

ref

size

"global"

inherited

References a register from register_template.global

required

omitted

"block"

inherited

References a register from register_template.per_code_block

required

omitted

"scratch"

dynamic

Created per invocation with no initial state guaranteed; a fragment resets each qubit of a "scratch" quantum register before its first use; discarded or pooled after the operation returns

absent

required

"output"

dynamic

Created per invocation with no initial state guaranteed; a fragment resets each qubit of an "output" quantum register before its first use; retained after the operation returns for downstream use

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

state_preparation

yes

keyed default/variants (by state)

Prepare a logical state from physical |0⟩ qubits

syndrome_measurement

yes

flat default/variants

Extract stabilizer syndromes without disturbing logical information

logical_gates

yes

logical-addressing

Apply logical gate operations (see below for distinct structure)

data_measurement

yes

keyed default/variants (by basis)

Measure all physical qubits, destroying the code block

logical_measurement

no

logical-addressing

Non-destructive measurement of a subset of logical qubits within a block

reset

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), and data_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_gates and logical_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 in variants.

  • 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

description

string

no

Human-readable summary of the variant

fault_tolerant

boolean

yes

Whether this variant provides fault-tolerant guarantees

qregs

object

no

Quantum registers used (see Register declarations above)

cregs

object

no

Classical registers used (see Register declarations above)

qasm

string

yes

OpenQASM 3.0 circuit fragment

references

array of strings

no

Citation keys resolving into properties.references; see §4.1

syndrome_cregs

list of objects

no

Output registers holding one bit per check; see Readout declarations below

transversal_readout_cregs

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

name

string

yes

Name of a creg declared in the variant’s cregs with scope: "output"

source

string

yes

Field name in code whose rows the bits correspond to (valid values below)

indices

list of int

no

0-indexed rows of the source field, in bit order; omit to declare every row in order

block_index

integer

by kind

Operand block whose checks the register holds (see “Both fields” below)

frame

string

by kind

"entry" or "exit": the frame the checks are named in (see “Frames” below)

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

name

string

yes

Name of a creg declared in the variant’s cregs with scope: "output"

source

string

yes

Field name in code whose rows the entry declares (valid values below)

indices

list of int

no

Strictly increasing 0-indexed rows of the source field the entry declares; omit to declare every row

qubits

list of int

no

qubits[i] is the block qubit bit i reads; omit when bit i reads block qubit i

block_index

integer

by kind

As for syndrome_cregs

frame

string

by kind

As for syndrome_cregs

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 if statement is not measured on the unconditioned fragment, so a declaration that relies on it is false.

  • A data_measurement variant’s result_creg may appear in transversal_readout_cregs only; a logical_measurement variant’s result_creg appears in neither field.

  • block_index names the operand block whose checks the register holds: one of the operand group’s block labels, matched as for block_index on a scope: "block" register, where only which operands share a label matters. It is required on every entry of a logical_gates or logical_measurement variant 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:

code_type

Valid source values

"css"

"H_X", "H_Z"

"stabilizer"

"stabilizer_generators"

"subsystem_css"

"gauge_X", "gauge_Z"

"subsystem_stabilizer"

"gauge_generators"

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 frame

state_preparation

"exit"

syndrome_measurement, logical_gates, logical_measurement, data_measurement

"entry"

reset

none: every entry carries frame

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 with purpose: "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"

|0_L⟩

"1"

|1_L⟩

"+"

|+_L⟩

"-"

|-_L⟩

"i"

|+i_L⟩

"j"

|-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

syndrome_cregs

list of objects

at least one of the two

Identifies which output registers hold one bit per check and maps them to code fields

transversal_readout_cregs

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..."
    }
  }
}

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

operands

list of objects

yes

Logical qubit arguments to the gate (see below)

default

string

yes

Default variant key

variants

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

block

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

logical_qubit

integer or null

yes

Logical qubit index within the block (0-indexed); null = wildcard: any logical qubit, identity irrelevant, asserting the operation is permutation-invariant over the block’s full logical-qubit set. Valid only at full-block coverage (every operand on that block is null and they number exactly code.k); concrete otherwise

role

string

no

Informational role label (e.g. "control", "target")

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):

  1. 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 operands lists.

  2. Match block structure. Filter to operand groups whose operands list has the same length and the same pattern of block values (same-index positions share the same block value, different-index positions have different block values).

  3. Prefer exact logical qubit match. Among the remaining groups, prefer one where every logical_qubit value equals the consumer’s logical qubit index at that position.

  4. 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 same block partition 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.

  5. 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

result_creg

string

yes

Name of the output-scope creg holding the measurement outcome

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"

Z-basis (computational)

"X"

X-basis

"Y"

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

result_creg

string

yes

Name of the output-scope creg holding the measurement outcomes

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:

code_type

Key "Z"

Key "X"

Key "Y"

"css"

result_creg over H_Z

result_creg over H_X

none

"subsystem_css"

result_creg over gauge_Z

result_creg over gauge_X

none

"stabilizer", "subsystem_stabilizer"

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

uuid

string

UUIDv4 for content-addressable identification

author

string or list

Author(s) or organization who created this file

creator

string

Software tool and version that produced this file

license

string

SPDX license identifier or URL

created_date

string

ISO 8601 date

references

array of reference_entry

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

key

string

Yes

Stable identifier used to cite this entry from variants. Must match ^[A-Za-z][A-Za-z0-9_-]*$. Unique within the file.

title

string

No

Paper / resource title for human readability.

doi

string

No

DOI without URL prefix (e.g. 10.1103/PhysRevLett.97.180501).

arxiv

string

No

arXiv identifier (e.g. 1108.5738 or quant-ph/0605138).

url

string

No

Direct URL, used as a fallback when no DOI or arXiv identifier exists.

note

string

No

Short human-readable note describing the reference’s role.

authors

string

No

Verbatim author list supplied by the file, rendered as-is by tools (no structured author array).

year

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

tiling_type

string

no

Tiling/tessellation type (e.g. "square", "hexagonal", "triangular", "4.8.8")

topology

string

no

Manifold topology (e.g. "planar", "torus", "periodic")

cell_complex

object

no

Combinatorial cell complex structure (vertices, edges, faces)

embedding

object

no

Geometric embedding of the cell complex; requires cell_complex

qubit_placement

object

no

Maps registers to cell complex elements or provides explicit coordinates; a cell_complex without placements draws a warning

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

num_vertices

integer

yes

Total number of vertices (0-cells)

edges

array of [int, int]

yes

Vertex index pairs; each pair defines an edge (1-cell)

faces

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

vertices

array of int

yes

Ordered vertex indices forming the face boundary

color

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

dimension

integer (>= 1)

yes

Embedding space dimension; validates coordinate tuple lengths

coordinate_type

string

yes

Coordinate system (e.g. "cartesian", "lattice_units")

vertex_coordinates

array of arrays of number

yes

One coordinate tuple per vertex; array length = num_vertices, tuple length = dimension

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

cell

"vertex", "edge", or "face"

Type of cell complex element

mapping

array of int

Element indices; mapping[i] is the element index for qubit i. Length = register size

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

coordinates

array of arrays of number

Coordinate tuples; array length = register size. If embedding is present, tuple length must equal embedding.dimension; otherwise, tuple length is inferred from the first entry and must be consistent across all entries

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.json

  • cell_complex.faces → layout/faces.json

  • embedding.vertex_coordinates → layout/vertex_coordinates.json

  • qubit_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

default

string

yes

Name of the default cycle variant

variants

object

yes

At least one named cycle variant

Each cycle variant has the following fields:

Field

Type

Required

Description

description

string

no

Human-readable description

fault_tolerant

boolean

no

Whether this cycle provides fault-tolerance guarantees

steps

array of objects

yes

Ordered sequence of measurement steps (min 1)

repeat

integer or ref

no

Number of times to repeat the entire step sequence (default: 1)

references

array of strings

no

Citation keys resolving to entries in properties.references; see §4.1

Each step object has the following fields:

Field

Type

Required

Description

measurement

string

yes

Name of a variant in operations.syndrome_measurement.variants

repeat

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:

  1. For each repetition of the cycle (controlled by the cycle-level repeat):

  2. Execute each step in steps order.

  3. For each step, execute the referenced syndrome_measurement variant the number of times indicated by the step’s repeat.

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 decoder_config ({}) is valid and declares no decoders

Each slug’s config body is an object with one reserved key and any number of per-detector tags:

Field

Type

Required

Description

parameters

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. color, weight). The key is the tag name and the value is an anchor map (below) carrying at least one anchor

Per-detector tags and anchor maps

A per-detector tag assigns a value to every detector the decoder will build from this code’s syndrome bits. The assignment is given as an anchor map: an object whose keys are either a syndrome source name or the reserved syndrome_measurement key.

Anchor key

Type

Description

(source name)

value list or ref

A syndrome source field name (e.g. H_X, H_Z, stabilizer_generators), matching the source of a syndrome classical register (see §3). The value is a list with one entry per syndrome operator of that source (one per row of code.<source>). This is the primary, DRY assignment: it propagates to every detector via the syndrome register’s existing source and indices binding

syndrome_measurement

object

An override keyed variant -> classical register -> per-bit value list, for the cases where a bit’s value must differ from its source-operator value, or must differ per syndrome-measurement variant. The key is singular, aligning with operations.syndrome_measurement

A source-anchored value is a list of one value per syndrome operator of that source, or a whole-value parametric reference that resolves to such a list. The syndrome_measurement override nests one level deeper: each variant name maps to an object keyed by classical register name, whose value is a per-register-bit list (one value per bit of that register) or a whole-value reference. An override entry takes precedence over the source-anchored value for the bits of the named register in the named variant. An override reaches only the registers listed in a syndrome_measurement variant’s syndrome_cregs; every other check, declared in transversal_readout_cregs or in the syndrome_cregs of another operation kind, or implied by a data_measurement variant, takes the source-anchored value of its row.

In an archive container a decoder entry externalizes as one whole object (decoders/<slug>.json): its tag names sit directly under the slug, so the entry itself is its heavy content, and an individual tag value is floor (see “Externalization granularity” under Containers).

The per-detector tag values are decoder-defined and opaque to the generic layer: each entry may be a primitive (an integer, string, or boolean) or a structured value (for example a vector or a map), as the decoder requires. A decoder-specific validator checks their types and required tags. A value entry, whether source-anchored or an override-register list, is one of:

  • an explicit list, one entry per syndrome operator (e.g. [0, 0, 1, 2]),

  • a list whose entries mix literal values and element-wise parametric references, or

  • a single whole-value parametric reference resolving to such a list.

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), every syndrome_measurement override names a real variant and a classical register listed in that variant’s syndrome_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

bposd

BP-OSD

no required tags; any tags it carries get the decoder-agnostic checks only

chromobius

Chromobius

a color tag; every value, source-anchored or override, is an integer after reference resolution

pymatching

PyMatching

no required tags; any tags it carries get the decoder-agnostic checks only

tesseract

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

FMT_DOC_VERSION_MAJOR_SUPPORTED

A file’s major schema version must be one the consumer supports.

Major version unsupported by the consumer

Error

FMT_DOC_VERSION_MINOR_SUPPORTED

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

FMT_DOC_REQUIRED_TOP_LEVEL_KEYS

A document must declare all required top-level keys: qec_version, code, register_template, operations, and error_correction_cycle.

Any of qec_version, code, register_template, operations, error_correction_cycle missing

Error

FMT_DOC_UNKNOWN_TOP_LEVEL_KEYS_IGNORED

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

FMT_CODE_REQUIRED_FIELDS_BY_TYPE

A code declaration must carry every field its code_type requires.

Mandatory field missing for declared code_type

Error

FMT_CODE_NKD_VALID

n, k, and an integer d must each be a positive integer.

Any ≤ 0 or non-integer (for integer d)

Error

FMT_CODE_CSS_ORTHOGONALITY

For a "css" or "subsystem_css" code, H_X and H_Z must be orthogonal mod 2 (H_X · H_Z^T = 0).

H_X · H_Z^T ≠ 0 (mod 2) for "css" or "subsystem_css"

Error

FMT_CODE_CSS_LOGICAL_PURITY

For a "css" or "subsystem_css" code, each logical X operator must be purely X-type and each logical Z operator purely Z-type.

A "css"/"subsystem_css" logical X operator is not purely X-type, or a logical Z operator is not purely Z-type

Error

FMT_CODE_MATRIX_COLUMNS

Every check or gauge matrix must have n columns.

Number of columns ≠ n for any check/gauge matrix

Error

FMT_CODE_SPARSE_MATRIX_SHAPE

A sparse check or gauge matrix’s declared shape[1] must equal n.

shape[1] ≠ n

Error

FMT_CODE_LOGICAL_OP_COUNT

logical_operators["X"] and logical_operators["Z"] must each hold k Pauli strings.

logical_operators["X"] or ["Z"] length ≠ k

Error

FMT_CODE_LOGICAL_OP_LENGTH

Every logical_operators Pauli string must have length n.

Any Pauli string length ≠ n

Error

FMT_CODE_STABILIZER_GEN_LENGTH

Every stabilizer generator Pauli string must have length n.

Any Pauli string length ≠ n

Error

FMT_CODE_STABILIZER_GENS_CODE_TYPE

stabilizer_generators may be present only when code_type is "stabilizer" or "subsystem_stabilizer".

stabilizer_generators present but code_type is not "stabilizer" or "subsystem_stabilizer"

Error

FMT_CODE_GAUGE_GENS_CODE_TYPE

gauge_generators may be present only when code_type is "subsystem_stabilizer".

gauge_generators present but code_type is not "subsystem_stabilizer"

Error

register_template section

ID

Requirement

Violation

Severity

FMT_REG_PER_CODE_BLOCK_REQUIRED

register_template must declare a per_code_block section.

per_code_block section absent

Error

FMT_REG_DATA_QREG_REQUIRED

per_code_block must declare a data_qreg.

per_code_block.data_qreg absent

Error

FMT_REG_DATA_QREG_SIZE

per_code_block.data_qreg.size must equal code.n.

per_code_block.data_qreg.size ≠ code.n

Error

FMT_REG_NAME_UNIQUE

Register names across data_qreg, ancilla_qregs, and cregs must be unique at both levels.

Duplicate name across data_qreg, ancilla_qregs, and cregs (both levels)

Error

FMT_REG_NAME_IDENTIFIER_PATTERN

A user-named register_template ancilla_qregs or cregs register name, at either the per_code_block or global tier, must match ^[A-Za-z][A-Za-z0-9_]*$: a leading letter, then letters, digits, or underscores. data_qreg is a fixed field name, not user-chosen, and is exempt.

A register name does not match ^[A-Za-z][A-Za-z0-9_]*$

Error

FMT_REG_DATA_QREG_PURPOSE

data_qreg’s purpose, when present, must be "logical_data".

purpose present and not "logical_data"

Error

FMT_REG_TEMPLATE_PURPOSE_VALID_FOR_KIND

A register_template ancilla_qregs or cregs entry’s purpose, when present, must be valid for the register’s kind: an ancilla_qregs entry may declare "syndrome", "verification", "flag", "cat", "magic_state", or "custom"; a cregs entry may declare "verification", "flag", or "custom". This holds identically at the per_code_block and global tiers; data_qreg’s purpose is covered separately.

An ancilla_qregs or cregs entry declares a purpose not valid for its kind (quantum vs. classical)

Error

FMT_REG_SIZE_POSITIVE

A register_template register’s size must be a positive integer.

size ≤ 0 or non-integer

Error

operations section: general

ID

Requirement

Violation

Severity

FMT_OP_REQUIRED_OPERATIONS

operations must declare state_preparation, syndrome_measurement, logical_gates, and data_measurement.

Any of state_preparation, syndrome_measurement, logical_gates, data_measurement missing

Error

FMT_OP_DEFAULT_VARIANT_REF

An operation container’s default must name a key in its variants.

default value not a key in variants

Error

FMT_OP_FAULT_TOLERANT_REQUIRED

Every operation variant must declare a fault_tolerant field.

Variant lacks fault_tolerant field

Error

FMT_OP_QASM_PARSABILITY

A variant’s QASM fragment must parse.

QASM fragment fails to parse

Error

FMT_OP_QASM_NO_BOUNDARY_BARRIER

A variant’s QASM fragment must not begin or end, ignoring blank lines and comments, with a barrier statement, read through control flow: 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.

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 barrier …;

Error

FMT_OP_QASM_CONDITION_PROFILE

A variant’s QASM fragment must keep its control flow within the conditional profile: if statements, optionally with an else and nested to any depth, whose condition tests one classical bit against a boolean or one whole declared classical register against an integer constant, every bit it reads belonging to exactly one register the fragment declares. The accepted spellings and the simulation boundary inside the profile are set out under Conditional control flow in the non-normative notes.

Variant QASM fragment parses and carries a loop, a box statement, or an if condition outside the profile

Error

FMT_OP_QASM_HELPER_RESET_BEFORE_USE

Each qubit of a quantum register the variant itself declares with scope: "scratch" or "output" that the fragment touches must be first touched, a barrier not counting as a touch, by a reset statement outside any if statement; persistent registers (the data registers and every other inherited "block" or "global" register) are outside the rule.

Variant QASM fragment parses and a touched qubit of a "scratch" or "output" quantum register is first touched, barriers aside, by a statement other than reset, or by a reset inside an if statement

Error

Operation register declarations (qregs/cregs)

ID

Requirement

Violation

Severity

FMT_OP_INHERITED_REGISTER_REF

An inherited register’s ref must name a register in register_template at the declared scope (global/block).

ref does not match a register in register_template at the declared scope (global/block)

Error

FMT_OP_INHERITED_REGISTER_REF_FLAVOR_MATCH

An inherited register’s ref must resolve to a register_template register of the matching kind: a qregs entry’s ref must name a quantum register, and a cregs entry’s ref must name a classical register.

An inherited register’s ref resolves to a register_template register of the other kind (quantum vs. classical) than the map (qregs/cregs) declaring it

Error

FMT_OP_INHERITED_REGISTER_PURPOSE_NOT_OVERRIDDEN

An inherited (global- or block-scoped) register declaration must not carry its own purpose; the purpose is inherited unchanged from the register_template register its ref names.

An inherited register declaration carries a purpose field of its own

Error

FMT_OP_DYNAMIC_REGISTER_SIZE

A "scratch"- or "output"-scoped register must declare a positive size.

scope is "scratch" or "output" and size missing or ≤ 0

Error

FMT_OP_QASM_REGISTER_SIZE_MATCH

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

FMT_OP_QASM_REGISTER_NAME_DECLARED

Every register name the QASM fragment declares must appear in variant.qregs ∪ variant.cregs.

QASM declares a register name not in variant.qregs ∪ variant.cregs

Error

FMT_OP_QASM_REGISTER_NAME_USED

Every register name a variant declares in qregs/cregs must appear in the QASM qreg/creg declarations.

Variant declares a register name not in QASM qreg/creg declarations

Error

FMT_OP_QASM_NO_LOOSE_BITS

Every qubit or clbit the QASM fragment declares must belong to a named register; a loose bit that the register-keyed qregs/cregs map cannot bind is not permitted.

QASM declares a loose bit (qubit or clbit) belonging to no register, which the register-keyed qregs/cregs map cannot bind

Error

FMT_OP_DYNAMIC_REGISTER_NAME_UNIQUE

A "scratch"- or "output"-scoped register name must not collide with another register name (inherited or dynamic) in the same variant.

A scratch or output register name collides with another register name (inherited or dynamic) in the same variant

Error

FMT_OP_SYNDROME_PURPOSE_OUTPUT_SCOPED

A cregs entry with purpose: "syndrome" must be "output"-scoped, not "scratch"-scoped.

A cregs entry declares purpose: "syndrome" with scope: "scratch"

Error

FMT_OP_TRANSVERSAL_READOUT_PURPOSE_OUTPUT_SCOPED

A cregs entry with purpose: "transversal_readout" must be "output"-scoped, not "scratch"-scoped.

A cregs entry declares purpose: "transversal_readout" with scope: "scratch"

Error

FMT_REG_READOUT_PURPOSE_RESERVATION

The purposes "logical_data" and "logical_measurement" are reserved to the register that carries that readout: data_qreg for "logical_data", and the cregs entry a variant’s result_creg names for "logical_measurement" (or "logical_data" under data_measurement). No other register, dynamic ("scratch"/"output") or otherwise, may declare either purpose; and the cregs entry a variant’s result_creg names must itself carry the purpose the operation requires when it declares one at all (an absent purpose is allowed).

A register other than the designated readout register declares "logical_data" or "logical_measurement" as its purpose; or the cregs entry a variant’s result_creg names declares a purpose other than the one the operation requires ("logical_data" under data_measurement, "logical_measurement" under logical_measurement)

Error

FMT_OP_BLOCK_INDEX_REQUIRED_LOGICAL_ADDRESSING

A scope: "block" register in a logical_gates or logical_measurement variant must carry a block_index.

scope: "block" in a logical_gates or logical_measurement variant and block_index missing

Error

FMT_OP_BLOCK_INDEX_ONLY_ON_MULTIBLOCK

A block_index is legal only on a scope: "block" register of a multi-block (logical-addressing) operation. A scope: "global" register must never carry block_index, whatever the operation kind; a scope: "block" register in a non-logical-addressing (single-block) operation must not carry block_index either, since such an operation binds its block from the operand qubits rather than by index.

block_index is present on a scope: "global" register, or on a scope: "block" register of a non-logical-addressing operation

Error

Readout declarations

ID

Requirement

Violation

Severity

FMT_OP_SYNDROME_CREG_NAME

Each syndrome_cregs entry’s name must match an "output"-scoped creg on the variant.

name not in variant’s cregs or creg scope ≠ "output"

Error

FMT_OP_SYNDROME_CREG_SOURCE

Each syndrome_cregs entry’s source must be a field valid for the declared code_type.

source not a valid field for the declared code_type

Error

FMT_OP_SYNDROME_CREG_NAME_UNIQUE

A register must be named in at most one syndrome_cregs entry of a variant.

Two syndrome_cregs entries of a variant name the same register

Error

FMT_OP_SYNDROME_CREG_NO_QUBITS

A syndrome_cregs entry must not carry a qubits key.

A syndrome_cregs entry carries a qubits key

Error

FMT_OP_SYNDROME_REGISTER_SIZE

The size of the register a syndrome_cregs entry names must equal the number of rows/elements in its source, or len(indices) when indices is present.

Register size ≠ number of rows/elements in source (or ≠ len(indices) when indices present)

Error

FMT_OP_SYNDROME_INDICES_RANGE

Every index in a syndrome_cregs entry’s indices must be less than the number of rows/elements in its source.

Any index in indices ≥ number of rows/elements in source

Error

FMT_OP_TRANSVERSAL_READOUT_CREG_NAME

Each transversal_readout_cregs entry’s name must match an "output"-scoped creg on the variant.

name not in variant’s cregs or creg scope ≠ "output"

Error

FMT_OP_TRANSVERSAL_READOUT_CREG_SOURCE

Each transversal_readout_cregs entry’s source must be a field valid for the declared code_type.

source not a valid field for the declared code_type

Error

FMT_OP_TRANSVERSAL_READOUT_REGISTER_SIZE

The size of the register a transversal_readout_cregs entry names must equal len(qubits) when qubits is present, or code.n when qubits is absent.

Register size ≠ len(qubits) (or ≠ code.n when qubits absent)

Error

FMT_OP_TRANSVERSAL_READOUT_QUBITS_DISTINCT

The entries of a transversal_readout_cregs entry’s qubits must be distinct.

An entry of qubits repeats an earlier entry

Error

FMT_OP_TRANSVERSAL_READOUT_QUBITS_RANGE

Every entry of a transversal_readout_cregs entry’s qubits must lie in 0 .. code.n - 1.

Any entry of qubits ≥ code.n

Error

FMT_OP_TRANSVERSAL_READOUT_INDICES_INCREASING

A transversal_readout_cregs entry’s indices must be strictly increasing.

An entry of indices is not greater than the entry before it

Error

FMT_OP_TRANSVERSAL_READOUT_INDICES_RANGE

Every index in a transversal_readout_cregs entry’s indices must be less than the number of rows/elements in its source.

Any index in indices ≥ number of rows/elements in source

Error

FMT_OP_TRANSVERSAL_READOUT_COVERAGE

The support of every check a transversal_readout_cregs entry declares, the qubits where the check acts, must lie within the qubits its register reads: the entries of qubits, or every block qubit when qubits is absent.

A declared row of source acts on a qubit absent from qubits

Error

FMT_OP_TRANSVERSAL_READOUT_CHECK_UNIQUE

transversal_readout_cregs entries naming one register must not declare the same check of the same source twice; an entry without indices declares every row of its source.

Two entries naming one register select a common row of the same source

Error

FMT_OP_TRANSVERSAL_READOUT_SHARED_REGISTER_AGREE

transversal_readout_cregs entries naming one register must agree on block_index and qubits; an absent qubits agrees with one listing 0 .. size - 1, size the register’s size.

Two entries naming one register carry different block_index values or read its bits from different qubits

Error

FMT_OP_READOUT_ONE_FIELD_PER_REGISTER

A register must appear in at most one of a variant’s syndrome_cregs and transversal_readout_cregs.

A register is named in both the syndrome_cregs and the transversal_readout_cregs of a variant

Error

FMT_OP_READOUT_PURPOSE_NOT_CROSSED

A register named in transversal_readout_cregs must not carry purpose: "syndrome", and a register named in syndrome_cregs must not carry purpose: "transversal_readout".

A transversal_readout_cregs entry names a cregs entry declaring purpose: "syndrome", or a syndrome_cregs entry names one declaring purpose: "transversal_readout"

Error

FMT_OP_READOUT_RESULT_CREG_PLACEMENT

A data_measurement variant’s result_creg may be named in transversal_readout_cregs only; a logical_measurement variant’s result_creg must be named in neither readout field.

A syndrome_cregs entry of a data_measurement variant names its result_creg, or an entry of either field of a logical_measurement variant names its result_creg

Error

FMT_OP_READOUT_BLOCK_INDEX_REQUIRED_LOGICAL_ADDRESSING

Every syndrome_cregs or transversal_readout_cregs entry in a logical_gates or logical_measurement variant must carry a block_index.

An entry of either field in a logical_gates or logical_measurement variant and block_index missing

Error

FMT_OP_READOUT_BLOCK_INDEX_ONLY_ON_MULTIBLOCK

A block_index on a syndrome_cregs or transversal_readout_cregs entry is legal only in a multi-block (logical-addressing) operation; an entry of either field in a non-logical-addressing (single-block) operation must not carry block_index, since such an operation binds its block from the operand qubits rather than by index.

block_index is present on an entry of either field in a non-logical-addressing operation

Error

FMT_OP_READOUT_BLOCK_INDEX_OPERAND_CONSISTENCY

A block_index on a syndrome_cregs or transversal_readout_cregs entry must correspond to a block value in the operand group’s operands.

block_index on an entry of either field does not correspond to a block value in operands

Error

FMT_OP_READOUT_FRAME_REQUIRED_ON_RESET

Every syndrome_cregs or transversal_readout_cregs entry in a reset variant must carry a frame.

An entry of either field in a reset variant and frame missing

Error

FMT_OP_READOUT_BITS_MEASURED

Every bit of a register named in syndrome_cregs or transversal_readout_cregs must be written by a measurement in the variant’s QASM fragment, inside if statements included.

Variant QASM fragment parses and a bit of a register named in either field is the target of no measure statement

Error

state_preparation / reset

ID

Requirement

Violation

Severity

FMT_OP_STATE_KEY_CHARSET

Every outer key must consist only of characters from {"0","1","+","-","i","j"}.

Any outer key contains a character outside {"0","1","+","-","i","j"}

Error

FMT_OP_STATE_KEY_LENGTH

Every outer key’s length must equal code.k.

Outer-key length ≠ code.k

Error

Data-register binding (state_preparation / reset / data_measurement)

ID

Requirement

Violation

Severity

FMT_OP_DATA_QREG_BOUND

A variant must declare a qregs entry with scope: "block" and ref: "data_qreg".

A variant declares no qregs entry with scope: "block" and ref: "data_qreg". Not reported when the variant carries an inherited quantum register whose ref does not resolve; that case is reported under FMT_OP_INHERITED_REGISTER_REF

Error

syndrome_measurement

ID

Requirement

Violation

Severity

FMT_OP_SYNDROME_CREGS_REQUIRED

Every syndrome_measurement variant must declare syndrome_cregs, transversal_readout_cregs, or both.

Variant lacks both the syndrome_cregs and the transversal_readout_cregs field

Error

logical_gates / logical_measurement

ID

Requirement

Violation

Severity

FMT_OP_LOGICAL_ADDRESSING_LIST

The value for each gate name must be a list.

Value for a gate name is not a list

Error

FMT_OP_OPERAND_GROUP_OPERANDS_REQUIRED

Every operand group must declare operands.

Operand group lacks operands

Error

FMT_OP_LOGICAL_QUBIT_RANGE

Every non-null logical_qubit value must be less than code.k.

Any logical_qubit value (non-null) ≥ code.k

Error

FMT_OP_BLOCK_INDEX_OPERAND_CONSISTENCY

A block_index in qregs must correspond to a block value in operands.

block_index in qregs does not correspond to a block value in operands

Error

FMT_OP_OBSERVABLE_KEY_FORMAT

A logical_measurement observable key must be a valid uppercase Pauli string ({I,X,Y,Z}*).

Key is not a valid uppercase Pauli string ({I,X,Y,Z}*)

Error

FMT_OP_OBSERVABLE_KEY_LENGTH

A logical_measurement observable key’s length must equal the number of operands.

Key length ≠ number of operands

Error

FMT_OP_LOGICAL_MEASUREMENT_RESULT_CREG_REF

A logical_measurement variant’s result_creg must name an "output"-scoped creg on the variant.

result_creg not in variant’s cregs or scope ≠ "output"

Error

FMT_OP_OPERAND_GROUP_SIGNATURE_UNIQUE

No two operand groups under one gate name / observable may share the same (block, logical_qubit) tuple list up to renaming of the block labels.

Two operand groups under the same gate name / observable share the same (block, logical_qubit) tuple list up to renaming of the block labels, making lookup ambiguous

Error

FMT_OP_OPERAND_GROUP_WILDCARD_TIE

No two operand groups under one gate name / observable may take the same number of operands over the same block partition, pin equally many positions, agree wherever both pin, and each carry a null.

Two operand groups under the same gate name / observable take the same number of operands over the same block partition, pin equally many positions, agree wherever both pin, and each carry a null, so lookup cannot rank the two for a call both accept

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

FMT_OP_OPERAND_GROUP_WILDCARD_NOT_SHADOWED

When code.k is 1, an operand group that leaves at least one operand null must not be outranked by a sibling group over the same block partition that pins more positions and agrees with it wherever both pin. At code.k of 1 each block partition admits exactly one call, so such a sibling always wins that call and the wildcard group is selected by no call.

At code.k of 1, an operand group leaving at least one operand null is outranked by a sibling group over the same block partition that pins more positions and agrees with it wherever both pin, so no call selects the wildcard group

Warning

FMT_OP_OPERAND_WILDCARD_SOUND

Within one block, an operand group’s operands must be either all concrete or a full-block null coverage numbering exactly code.k.

A block’s operands are neither all-concrete nor a full-block null coverage: they mix null with concrete values, or are all null but do not number exactly code.k

Error

FMT_OP_OPERAND_GROUP_NO_DUPLICATE_PIN

Within one block of an operand group, a logical_qubit must not be pinned (named as a concrete, non-null value) more than once. A call’s operands on a single block always name distinct logical qubits, so a group pinning the same logical_qubit twice on one block is selected by no call.

An operand group pins the same logical_qubit twice on a single block

Error

FMT_OP_IDENTITY_GATE_ADAPTER_IMPLICIT

The identity gate is supplied implicitly by the consumer and is never looked up from logical_gates; a logical_gates entry keyed "id" is not consulted and its implementation is discarded.

logical_gates declares an entry keyed "id"; its implementation is discarded and never executed

Warning

data_measurement

ID

Requirement

Violation

Severity

FMT_OP_DATA_MEASUREMENT_BASIS_KEY

Every outer key must be one of "Z", "X", or "Y".

Outer key is not in {"Z", "X", "Y"}

Error

FMT_OP_DATA_MEASUREMENT_RESULT_CREG_REF

A data_measurement variant’s result_creg must name an "output"-scoped creg on the variant.

result_creg not in variant’s cregs or scope ≠ "output"

Error

FMT_OP_DATA_MEASUREMENT_RESULT_CREG_SIZE

A data_measurement variant’s result_creg register must have size code.n.

Register size ≠ code.n

Error

properties section

ID

Requirement

Violation

Severity

FMT_PROP_REFERENCE_KEY_UNIQUE

Every entry in properties.references must have a key unique among all entries in the list.

Two or more entries in properties.references declare the same key

Error

FMT_PROP_REFERENCE_KEY_RESOLVES

Every string in a variant-level references list (an operation variant or an error_correction_cycle variant) must match the key of an entry in properties.references.

A variant’s references entry matches no properties.references key

Error

FMT_PROP_REFERENCE_IDENTIFIER_PRESENT

Every entry in properties.references must carry at least one of doi, arxiv, or url.

A properties.references entry carries none of doi, arxiv, or url

Error

qubit_layout section

cell_complex

ID

Requirement

Violation

Severity

FMT_LAYOUT_CC_EDGE_VERTEX_RANGE

Every vertex index in an edge must be less than num_vertices.

Any vertex index in an edge ≥ num_vertices

Error

FMT_LAYOUT_CC_FACE_VERTEX_RANGE

Every vertex index in a face must be less than num_vertices.

Any vertex index in a face ≥ num_vertices

Error

FMT_LAYOUT_CC_FACE_COLOR_TYPE

A face’s color, when present, must be a non-negative integer.

color present and not a non-negative integer

Error

embedding

ID

Requirement

Violation

Severity

FMT_LAYOUT_EMBEDDING_REQUIRES_CELL_COMPLEX

embedding may be present only when cell_complex is present.

embedding present but cell_complex absent

Error

FMT_LAYOUT_EMBEDDING_VERTEX_COUNT

vertex_coordinates must have num_vertices entries.

vertex_coordinates length ≠ num_vertices

Error

FMT_LAYOUT_EMBEDDING_COORD_TUPLE_LENGTH

Every coordinate tuple must have length equal to dimension.

Any tuple length ≠ dimension

Error

qubit_placement

ID

Requirement

Violation

Severity

FMT_LAYOUT_PLACEMENT_EXPECTED_WITH_CELL_COMPLEX

When cell_complex is present, qubit_placement should be present and non-empty.

cell_complex present but qubit_placement absent or empty

Warning

FMT_LAYOUT_PLACEMENT_REGISTER_NAME

Every qubit_placement key must name a register in register_template (global or per_code_block).

Key not in register_template (global or per_code_block)

Error

FMT_LAYOUT_PLACEMENT_CELL_REQUIRES_CELL_COMPLEX

An entry declaring cell requires cell_complex to be present; coordinate placement is exempt.

Entry declares cell but cell_complex is absent (coordinate placement is exempt)

Error

FMT_LAYOUT_PLACEMENT_MAPPING_LENGTH

A mapping’s length must equal the register size.

mapping length ≠ register size

Error

FMT_LAYOUT_PLACEMENT_COORDINATE_COUNT

Explicit coordinates count must equal the register size.

Explicit coordinates count ≠ register size

Error

FMT_LAYOUT_PLACEMENT_VERTEX_RANGE

When cell = "vertex", every index in mapping must be less than num_vertices.

cell = "vertex" and any index in mapping ≥ num_vertices

Error

FMT_LAYOUT_PLACEMENT_EDGE_RANGE

When cell = "edge", every index in mapping must be less than len(edges).

cell = "edge" and any index in mapping ≥ len(edges)

Error

FMT_LAYOUT_PLACEMENT_FACE_RANGE

When cell = "face", every index in mapping must be less than len(faces).

cell = "face" and any index in mapping ≥ len(faces)

Error

FMT_LAYOUT_PLACEMENT_FACE_REQUIRES_FACES

When cell = "face", faces must be present and non-empty.

cell = "face" but faces is absent or empty

Error

FMT_LAYOUT_PLACEMENT_EDGE_REQUIRES_EDGES

When cell = "edge", edges must be non-empty.

cell = "edge" but edges is empty

Error

FMT_LAYOUT_PLACEMENT_COORDINATE_DIMENSION

Explicit coordinates tuple length must be consistent with embedding.dimension when present, and consistent across entries.

Explicit coordinates tuple length inconsistent with embedding.dimension (if present), or inconsistent across entries

Error

error_correction_cycle section

ID

Requirement

Violation

Severity

FMT_CYCLE_DEFAULT_VARIANT_REF

default must name a key in variants.

default not a key in variants

Error

FMT_CYCLE_STEP_MEASUREMENT_REF

Each step’s measurement must name a key in operations.syndrome_measurement.variants.

step.measurement not a key in operations.syndrome_measurement.variants

Error

FMT_CYCLE_REF_RESOLVES

A ref path must resolve to a field in the document.

ref path does not resolve to a field in the document

Error

FMT_CYCLE_REF_INTEGER_TYPE

A ref used where an integer is required must resolve to an integer.

ref resolves to a non-integer value (e.g. object, array, string)

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

FMT_DECODER_TAG_ANCHOR_MAP_NONEMPTY

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

FMT_DECODER_ANCHOR_KEY_VALID

Every anchor key under a tag must be a valid syndrome source for the code_type or the reserved syndrome_measurement key.

An anchor key under a tag is neither a valid syndrome source for the code_type nor the reserved syndrome_measurement

Error

FMT_DECODER_SOURCE_ANCHOR_LENGTH

A source anchor’s resolved value list must have one entry per syndrome operator of that code source.

A source anchor’s resolved value list length ≠ the number of syndrome operators in that code source

Error

FMT_DECODER_SYNDROME_OVERRIDE_VARIANT_REF

A syndrome_measurement override must name a variant present in operations.syndrome_measurement.variants.

A syndrome_measurement override names a variant absent from operations.syndrome_measurement.variants

Error

FMT_DECODER_SYNDROME_OVERRIDE_CREG_REF

A syndrome_measurement override must name a classical register declared in the named variant.

A syndrome_measurement override names a classical register not declared in that variant

Error

FMT_DECODER_SYNDROME_OVERRIDE_CREG_DECLARED

A syndrome_measurement override must name a register listed in the named variant’s syndrome_cregs.

A syndrome_measurement override names a classical register that the named variant declares but does not list in its syndrome_cregs

Error

FMT_DECODER_SYNDROME_OVERRIDE_LENGTH

A syndrome_measurement override’s resolved value list must have length equal to the named register’s size.

A syndrome_measurement override’s resolved value list length ≠ the named register’s size

Error

FMT_DECODER_REF_RESOLVES

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

FMT_DECODER_SLUG_RECOGNIZED

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

FMT_DECODER_REQUIRED_TAG_PRESENT

A recognized decoder must carry every tag it requires.

A recognized decoder is missing a tag it requires

Error

FMT_DECODER_TAG_VALUE_TYPE

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

FMT_ARCHIVE_NO_REF_IN_INLINE

In an inline-container document, no field value may be a $ref object.

Any field value is a $ref object in an inline-container document

Error

FMT_ARCHIVE_MANIFEST_FILES_PRESENT

Every file path referenced in manifest.json must resolve to a file present in the archive.

File path reference in manifest.json resolves to missing file

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 purpose values); old consumers that don’t recognise the value may safely ignore it

  • Widen the accepted values for existing fields (e.g. extend basis to 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_type is 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 operations container 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: false on 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: true on 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: false for the new field set. The old schema’s false correctly 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_version field 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 of H_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 of H_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 is X(g_j)

  • B (size [s, n]): row j is Z(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

k

One bit per logical qubit

Error syndrome bits

r_Z = s − rank(A)

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

r_Z = s − rank(A)

X errors

logical Z

X-basis

r_X = s − rank(B)

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:

  1. Form the stabilizer tableau T = [A | B] with rows (X(g_j) | Z(g_j)).

  2. Row-reduce T over 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 generator g_j with g_j · g_k, and the B row must be updated to B_j ⊕ B_k.

  3. After reduction, let T' = [A' | B']. Rows where A'_j = 0 correspond to Z-extractable generators: purely Z-type stabilizers g'_j = ±Z^{B'_j}. There are exactly r_Z = s − rank(A) such rows.

  4. 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), and rank(B) = rank(H_Z). When these matrices have full row rank (the typical case), rank(A) equals the number of X-type generators and rank(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 of H_Z. The formulas reduce to s = H_Z · m.

  • Logical Z operators for CSS codes are conventionally purely Z-type; Z(Z̄_i) · m gives 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 operations section 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_measurement circuits from operations, 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.