OccupationB2QLayout¶
- class OccupationB2QLayout(spec)¶
Bases:
GenericPass[DAGCircuit,DAGCircuit]Maps bosonic modes to the qubits a
LevelSpecassigns them.Each bosonic mode is truncated to the levels its cutoff in
speckeeps and spansLevelEncoding.num_qubits()of that many levels consecutive qubits, so the register of \(M\) modes is mapped to a qubit register ofLevelSpec.total_widthqubits and mode \(m\) starts at qubitLevelSpec.offsets[m].A boson-to-qubit encoding generally needs more than one qubit per mode (\(d\) of them for the unary encodings), so the qubit register is wider than the mode register. Unlike
CustomB2QLayoutthis derives the registers from the circuit being transpiled rather than requiring them up front, which is what lets one pass manager serve circuits of different widths, as long asspecleaves the number of modes open.Note
The truncation and the encoding are given by the
specof this pass, not by the circuit. That is the point: the bosonic circuit upstream of the transpiler is independent of both, so the same circuit can be lowered at several truncation levels – or under several encodings – by swapping this pass alone.Warning
A spec whose modes have different cutoffs fixes the qubit offset of each mode by its position in the register, so reordering the modes afterwards would silently attach the wrong cutoff to a mode. This pass therefore refuses a circuit to which
RelabelModeshas already been applied (it leaves a"permutation"entry in the circuit’s metadata) and raises aValueError. A spec with one shared cutoff is unaffected. Note thatCustomB2QLayoutdoes not perform this check: the user is responsible for the consistency of a layout they provide themselves.Initializing this transpiler pass can be done with the arguments listed below.
- Parameters:
spec (LevelSpec) – the
LevelSpecwith the cutoff of every mode and the encoding that lays the occupation levels out on qubits. A spec with one cutoff per mode only supports circuits with exactly that many modes.
Attributes
Methods
- run(dag)¶
Runs this analysis pass.
- Parameters:
dag (DAGCircuit) – the DAG circuit representation of a
BosonicCircuit.- Returns:
The unchanged input. But the
property_setof this transpilation pipeline will be updated.- Raises:
ValueError – if a register has a different number of modes than
speccovers, or ifspecgives the modes different cutoffs andRelabelModeshas been applied to the circuit.- Return type:
Inherited Methods
- execute(passmanager_ir, state, callback=None)¶
Execute optimization task for input Qiskit IR.
- Parameters:
passmanager_ir (IR) – Qiskit IR to optimize.
state (PassManagerState) – State associated with workflow execution by the pass manager itself.
callback (Callable[[Task, IR_OUT, PropertySet, float, int], None] | None) – A callback function which is called per execution of optimization task.
- Returns:
Optimized Qiskit IR and state of the workflow.
- Return type:
tuple[IR_OUT, PassManagerState]
- update_status(state, run_state)¶
Update workflow status.
- Parameters:
state (PassManagerState) – Pass manager state to update.
run_state (RunState) – Completion status of current task.
- Returns:
Updated pass manager state.
- Return type: