qat.experimental.dialect.gate.transforms.naive_placement module
A pass that assigns each algorithmic qubit to a physical one by rewriting its type.
The pass uses a naive placement approach to assign qubits.
- class AllocDetail(alloc_op, is_algorithmic, place, drop, qubit_values, dealloc_op)
Bases:
objectWhat the pass learned about one qubit allocation before any rewriting.
- Variables:
alloc_op – The
AllocateQubitOpbeing analysed.is_algorithmic – Whether the allocation is for an algorithmic qubit
place – Whether the qubit is to be kept and placed on a physical qubit.
drop – Whether the qubit is to be dropped (unused)
qubit_values – Every SSA value in the qubit’s chain, after the allocation result to the last gate result, in order.
dealloc_op – The
DeallocateQubitOpending the chain, orNone.
-
alloc_op:
AllocateQubitOp
-
dealloc_op:
DeallocateQubitOp|None
-
drop:
bool
-
is_algorithmic:
bool
-
place:
bool
-
qubit_values:
list[SSAValue]
- class NaiveQubitPlacementPass(qubit_view, policy, explicit_qubit_ids=None)
Bases:
OrderedPass,ModulePassA pass that assigns each algorithmic qubit to a physical one by rewriting its type.
The pass uses a naive placement policy to assign qubits, which can be one of:
best_coupling: assign qubits to the highest fidelity or best coupled physical qubits (1 or 2 qubits only). Inputs that mix physical and algorithmic qubits are rejected.
explicit: assign qubits to the physical qubits specified in the explicit_qubit_ids
as_written: assign qubits to the physical qubits in the order they are allocated
Unused allocated qubits are dropped (including those that are deallocated before any use). The pass will raise an error if a two-qubit gate is applied to uncoupled qubits. Couplings are directed, so the qubit view must list a link in both directions for a gate to be accepted either way round.
Functions that take or return qubits are rejected and should be inlined first. The input module must be valid, as for any xDSL pass.
The pass validates up front so the module is left unchanged if validation fails.
- apply(ctx, op)
Replace each algorithmic qubit allocation with a physical one under the chosen policy and remove any unused allocations. Inputs with physical allocations are processed without change apart from validating the qubit indices.
-
explicit_qubit_ids:
tuple[str,...] |None= None
- name: ClassVar[str] = 'gate.naive-qubit-placement'
-
policy:
PlacementPolicy