Skip to content

processor

chalmers_qubit.devices.sarimner.processor

Classes:

Name Description
SarimnerProcessor

Initialize a new SarimnerProcessor instance with a quantum model, an optional compiler, and noise models.

SarimnerProcessor

SarimnerProcessor(
    model: Model,
    compiler: Optional[GateCompiler] = None,
    noise: Optional[list] = None,
)

Bases: Processor

Initialize a new SarimnerProcessor instance with a quantum model, an optional compiler, and noise models.

Parameters:

Name Type Description Default
model Model

The quantum model that defines the physical properties and capabilities of the processor.

required
compiler GateCompiler

The compiler used to translate quantum gates into executable operations. If not provided, a default compiler specific to the model (SarimnerCompiler) is instantiated and used.

None
noise list

A list of noise models to be added to the processor. Each element in the list should be compatible with the processor's noise handling methods.

None

Attributes:

Name Type Description
model Model

The model of the quantum processor, storing physical properties.

_default_compiler GateCompiler

Holds the compiler instance being used, either the provided one or a default SarimnerCompiler.

native_gates None

Initially set to None, to be configured with the gate set natively supported by the processor.

spline_kind str

Type of the coefficient interpolation.

global_phase float

The global phase of the quantum state managed by the processor, initialized to 0.

Methods:

Name Description
add_control

Add a control Hamiltonian to the model. The new control Hamiltonian

add_drift

Add the drift Hamiltonian to the model.

add_noise

Add a noise object to the processor.

add_pulse

Add a new pulse to the device.

eliminate_auxillary_modes

Eliminate the auxillary modes like the cavity modes in cqed.

get_all_drift

Get all the drift Hamiltonians.

get_control

Get the control Hamiltonian corresponding to the label.

get_control_labels

Get a list of all available control Hamiltonians.

get_control_latex

Get the latex string for each Hamiltonian.

get_full_coeffs

Return the full coefficients in a 2d matrix form.

get_full_tlist

Return the full tlist of the ideal pulses.

get_noise

Get a list of :obj:.Noise objects.

get_noisy_pulses

It takes the pulses defined in the Processor and

get_qobjevo

Create a :class:qutip.QobjEvo representation of the evolution.

load_circuit

The default routine of compilation.

plot_pulses

Plot the ideal pulse coefficients.

read_coeff

Read the control amplitudes matrix and time list

remove_pulse

Remove the control pulse with given indices.

run

Calculate the propagator of the evolution by matrix exponentiation.

run_analytically

Simulate the state evolution under the given qutip.QubitCircuit

run_propagator

Parameters

save_coeff

Save a file with the control amplitudes in each timeslot.

set_coeffs

Clear all the existing pulses and

set_tlist

Set the tlist for all existing pulses. It assumes that

coeffs property writable

coeffs

A list of ideal control coefficients for all saved pulses. The order matches with :obj:Processor.controls

controls property

controls

A list of the ideal control Hamiltonians in all saved pulses. Note that control Hamiltonians with no pulse will not be included. The order matches with :obj:Processor.coeffs

dims property writable

dims

The dimension of each component system. :type: list

drift property

drift

The drift Hamiltonian in the form [(qobj, targets), ...] :type: list

noise property

noise

.coverage

num_qubits property writable

num_qubits

Number of qubits (or subsystems). For backward compatibility. :type: int

params property

params

Hardware parameters. :type: dict

pulse_mode property writable

pulse_mode

If the given pulse is going to be interpreted as "continuous" or "discrete".

:type: str

t1 property writable

t1

Characterize the total amplitude damping of each qubit. :type: float or list

t2 property writable

t2

Characterize the total dephasing for each qubit. :type: float or list

add_control

add_control(
    qobj, targets=None, cyclic_permutation=False, label=None
)

Add a control Hamiltonian to the model. The new control Hamiltonian is saved in the :obj:.Processor.model attributes.

Parameters:

Name Type Description Default
qobj :obj:`qutip.Qobj`

The control Hamiltonian.

required
targets list

The indices of the target qubits (or composite quantum systems).

None
cyclic_permutation bool

If true, the Hamiltonian will be added for all qubits, e.g. if targets=[0,1], and there are 2 qubits, the Hamiltonian will be added to the target qubits [0,1], [1,2] and [2,0].

False
label str

The hashable label (name) of the control Hamiltonian. If None, it will be set to the current number of control Hamiltonians in the system.

None

Examples:

>>> import qutip
>>> from qutip_qip.device import Processor
>>> processor = Processor(1)
>>> processor.add_control(qutip.sigmax(), 0, label="sx")
>>> processor.get_control_labels()
['sx']
>>> processor.get_control("sx")
(Quantum object: dims=[[2], [2]], shape=(2, 2),
type='oper', dtype=CSR, isherm=True
Qobj data =
[[0. 1.]
[1. 0.]], [0])

add_drift

add_drift(qobj, targets=None, cyclic_permutation=False)

Add the drift Hamiltonian to the model. The drift Hamiltonians are intrinsic of the quantum system and cannot be controlled by an external field.

