OccupationInitializeModesSynthesis¶
- class OccupationInitializeModesSynthesis(spec)¶
Bases:
objectA
B2QSynthesisPluginfor transpilingInitializeModes.Prepares each mode’s Fock state by setting the qubits of the bit pattern that the chosen occupation encoding assigns to that mode’s occupation level. This is a plain layer of
XGateon the qubits the pattern sets – no entangling gate is needed for a product Fock state.Warning
This plugin makes the following assumptions, none of which it verifies:
The qubits start in the all-zero state, and the gate is the first one acting on its modes. The pattern is applied with
Xgates, so it toggles the qubits rather than setting them. A secondInitializeModesgate on the same modes undoes the first one or, depending on the encoding, leaves the register in a state that no level of the truncation represents.All-zero is the vacuum only under the compact encodings. Under both unary encodings the pattern of level 0 sets a qubit, so a mode that no
InitializeModesgate acts on starts outside the one-hot subspace. Place anInitializeModesgate on every mode of such a circuit, withInitializeModes.vacuum()for the empty ones.The
LevelSpecis the one used by the layout and the mapper. The layout derives the qubit register from its spec and the mapper maps the operators with its own; this plugin places the pattern at the offsets of the spec it is given. If they differ, the qubits are set without an error, but not the qubits that the rest of the pipeline reads as that occupation. The preset builds all three from one spec.
Note
This plugin needs to know the encoding and the truncation, because “which qubits represent occupation 2” is exactly what an encoding defines. They are given by a
LevelSpecpassed to the constructor rather than being read off the gate: the gate is encoding-agnostic by design, and deferring this choice to transpile time is what lets one bosonic circuit be lowered under several encodings. Each mode is checked against, and placed at the qubit offset of, its own entry in the spec.Initializing this plugin can be done with the arguments listed below.
- Parameters:
spec (LevelSpec) – the
LevelSpecwith which the rest of the pipeline truncates and encodes its modes. It must be the same spec as the layout and the mapper use.
Attributes
Methods
- run(in_node, out_dag, *, b2q_layout)¶
Runs this transpilation plugin.
- Parameters:
in_node (DAGOpNode) – the input boson-based circuit instruction. When this plugin gets called, the
in_node.opattribute must be of typeInitializeModes.out_dag (DAGCircuit) – the output qubit-based circuit.
b2q_layout (dict[QuantumRegister, QuantumRegister]) – the global transpilation
B2QLayoutsetting.
- Return type:
None
See also
The documentation of
B2QSynthesisPluginfor more detailed explanations of the arguments.- Raises:
NotImplementedError – when
in_nodeacts on bosonic modes that are spread across multipleBosonicRegisterinstances.ValueError – if the gate declares an occupation that the truncation of its mode cannot represent, or if the register has a different number of modes than
speccovers.
- Parameters:
in_node (DAGOpNode)
out_dag (DAGCircuit)
b2q_layout (dict[QuantumRegister, QuantumRegister])
- Return type:
None