Transpiler

Overview

Transpilation is the process of rewriting a given input circuit to conform with desired criteria such as topological and operational constraints of the hardware used to execute the final circuit. We are not going to explain this in more detail here, and instead refer to Qiskit’s documentation of the qiskit.transpiler module.

The focus here lies on explaining how we achieve the transpilation of a BosonicCircuit to a QuantumCircuit.

Stages

Conceptually, we split the transpilation process into several stages:

Stage

Description

Input

convert to DAG data structure

Optimization

bosonic-level optimization

Layout

boson-to-qubit layouting

Synthesis

boson-to-qubit synthesis

Qubit

continued transpilation on the qubit-level

Output

convert from DAG data structure

Input

The various transpiler passes are implemented to work with BosonicDAGCircuit as the underlying data structure to store the circuit operations. Such directed acyclic graphs (DAGs) provide an efficient data model for the traversal and manipulation of circuits.

However, an end-user is more likely to work with a BosonicCircuit as it provides a more intuitive interface and data model. As such, this input stage simply runs the BosonicCircuitToDAG transpiler pass.

Optimization

This stage of the transpilation pipeline can implement circuit optimizations while preserving the type of circuit to be an instance of BosonicDAGCircuit. As such, no qubit information is required (or necessarily available) at this point in the transpilation pipeline.

Layout

One global configuration setting for the transpilation process is the boson-to-qubit “layout”. This must be provided by the user and it must match the provided boson-to-qubit mapping (in the sense that, if a chosen mapping encodes a fixed number of bosons with a different number of qubits, the configured layout must account for that).

In the general case, bosonic modes are not always encoded with an occupation-basis into the qubit register. Consequently, we cannot associate a single bosonic mode with a single qubit. Therefore, the user-provided boson-to-qubit layout (B2QLayout) associates BosonicRegister instances with QuantumRegister ones.

B2QLayout

A mapping of bosonic mode registers to quantum registers.

The way to configure this global setting, is by placing a B2QLayout instance in the b2q_layout field of the property_set. For more details refer to Layouting Passes.

Synthesis

At its core, the transpilation is handled by the B2QSynthesis transpiler pass. It is conceptually similar to Qiskit’s HighLevelSynthesis pass, which uses various plugins for transpiling high-level circuit instructions. For more details, refer to the documentation of B2QSynthesis directly.

How a given BosonicGate can be synthesized in terms of qubit-based operations will depend on the particular gate type as well as the user-chosen boson-to-qubit mapping. For more details, refer to Transpiler Pass Synthesis (B2Q).

Qubit

At this point in the transpilation process, we have reached a DAGCircuit instance and can continue to use Qiskit’s transpilation pipeline as one would usually.

Hint

Additional transpiler passes for optimizations on the qubit-level that take into account the knowledge of a circuit originating from a BosonicCircuit may be added in the future!

Output

This stage implements effectively the reverse of Input, by calling the QuantumDAGToCircuit transpiler pass.

Pass Managers

All of the stages above are the default stages by how the presets orchestrate the various MultiStagePassManager.

The individual stages can be either a single pass (when they change from one internal representation (IR) to another, such as the Input, Synthesis, and Output stages above) or a stage can be a BasePassManager whose internal passes can be modified.

For the stages operating on bosonic circuits (Optimization and Layout), the type of passmanager to use is BosonicPassManager.

BosonicPassManager([tasks, max_iteration])

A transpiler pass manager converting one BosonicCircuit to another.

Conversion Passes

Some very basic conversion passes are provided directly by this module:

Presets

For user convenience, the qiskit_bosons.transpiler.presets module provides a number of functions for quickly building pre-defined transpilation pipelines.