Parameters:

Name Type Description Default
qobj :class:`qutip.Qobj`

The drift Hamiltonian.

required
targets list

The indices of the target qubits (or subquantum system of other dimensions).

None
cyclic_permutation bool

If true, the Hamiltonian will be added for all qubits, e.g. if targets=[0,1], and there are 2 qubits, The Hamiltonian will be added to the target qubits [0,1], [1,2] and [2,0].

False

add_noise

add_noise(noise)

Add a noise object to the processor.

Parameters:

Name Type Description Default
noise :class:`.Noise`

The noise object defined outside the processor.

required

add_pulse

add_pulse(pulse)

Add a new pulse to the device.

Parameters:

Name Type Description Default
pulse :class:`.Pulse`

Pulse object to be added.

required

eliminate_auxillary_modes

eliminate_auxillary_modes(U)

Eliminate the auxillary modes like the cavity modes in cqed. (Defined in subclasses)

get_all_drift

get_all_drift()

Get all the drift Hamiltonians.

Returns:

Name Type Description
drift_hamiltonian_list list

A list of drift Hamiltonians in the form of [(qobj, targets), ...].

get_control

get_control(label)

Get the control Hamiltonian corresponding to the label.

Parameters:

Name Type Description Default
label

A label that identifies the Hamiltonian.

required

Returns:

Name Type Description
control_hamiltonian tuple

The control Hamiltonian in the form of (qobj, targets).

Examples:

>>> from qutip_qip.device import LinearSpinChain
>>> processor = LinearSpinChain(1)
>>> processor.get_control_labels()
['sx0', 'sz0']
>>> processor.get_control('sz0')
(Quantum object: dims=[[2], [2]], shape=(2, 2),
type='oper', dtype=CSR, isherm=True
Qobj data =
[[ 6.28319  0.     ]
 [ 0.      -6.28319]], 0)

get_control_labels

get_control_labels()

Get a list of all available control Hamiltonians.

Returns:

Name Type Description
label_list list

A list of hashable objects each corresponds to an available control Hamiltonian.

get_control_latex

get_control_latex()

Get the latex string for each Hamiltonian. It is used in the method :meth:.Processor.plot_pulses. It is a list of dictionaries. In the plot, a different color will be used for each dictionary in the list.

Returns:

Name Type Description
nested_latex_str list of dict

E.g.: [{"sx": "\sigma_z"}, {"sy": "\sigma_y"}].

get_full_coeffs

get_full_coeffs(full_tlist=None)

Return the full coefficients in a 2d matrix form. Each row corresponds to one pulse. If the tlist are different for different pulses, the length of each row will be the same as the full_tlist (see method get_full_tlist). Interpolation is used for adding the missing coefficients according to spline_kind.

Returns:

Name Type Description
coeffs array-like 2d

The coefficients for all ideal pulses.

get_full_tlist

get_full_tlist(tol=1e-10)

Return the full tlist of the ideal pulses. If different pulses have different time steps, it will collect all the time steps in a sorted array.

Returns:

Name Type Description
full_tlist array-like 1d

The full time sequence for the ideal evolution.

get_noise

get_noise()

Get a list of :obj:.Noise objects.

Returns:

Name Type Description
noise_list list

A list of :obj:.Noise.

get_noisy_pulses

get_noisy_pulses(device_noise=False, drift=False)

It takes the pulses defined in the Processor and adds noise according to Processor.noise. It does not modify the pulses saved in Processor.pulses but returns a new list. The length of the new list of noisy pulses might be longer because of drift Hamiltonian and device noise. They will be added to the end of the pulses list.

Parameters:

Name Type Description Default
device_noise

If true, include pulse independent noise such as single qubit Relaxation. Default is False.

False
drift

If true, include drift Hamiltonians. Default is False.

False

Returns:

Name Type Description
noisy_pulses list of :class:`.Drift`

A list of noisy pulses.

get_qobjevo

get_qobjevo(args=None, noisy=False)

Create a :class:qutip.QobjEvo representation of the evolution. It calls the method :meth:.Processor.get_noisy_pulses and create the QobjEvo from it.

Parameters:

Name Type Description Default
args

Arguments for :class:qutip.QobjEvo

None
noisy

If noise are included. Default is False.

False

Returns:

Name Type Description
qobjevo :class:`qutip.QobjEvo`

The :class:qutip.QobjEvo representation of the unitary evolution.

c_ops list of :class:`qutip.QobjEvo`

A list of lindblad operators is also returned. if noisy==False, it is always an empty list.

load_circuit

load_circuit(
    qc: QubitCircuit,
    schedule_mode: str = "ASAP",
    compiler: Optional[GateCompiler] = None,
)

The default routine of compilation. It first calls the :meth:.transpile to convert the circuit to a suitable format for the hardware model. Then it calls the compiler and save the compiled pulses.

Parameters:

Name Type Description Default
qc :class:`.QubitCircuit`

Takes the quantum circuit to be implemented.

