pub struct LogicalQubitAllocator { /* private fields */ }Expand description
Allocates logical qubit patches on a physical qubit grid.
A distance-d surface code patch requires d^2 data qubits and (d-1)^2 + (d-1)^2 = 2(d-1)^2 ancilla qubits, totaling d^2 + 2(d-1)^2 = 2d^2 - 2d + 1 physical qubits per logical qubit.
Patches are laid out on a 2D grid with d-qubit spacing between patch origins to avoid overlap.
Implementations§
Source§impl LogicalQubitAllocator
impl LogicalQubitAllocator
Sourcepub fn new(total_physical: u32, code_distance: u32) -> Self
pub fn new(total_physical: u32, code_distance: u32) -> Self
Create a new allocator with the given total physical qubit count and default code distance.
Sourcepub fn max_logical_qubits(&self) -> u32
pub fn max_logical_qubits(&self) -> u32
Maximum number of logical qubits that can be allocated.
Each logical qubit requires 2d^2 - 2d + 1 physical qubits.
Sourcepub fn allocate(&mut self) -> Option<SurfaceCodePatch>
pub fn allocate(&mut self) -> Option<SurfaceCodePatch>
Allocate a new logical qubit patch.
Returns None if insufficient physical qubits remain.
Sourcepub fn deallocate(&mut self, logical_id: u32)
pub fn deallocate(&mut self, logical_id: u32)
Deallocate a logical qubit by its logical ID.
Sourcepub fn utilization(&self) -> f64
pub fn utilization(&self) -> f64
Return the fraction of physical qubits currently allocated.
Sourcepub fn patches(&self) -> &[SurfaceCodePatch]
pub fn patches(&self) -> &[SurfaceCodePatch]
Return a reference to all currently allocated patches.