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: |
get_noisy_pulses |
It takes the pulses defined in the |
get_qobjevo |
Create a :class: |
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 |
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 |
coeffs
property
writable
A list of ideal control coefficients for all saved pulses.
The order matches with :obj:Processor.controls
controls
property
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
num_qubits
property
writable
Number of qubits (or subsystems). For backward compatibility. :type: int
pulse_mode
property
writable
If the given pulse is going to be interpreted as "continuous" or "discrete".
:type: str
t1
property
writable
Characterize the total amplitude damping of each qubit. :type: float or list
add_control
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 |
False
|
label
|
str
|
The hashable label (name) of the control Hamiltonian.
If |
None
|
Examples:
add_drift
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 |
False
|
add_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 a new pulse to the device.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pulse
|
:class:`.Pulse`
|
|
required |
eliminate_auxillary_modes
Eliminate the auxillary modes like the cavity modes in cqed. (Defined in subclasses)
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
|
get_control
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 |
Examples:
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 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.: |
get_full_coeffs
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
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 a list of :obj:.Noise
objects.
Returns:
Name | Type | Description |
---|---|---|
noise_list |
list
|
A list of :obj: |
get_noisy_pulses
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
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: |
None
|
|
noisy
|
If noise are included. Default is False. |
False
|
Returns:
Name | Type | Description |
---|---|---|
qobjevo |
:class:`qutip.QobjEvo`
|
The :class: |
c_ops |
list of :class:`qutip.QobjEvo`
|
A list of lindblad operators is also returned.
if |
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. |
None
|
|
use_control_latex
|
Use labels defined in |
True
|
|
pulse_labels
|
A map between pulse labels and the labels shown on the y axis.
E.g. |
None
|
|
use_control_latex
|
Use labels defined in |
True
|
Returns:
Name | Type | Description |
---|---|---|
fig |
Figure
|
The |
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 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 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
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 |
None
|
Returns:
Name | Type | Description |
---|---|---|
U_list |
list
|
The propagator matrix obtained from the physical implementation. |
run_analytically
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 |
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 |
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 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
Clear all the existing pulses and reset the coefficients for the control Hamiltonians.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
coeffs
|
|
required |
set_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 |