QReg
A quantum register: a named, contiguous block of qubits.str
required
Register name. Must be unique within a program.
int
required
Number of qubits in this register.
str
default:"\"sys\""
Register kind.
"sys" for user-declared registers, "anc" for ancilla registers allocated by ancilla(...).Methods and indexing
Wire
Returns the
Wire at position idx. Raises IndexError if out of bounds.list[Wire]
Returns a list of all wires in the register, in order.
int
Returns the number of qubits (
size).Iterator[Wire]
Iterates over all wires in the register.
Wire
A reference to a single qubit within a register. Wires are frozen dataclass instances and are used everywhere gates accept qubit arguments.str
The name of the register this wire belongs to.
int
Zero-based index within the register.
str
Kind of the parent register:
"sys" or "anc".Wire objects by indexing a QReg rather than constructing them directly.
ExactProgram
The result of calling.build_exact() on a @coherent or @primitive function. Represents a certified exact program.
str
The function name from the decorator.
tuple[QReg, ...]
All registers in the program, including any ancilla registers allocated during the build. System registers appear first.
tuple[ExactOp, ...]
The compiled op sequence. Contains
ExactGateOp, ExactAncillaBlock, or ExactParOp instances.Certification
Certification.SAFE for @coherent programs; Certification.PRIMITIVE for @primitive programs.IRProgram
The result of calling.build() on a @parametric or @adaptive function, or of calling lower_exact_program() on an ExactProgram.
str
The function name from the decorator.
Effect
Effect.COHERENT for @parametric; Effect.ADAPTIVE for @adaptive.list[QReg]
Declared registers in the order they were passed to
.build().list[Op]
The compiled op sequence. Contains
GateOp, MeasureOp, MeasureAllOp, IfOp, AncillaBlockOp, or ParOp instances.bool
True if the program passed the safety checker (coherent effect + well-formed ancilla blocks with exact-safe gates only). Always False for adaptive programs.Certification
Enum marking the safety level of anExactProgram.
Effect
Enum describing the computational effect of anIRProgram.
DSLValidationError
Raised whenever a b01t rule is violated. Inherits fromRuntimeError.
Common causes:
- Using a forbidden gate in a context (e.g.,
rxin@coherent) - Calling a gate outside a build context
- Ancilla discipline violations (missing
uncompute, nested blocks) - Duplicate register names
- Measurement in a
@coherentfunction if_thenin a non-adaptive function- Calling
.build_exact()or.build()with wrong argument types
is_safe_program
Effect
required
The effect of the program. Returns
False immediately if effect is Effect.ADAPTIVE.Sequence[Op]
required
The list of ops to check.
bool — True if all ops satisfy the safety conditions.
dump_ir
IRProgram as a human-readable text string. Useful for debugging and inspecting compiled programs.
IRProgram
required
The IR program to print.