Skip to content

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.

Note

With the Pulser backend, qadence simulations can be executed on the cloud emulators available on the PASQAL cloud platform. In order to do so, make to have valid credentials for the PASQAL cloud platform and use the following configuration for the Pulser backend:

config = {
    "cloud_configuration": {
        "username": "<changeme>",
        "password": "<changeme>",
        "project_id": "<changeme>",  # the project should have access to emulators
        "platform": "EMU_FREE"  # choose between `EMU_TN` and `EMU_FREE`
    }
}

For inquiries and more details on the cloud credentials, please contact info@pasqal.com.

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:

\[ \mathcal{H}_{\textrm{int}} = \sum_{i<j} \frac{C_6}{|R_i - R_j|^6} \hat{n}_i \hat{n}_j \]

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
AnalogInteraction An idle block to 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"),
)
bell_state = ChainBlock(0,1)
├── AnalogEntanglement(t=0.19153186677421175, support=(0, 1))
└── RY(0) [params: ['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, PI

register = Register.line(2, spacing = 8.0)  # Two qubits with a distance of 8µm
circuit = QuantumCircuit(register, bell_state)
model = QuantumModel(circuit, backend="pulser", diff_mode="gpsr")

params = {
    "t": torch.tensor([1000]),  # ns
    "y": torch.tensor([3*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]
final_vector = tensor([[-0.7114-0.0169j, -0.0339+0.0156j,  0.0109-0.0457j,  0.6630-0.2244j]])
sample = Counter({'00': 30, '11': 20})

Plot the distribution:


2024-05-03T08:23:12.034947 image/svg+xml Matplotlib v3.7.5, https://matplotlib.org/
One can visualise the pulse sequence with different parameters using the assign_paramters method.

model.assign_parameters(params).draw(show=False)
2024-05-03T08:23:12.125554 image/svg+xml Matplotlib v3.7.5, https://matplotlib.org/

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 import RealisticDevice

# Choose a realistic device
register = Register.line(2, spacing = 8.0, device_specs = RealisticDevice())

circuit = QuantumCircuit(register, bell_state)

model = QuantumModel(
    circuit,
    backend=BackendName.PULSER,
    diff_mode=DiffMode.GPSR,
)

params = {
    "t": torch.tensor([1000]),  # ns
    "y": torch.tensor([3*PI/2]),
}

# Sample from the result state vector
sample = model.sample(params, n_shots=50)[0]
sample = Counter({'00': 27, '11': 21, '10': 2})

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 AnalogInteraction and AnalogRY blocks together with appropriate parameters.

from qadence import AnalogRY, chain, AnalogInteraction

# Custom entanglement operation.
def my_entanglement(duration):
    return chain(
        AnalogRY(-PI / 2),
        AnalogInteraction(duration)
    )

protocol = chain(
   my_entanglement("t"),
   RY(0, "y"),
)

register = Register.line(2, spacing = 8.0)
circuit = QuantumCircuit(register, protocol)
model = QuantumModel(circuit, backend=BackendName.PULSER, diff_mode=DiffMode.GPSR)

params = {
    "t": torch.tensor([500]),  # ns
    "y": torch.tensor([PI / 2]),
}

sample = model.sample(params, n_shots=50)[0]
2024-05-03T08:23:12.551812 image/svg+xml Matplotlib v3.7.5, https://matplotlib.org/

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(PI/4)
)

register = Register.line(2, spacing=8.0)
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)
2024-05-03T08:23:12.665199 image/svg+xml Matplotlib v3.7.5, https://matplotlib.org/

References