Skip to content

compiler

chalmers_qubit.devices.sarimner.compiler

Classes:

Name Description
SarimnerCompiler

Compiler for :class:.SarimnerModel.

SarimnerCompiler

SarimnerCompiler(
    model: Model, options: Optional[dict] = None
)

Bases: GateCompiler

Compiler for :class:.SarimnerModel. Frequencies are the unit of GHz and times in ns.

Parameters:

Name Type Description Default
model Model

Model object of the superconducting qubit device with hardware parameters.

required
options Optional[dict]

A dictionary of compiler options. If not provided, default options will be used.

None

Attributes:

Name Type Description
num_qubits int

The number of component systems (qubits).

params dict

A Python dictionary containing the name and value of hardware parameters, such as qubit frequency, anharmonicity, etc.

gate_compiler dict

A Python dictionary in the form of {gate_name: decompose_function}. It stores the decomposition scheme for each supported gate.

phase list

List of values indicating how much we have virtually rotated the Bloch sphere of each qubit.

global_phase float

The global phase of the quantum state.

dt float

Time step in nanoseconds.

two_qubit_gate_options dict

Options specific to two-qubit gates, including buffer_time and rise_fall_time.

single_qubit_gate_options dict

Options specific to single-qubit gates, including type, gate_time, pi-pulse amplitude, and std.

Notes

The compiler supports various gates including RZ, RX, RY, X, H, CZ, ISWAP, CCZS, IDLE, and GLOBALPHASE. Default options are provided for dt, two-qubit gates, and single-qubit gates, which can be overridden by passing custom options during initialization.

Methods:

Name Description
cczs_compiler

Compiler for CCZS gate.

compile

Compile the the native gates into control pulse sequence.

cz_compiler

Compiler for CZ gate.

generate_pulse_shape

Return a tuple consisting of a coeff list and a time sequence

globalphase_compiler

Compiler for the GLOBALPHASE gate

h_compiler

Compiler for the Hadamard gate

idle_compiler

Compiler for the IDLE gate

iswap_compiler

Compiler for ISWAP gate.

rx_compiler

Compiler for the RX gate

ry_compiler

Compiler for the RY gate

rz_compiler

Compiler for the Virtual-RZ gate

x_compiler

Compiler for the Hadamard gate

cczs_compiler

cczs_compiler(gate, args)

Compiler for CCZS gate.

Parameters:

Name Type Description Default
gate :obj:`.Gate`:

The quantum gate to be compiled.

required
args dict

The compilation configuration defined in the attributes :obj:.GateCompiler.args or given as a parameter in :obj:.GateCompiler.compile.

required

Returns:

Type Description
A list of :obj:`.Instruction`, including the compiled pulse
information for this gate.

compile

compile(circuit, schedule_mode=None, args=None)

Compile the the native gates into control pulse sequence. It calls each compiling method and concatenates the compiled pulses.

Parameters:

Name Type Description Default
circuit

:class:~.operations.Gate A list of elementary gates that can be implemented in the corresponding hardware. The gate names have to be in gate_compiler.

required
schedule_mode

"ASAP" for "as soon as possible" or "ALAP" for "as late as possible" or False or None for no schedule. Default is None.

None
args

A dictionary of arguments used in a specific gate compiler function.

None

Returns:

Type Description
tlist, coeffs: array_like or dict

Compiled ime sequence and pulse coefficients. if return_array is true, return A 2d NumPy array of the shape (len(ctrls), len(tlist)). Each row corresponds to the control pulse sequence for one Hamiltonian. if return_array is false

cz_compiler

cz_compiler(gate, args)

Compiler for CZ gate.

Parameters:

Name Type Description Default
gate :obj:`.Gate`:

The quantum gate to be compiled.

required
args dict

The compilation configuration defined in the attributes :obj:.GateCompiler.args or given as a parameter in :obj:.GateCompiler.compile.

required

Returns:

Type Description
A list of :obj:`.Instruction`, including the compiled pulse
information for this gate.

generate_pulse_shape classmethod

generate_pulse_shape(
    shape, num_samples, maximum=1.0, area=1.0
)

Return a tuple consisting of a coeff list and a time sequence according to a given pulse shape.

Parameters:

Name Type Description Default
shape str

The name "rectangular" for constant pulse or the name of a Scipy window function. See the Scipy documentation <https://docs.scipy.org/doc/scipy/reference/signal.windows.html>_ for detail.

