Pulse-level programming with Pulser
Qadence offers a direct interface with Pulser1, an open-source pulse-level interface written in Python and specifically designed for programming neutral atom quantum computers.
Using directly Pulser requires advanced knowledge on pulse-level programming and on how neutral atom devices work. Qadence abstracts this complexity out by using the familiar block-based interface for building pulse sequences in Pulser while leaving the possibility to directly manipulate them if required by, for instance, optimal pulse shaping.
Note
The Pulser backend is still experimental and the interface might change in the future.
Please note that it does not support DiffMode.AD
.
Default qubit interaction
When simulating pulse sequences written using Pulser, the underlying constructed Hamiltonian is equivalent to a digital-analog quantum computing program (see digital-analog emulation for more details) with the following interaction term:
where \(C_6\) is an interaction strength coefficient dependent on the principal quantum number of chosen the neutral atom system, \(R_i\) are atomic positions in Cartesian coordinates and \(\hat{n} = \frac{1-\sigma^z_i}{2}\) the number operator.
Note
The Ising interaction is always-on for all computations performed with the Pulser backend. It cannot be switched off.
Available quantum operations
Currently, the Pulser backend supports the following operations:
gate | description | trainable parameter |
---|---|---|
RX , RY |
Single qubit rotations. Notice that the interaction is on and this affects the resulting gate fidelity. | rotation angle |
AnalogRX , AnalogRY , AnalogRZ |
Span a single qubit rotation among the entire register. | rotation angle |
entangle |
Fully entangle the register. | interaction time |
wait |
An idle block to wait for the system to free-evolve for a duration according to the interaction. | free evolution time |
Sequence the Bell state on a two qubit register
The next example illustrates how to create a pulse sequence to prepare a Bell state. This is a sequence of an entanglement operation,
represented as an entangle
gate (using CZ
interactions) in the \(X\)-basis and a \(Y\) rotation for readout
in the \(Z\)-basis:
from qadence import chain, entangle, RY
bell_state = chain(
entangle("t", qubit_support=(0,1)),
RY(0, "y"),
)
Next, a Register
with two qubits is combined with the resulting ChainBlock
to form a circuit.
Then, the QuantumModel
converts the circuit into a proper parametrized
pulse sequence with the Pulser backend. Supplying the parameter values allows to sample the pulse sequence outcome:
import torch
import matplotlib.pyplot as plt
from qadence import Register, QuantumCircuit, QuantumModel
register = Register(2)
circuit = QuantumCircuit(register, bell_state)
model = QuantumModel(circuit, backend="pulser", diff_mode="gpsr")
params = {
"t": torch.tensor([383]), # ns
"y": torch.tensor([3*torch.pi/2]),
}
# Return the final state vector
final_vector = model.run(params)
# Sample from the result state vector
sample = model.sample(params, n_shots=50)[0]
Plot the distribution:
assign_paramters
method.
Change device specifications
At variance with other backends, Pulser provides the concept of Device
. A Device
instance encapsulates
all the properties for the definition of a real neutral atoms processor, including but not limited
to the maximum laser amplitude for pulses, the maximum distance between two qubits and the maximum duration
of the pulse. For more information, please check this tutorial.
Qadence offers a simplified interface with only two devices which are detailed here:
IDEALIZED
(default): ideal device which should be used only for testing purposes. It does not restrict the simulation of pulse sequences.REALISTIC
: device specification close to real neutral atom quantum processors.
Note
If you want to perform simulations closer to the specifications of real neutral atom machines,
always select the REALISTIC
device.
One can use the Configuration
of the Pulser backend to select the appropriate device:
from qadence import BackendName, DiffMode
from qadence.backends.pulser.devices import Device
register = Register(2)
circuit = QuantumCircuit(register, bell_state)
# Choose a realistic device
model = QuantumModel(
circuit,
backend=BackendName.PULSER,
diff_mode=DiffMode.GPSR,
configuration={"device_type": Device.REALISTIC}
)
params = {
"t": torch.tensor([383]), # ns
"y": torch.tensor([3*torch.pi/2]),
}
# Sample from the result state vector
sample = model.sample(params, n_shots=50)[0]
Create a custom gate
A major advantage of the block-based interface in Qadence is the ease to compose complex operations from a restricted set of primitive ones. In the following, a custom entanglement operation is used as an example.
The operation consists of moving all the qubits to the \(X\)-basis. This is realized when the atomic interaction performs a
controlled-\(Z\) operation during the free evolution. As seen before, this is implemented with the wait
and AnalogRY
blocks and
appropriate parameters.
from qadence import AnalogRY, chain, wait
# Custom entanglement operation.
def my_entanglement(duration):
return chain(
AnalogRY(-torch.pi / 2),
wait(duration)
)
protocol = chain(
my_entanglement("t"),
RY(0, "y"),
)
register = Register(2)
circuit = QuantumCircuit(register, protocol)
model = QuantumModel(circuit, backend=BackendName.PULSER, diff_mode=DiffMode.GPSR)
params = {
"t": torch.tensor([383]), # ns
"y": torch.tensor([torch.pi / 2]),
}
sample = model.sample(params, n_shots=50)[0]
Digital-analog QNN circuit
Finally, let's put all together by constructing a digital-analog version of a quantum neural network circuit with feature map and variational ansatz.
from qadence import kron, fourier_feature_map
from qadence.operations import RX, RY, AnalogRX
hea_one_layer = chain(
kron(RY(0, "th00"), RY(1, "th01")),
kron(RX(0, "th10"), RX(1, "th11")),
kron(RY(0, "th20"), RY(1, "th21")),
entangle("t", qubit_support=(0,1)),
)
protocol = chain(
fourier_feature_map(1, param="x"),
hea_one_layer,
AnalogRX(torch.pi/4)
)
register = Register(2)
circuit = QuantumCircuit(register, protocol)
model = QuantumModel(circuit, backend=BackendName.PULSER, diff_mode=DiffMode.GPSR)
params = {
"x": torch.tensor([0.8]), # rad
"t": torch.tensor([900]), # ns
"th00": torch.rand(1), # rad
"th01": torch.rand(1), # rad
"th10": torch.rand(1), # rad
"th11": torch.rand(1), # rad
"th20": torch.rand(1), # rad
"th21": torch.rand(1), # rad
}
model.assign_parameters(params).draw(draw_phase_area=True, show=False)