required
schedule_mode str

"ASAP" or "ALAP" or None.

'ASAP'
compiler Optional[GateCompiler]

The used compiler.

None

Returns:

Type Description
tlist, coeffs: dict of 1D NumPy array

A dictionary of pulse label and the time sequence and compiled pulse coefficients.

plot_pulses

plot_pulses(
    title=None,
    figsize=(12, 6),
    dpi=None,
    show_axis=False,
    rescale_pulse_coeffs=True,
    num_steps=1000,
    pulse_labels=None,
    use_control_latex=True,
)

Plot the ideal pulse coefficients.

Parameters:

Name Type Description Default
title

Title for the plot.

None
figsize

The size of the figure.

(12, 6)
dpi

The dpi of the figure.

None
show_axis

If the axis are shown.

False
rescale_pulse_coeffs

Rescale the hight of each pulses.

True
num_steps

Number of time steps in the plot.

1000
pulse_labels

A map between pulse labels and the labels shown in the y axis. E.g. [{"sx": "sigmax"}]. Pulses in each dictionary will get a different color. If not given and use_control_latex==False, the string label defined in each :obj:.Pulse is used.

None
use_control_latex

Use labels defined in Processor.model.get_control_latex.

True
pulse_labels

A map between pulse labels and the labels shown on the y axis. E.g. ["sx", "sigmax"]. If not given and use_control_latex==False, the string label defined in each :obj:.Pulse is used.

None
use_control_latex

Use labels defined in Processor.model.get_control_latex.

True

Returns:

Name Type Description
fig Figure

The Figure object for the plot.

axis list of ``matplotlib.axes._subplots.AxesSubplot``

The axes for the plot.

Notes

:meth:.Processor.plot_pulses` only works for array_like coefficients.

read_coeff

read_coeff(file_name, inctime=True)

Read the control amplitudes matrix and time list saved in the file by save_amp.

Parameters:

Name Type Description Default
file_name

Name of the file.

required
inctime

True if the time list in included in the first column.

True

Returns:

Name Type Description
tlist array_like

The time list read from the file.

coeffs array_like

The pulse matrix read from the file.

remove_pulse

remove_pulse(indices=None, label=None)

Remove the control pulse with given indices.

Parameters:

Name Type Description Default
indices

The indices of the control Hamiltonians to be removed.

None
label

The label of the pulse

None

run

run(qc=None)

Calculate the propagator of the evolution by matrix exponentiation. This method won't include noise or collpase.

Parameters:

Name Type Description Default
qc :class:`.QubitCircuit`

Takes the quantum circuit to be implemented. If not given, use the quantum circuit saved in the processor by load_circuit.

None

Returns:

Name Type Description
U_list list

The propagator matrix obtained from the physical implementation.

run_analytically

run_analytically(init_state=None, qc=None)

Simulate the state evolution under the given qutip.QubitCircuit with matrice exponentiation. It will calculate the propagator with matrix exponentiation and return a list of :class:qutip.Qobj. This method won't include noise or collpase.

Parameters:

Name Type Description Default
qc :class:`.QubitCircuit`

Takes the quantum circuit to be implemented. If not given, use the quantum circuit saved in the processor by load_circuit.

None
init_state :class:`qutip.Qobj`

The initial state of the qubits in the register.

None

Returns:

Name Type Description
U_list list

A list of propagators obtained for the physical implementation.

run_propagator

run_propagator(
    qc: Optional[QubitCircuit] = None,
    noisy: bool = False,
    **kwargs
)

Parameters:

Name Type Description Default
qc Optional[QubitCircuit]

A quantum circuit. If given, it first calls the load_circuit and then calculate the evolution.

None
noisy bool

If noise are included. Default is False.

False
**kwargs

Keyword arguments for the qutip solver.

{}

Returns:

Name Type Description
prop list of Qobj or Qobj

Returns the propagator(s) calculated at times t.

save_coeff

save_coeff(file_name, inctime=True)

Save a file with the control amplitudes in each timeslot.

Parameters:

Name Type Description Default
file_name

Name of the file.

required
inctime

True if the time list should be included in the first column.

True

set_coeffs

set_coeffs(coeffs)

Clear all the existing pulses and reset the coefficients for the control Hamiltonians.

Parameters:

Name Type Description Default
coeffs
  • If it is a dict, it should be a map of the label of control Hamiltonians and the corresponding coefficients. Use :obj:.Processor.get_control_labels() to see the available Hamiltonians.
  • If it is a list of arrays or a 2D NumPy array, it is treated same to dict, only that the pulse label is assumed to be integers from 0 to len(coeffs)-1.
required

set_tlist

set_tlist(tlist)

Set the tlist for all existing pulses. It assumes that pulses all already added to the processor. To add pulses automatically, first use :obj:Processor.set_coeffs.

Parameters:

Name Type Description Default
tlist

If it is a dict, it should be a map between pulse label and the time sequences. If it is a list of arrays or a 2D NumPy array, each array will be associated to a pulse, following the order in the pulse list.

required