required
num_samples int

The number of the samples of the coefficients.

required
maximum float

The maximum of the coefficients. The absolute value will be used if negative.

1.0
area float

The total area if one integrates coeff as a function of the time. If the area is negative, the pulse is flipped vertically (i.e. the pulse is multiplied by the sign of the area).

1.0

Returns:

Type Description
coeff, tlist :

If the default window "shape"="rectangular" is used, both are float numbers. If Scipy window functions are used, both are a 1-dimensional numpy array with the same size.

Notes

If Scipy window functions are used, it is suggested to set Processor.pulse_mode to "continuous". Notice that finite number of sampling points will also make the total integral of the coefficients slightly deviate from area.

Examples:

.. plot:: :context: reset

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
from qutip_qip.compiler import GateCompiler
import numpy as np
compiler = GateCompiler()
coeff, tlist= compiler.generate_pulse_shape(
    "hann",  # Scipy Hann window
    1000,  # 100 sampling point
    maximum=3.,
    # Notice that 2 pi is added to H by qutip solvers.
    area= 1.,
)

We can plot the generated pulse shape:

.. plot:: :context: close-figs

1
2
3
import matplotlib.pyplot as plt
plt.plot(tlist, coeff)
plt.show()

The pulse is normalized to fit the area. Notice that due to the finite number of sampling points, it is not exactly 1.

.. testsetup::

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
from qutip_qip.compiler import GateCompiler
import numpy as np
compiler = GateCompiler()
coeff, tlist= compiler.generate_pulse_shape(
    "hann",  # Scipy Hann window
    1000,  # 100 sampling point
    maximum=3.,
    # Notice that 2 pi is added to H by qutip solvers.
    area= 1.,
)

.. doctest::

1
2
>>> round(np.trapz(coeff, tlist), 2)
1.0

globalphase_compiler

globalphase_compiler(gate, args)

Compiler for the GLOBALPHASE gate

h_compiler

h_compiler(gate, args)

Compiler for the Hadamard gate

Parameters:

Name Type Description Default
gate :obj:`.Gate`:

The quantum gate to be compiled.

required
args dict

The compilation configuration defined in the attributes :obj:.GateCompiler.args or given as a parameter in :obj:.GateCompiler.compile.

required

idle_compiler

idle_compiler(gate, args)

Compiler for the IDLE gate

iswap_compiler

iswap_compiler(gate, args)

Compiler for ISWAP gate.

Parameters:

Name Type Description Default
gate :obj:`.Gate`:

The quantum gate to be compiled.

required
args dict

The compilation configuration defined in the attributes :obj:.GateCompiler.args or given as a parameter in :obj:.GateCompiler.compile.

required

Returns:

Type Description
A list of :obj:`.Instruction`, including the compiled pulse
information for this gate.

rx_compiler

rx_compiler(gate, args)

Compiler for the RX gate

Parameters:

Name Type Description Default
gate :obj:`.Gate`:

The quantum gate to be compiled.

required
args dict

The compilation configuration defined in the attributes :obj:.GateCompiler.args or given as a parameter in :obj:.GateCompiler.compile.

required

Returns:

Type Description
A list of :obj:`.Instruction`, including the compiled pulse
information for this gate.

ry_compiler

ry_compiler(gate, args)

Compiler for the RY gate

Parameters:

Name Type Description Default
gate :obj:`.Gate`:

The quantum gate to be compiled.

required
args dict

The compilation configuration defined in the attributes :obj:.GateCompiler.args or given as a parameter in :obj:.GateCompiler.compile.

required

Returns:

Type Description
A list of :obj:`.Instruction`, including the compiled pulse
information for this gate.

rz_compiler

rz_compiler(gate, args)

Compiler for the Virtual-RZ gate

Parameters:

Name Type Description Default
gate :obj:`.Gate`:

The quantum gate to be compiled.

required
args dict

The compilation configuration defined in the attributes :obj:.GateCompiler.args or given as a parameter in :obj:.GateCompiler.compile.

required

x_compiler

x_compiler(gate, args)

Compiler for the Hadamard gate

Parameters:

Name Type Description Default
gate :obj:`.Gate`:

The quantum gate to be compiled.

required
args dict

The compilation configuration defined in the attributes :obj:.GateCompiler.args or given as a parameter in :obj:.GateCompiler.compile.

required