QReg
A quantum register: a named, contiguous block of qubits.Register name. Must be unique within a program.
Number of qubits in this register.
Register kind.
"sys" for user-declared registers, "anc" for ancilla registers allocated by ancilla(...).Methods and indexing
Returns the
Wire at position idx. Raises IndexError if out of bounds.Returns a list of all wires in the register, in order.
Returns the number of qubits (
size).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.The name of the register this wire belongs to.
Zero-based index within the register.
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.
The function name from the decorator.
All registers in the program, including any ancilla registers allocated during the build. System registers appear first.
The compiled op sequence. Contains
ExactGateOp, ExactAncillaBlock, or ExactParOp instances.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.
The function name from the decorator.
Effect.COHERENT for @parametric; Effect.ADAPTIVE for @adaptive.Declared registers in the order they were passed to
.build().The compiled op sequence. Contains
GateOp, MeasureOp, MeasureAllOp, IfOp, AncillaBlockOp, or ParOp instances.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.
| Value | Meaning |
|---|---|
Certification.SAFE | Produced by @coherent. Ancilla cleanliness is certified by the compiler. |
Certification.PRIMITIVE | Produced by @primitive. Coherent and unitary, but ancilla management is the caller’s responsibility. |
Effect
Enum describing the computational effect of anIRProgram.
| Value | Meaning |
|---|---|
Effect.COHERENT | Unitary program; no measurement or classical branching. |
Effect.ADAPTIVE | Allows mid-circuit measurement and classical feed-forward via if_then. |
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
The effect of the program. Returns
False immediately if effect is Effect.ADAPTIVE.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.
The IR program to print.