Types¶
quanta.core.types ¶
quanta.core.types -- Core quantum types.
This module defines all fundamental data structures of the SDK
- QubitRef: Indexed reference to a qubit
- Instruction: Single circuit instruction (gate + qubits)
- QubitRegister: N-qubit register
These types are the foundation of the core layer with zero external dependencies.
Example
reg = QubitRegister(3) reg[0] QubitRef(index=0) len(reg) 3
CircuitError ¶
Bases: QuantaError
Circuit creation or validation error.
GateError ¶
Bases: QuantaError
Gate definition or application error.
Instruction
dataclass
¶
A single circuit instruction: gate + target qubits + parameters.
Created during circuit construction (lazy evaluation) and recorded into the CircuitBuilder.
Attributes:
| Name | Type | Description |
|---|---|---|
gate_name |
str
|
Gate name (e.g., "H", "CX", "RY"). |
qubits |
tuple[int, ...]
|
Target qubit indices. |
params |
tuple[float, ...]
|
Angle values for parametric gates (in radians). |
Source code in quanta/core/types.py
MeasureSpec
dataclass
¶
Measurement specification: which qubits to measure.
Attributes:
| Name | Type | Description |
|---|---|---|
qubits |
tuple[int, ...]
|
Qubit indices to measure. If empty, all are measured. |
Source code in quanta/core/types.py
QuantaError ¶
QubitIndexError ¶
Bases: CircuitError
Invalid qubit index error.
QubitRef
dataclass
¶
Immutable reference to a qubit.
Created as q[0], q[1] within a circuit.
Being frozen, it is hashable and can be used in sets/dicts.
Attributes:
| Name | Type | Description |
|---|---|---|
index |
int
|
Zero-based index of the qubit within its register. |
Source code in quanta/core/types.py
QubitRegister ¶
An N-qubit register with indexed access.
Automatically created by @circuit(qubits=N).
User accesses via q[0], q[1] or for qubit in q:.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
size
|
int
|
Number of qubits. Must be a positive integer. |
required |
Raises:
| Type | Description |
|---|---|
CircuitError
|
If size < 1. |
Example
reg = QubitRegister(3) reg[0], reg[1], reg[2] (q[0], q[1], q[2])
Source code in quanta/core/types.py
__getitem__ ¶
Access a single qubit. Supports negative indexing.
Source code in quanta/core/types.py
SimulatorError ¶
Bases: QuantaError
Simulator execution error.