Compiler¶
Two common issues that come up when attempting to run an algorithm on specific hardware platforms include:
Gates inside of theoretical circuits are not directly compatible with the hardware’s native gateset.
Gates or circuits are specified as unitary matrices, rather than specific gate decompositions.
If True-Q™ has access to the configuration of the system, it is possible to solve both of these issues. Our compilation tools take a circuit and rewrite it using only the gates and connections specified in a given device configuration file.
Note
The same circuit can be transpiled for implementation on any number of hardware devices. Below we show an example of this.
How it Works¶
True-Q™ has a number of compilation tools which rely upon device-specific
configurations. The compilation tools work by applying an ordered list of built-in
and/or user-specified Pass
s to a circuit in
order, see (Compiler
for more details).
To give a feel for what a compiler definition looks like, here is the list of passes
that defines the default compiler which is used when no custom list of
Pass
s is provided:
import trueq as tq
tq.Compiler.DEFAULT_PASSES
(trueq.compilation.two_qubit.Native2Q,
trueq.compilation.common.Justify,
trueq.compilation.common.Merge,
trueq.compilation.common.RemoveId,
trueq.compilation.common.RemoveEmptyCycle,
trueq.compilation.one_qubit.Native1Q,
functools.partial(<class 'trueq.compilation.common.RemoveId'>, marker=None),
trueq.compilation.common.InvolvingRestrictions,
trueq.compilation.common.RemoveEmptyCycle)
Each item in the list above is one of True-Q™’s built-in
Pass
s. Notice that
RemoveId
is applied twice; this is because the passes
in a compiler are applied sequentially and in the order listed above it is possible that
new identity gates may have appeared between the first application of
RemoveId
and the second.
Each pass takes a circuit, applies an operation, and returns an altered circuit. Details
of how this functions can be found in Compiler
.
Here are the premade Pass
s available for use
with the compiler:
Pass that searches |
|
A pass which ensures that any |
|
Pass that takes two Cycles, and moves gates preferentially to one side. |
|
Pass that marks cycles which contain multi-qubit gates if none of the existing cycles in the circuit have been marked with non-zero values. |
|
Pass that takes two cycles, finds compatabile labels and gates, then merges them to a single gate as much as is possible. |
|
A |
|
An |
|
An |
|
An |
|
A |
|
An |
|
An |
|
An |
|
Checks to see if each gate is present in the provided list of |
|
A |
|
This pass tracks phase accumulation on each qubit throughout a circuit, and compiles this phase information into parametric gates. |
|
Pass which relabels all the labels and keys in a |
|
Pass which accepts one cycle and returns the cycle if it contains any operations. |
|
Pass that removes single qubit identity gates from |
|
An |