Skip to main content

QuantumInspireUtilities

This repository contains utility functions and demonstration notebooks that supplement the Quantum Inspire 2.0 Python SDK, tailored for the superconducting backends of the platform, hosted in the DiCarlo lab in QuTech.

It is primarily intended for researchers, students, and developers who use Quantum Inspire’s superconducting backends and want reusable utilities and worked examples beyond the core SDK.

Useful links relating to our superconducting backends:

  1. Tuna Backends Operational Specifics
  2. Backend Performance Dashboards [live updates]
  3. Join our Slack community!

1. Installation instructions

1.1. Beginner-friendly installation

Note: this installation method is typically not recommended, but is nevertheless suggested due to its relative simplicity. In principle it avoids installing and using pipx, which some users have experienced difficulties in doing so.

  1. Install Anaconda or Miniconda (lightweight version of Anaconda) in your computer
  2. Open Anaconda Prompt (or Terminal in UNIX)
  3. Run the following commands
  • conda create -n quantuminspire python=3.12 (creates a new conda environment)
  • conda activate quantuminspire (activates the environment)
  • pip install quantuminspire
  • pip install qi-utilities (installs this repository)
  • pip install jupyterlab
  • pip install notebook

Installing quantuminspire within the conda environment restricts the command 'qi login' to be recognized and used only within the created environment.

  1. Install pipx (used when installing quantuminspire package)
  2. Install quantuminspire repository (used for login)
  3. Install Anaconda or Miniconda (lightweight version of Anaconda) in your computer
  4. Open Anaconda Prompt (or Terminal in UNIX)
  5. Run the following commands
  • conda create -n quantuminspire python=3.12 (creates a new conda environment)
  • conda activate quantuminspire (activates the environment)
  • pip install qi-utilities (installs this repository)
  • pip install jupyterlab
  • pip install notebook

Note: in order to run the method backend.coupling_map.draw(), you will need to install Graphviz in your computer. Make sure during installation to add Graphviz to the system PATH, so that your Python environment can recognize it.

2. Using the notebook guides (requires cloning the repository)

In order to use the Jupyter notebook guides which include from simple example code up to advanced demonstrations, you will need to clone this repository. First, you will need a GitHub account to be able to pull the project.

For new users, we recommend downloading GitHub Desktop, and then cloning the repository by using the link https://github.com/DiCarloLab-Delft/QuantumInspireUtilities.git.

After creating a working Python environment (see instructions above) and having cloned the repository, you should be able to use the notebooks.

In order to create your first quantum circuit using the Quantum Inspire SDK, visit https://qutech-delft.github.io/qiskit-quantuminspire/getting_started/submitting.html.

3. Using a noisy simulator of a backend

The NoisySimulator class is built on top of the Qiskit AerSimulator, mimicking a Quantum Inspire backend: it has the same native gate set, coupling map and shot limits as the hardware, and returns job results structured like those of the Quantum Inspire SDK.

The noise model is constructed from the device parameters stored in backend_parameters.json (qubit frequencies, $T_1$, $T_2$, randomized benchmarking errors, readout errors and CZ interleaved randomized benchmarking errors), and includes:

  • Single-qubit gate errors: single-qubit depolarizing channel, derived from the randomized benchmarking error of each qubit.
  • Two-qubit gate errors: two-qubit depolarizing channel, derived from the interleaved randomized benchmarking error of each CZ gate.
  • Idling errors: relaxation and pure dephasing channels, applied for every 20 ns cycle of a delay operation.
  • Readout errors: relaxation and pure dephasing channels for the duration of the readout operation, as well as readout assignment errors.

The noise modelling does not capture leakage or crosstalk effects. Individual noise sources can be switched on or off through the noise_applied argument, while ideal_simulation=True gives a noiseless simulator.

The noisy simulator can be used directly with the DeviceControl class (see next section) and the rest of the repository,

from qi_utilities.device_simulation.simulators import NoisySimulator

backend = NoisySimulator("Tuna-17")   # or "Starmon-7"
device = DeviceControl(backend)

4. Device benchmarking module

This module contains characterization experiments that are routinely used in a superconducting qubits lab in order to benchmark a quantum processor, adapted for execution on the Tuna backends of Quantum Inspire. With a single line of code, one can measure the relaxation and dephasing times of the qubits, check the calibration of the single-qubit gates, and benchmark the CZ gate as well as the preparation of entangled states.

The module contains the following tools, (along with their section in the tutorial).

  1. The DeviceControl class (Sec. 3 of the user tutorial)
  2. Single-qubit benchmark measurements (Sec. 4 of the user tutorial)
  3. Two-qubit benchmark measurements (Sec. 5 of the user tutorial)

4.1. The DeviceControl class

All experiments are executed through the DeviceControl class, which serves as a single entry point for benchmarking a backend,

from qiskit_quantuminspire.qi_provider import QIProvider
from qi_utilities.measurements.device_control import DeviceControl

backend = QIProvider().get_backend(name="Tuna-17")
device = DeviceControl(backend)

device.measure_T1(qubit_list='all')   # measures all qubits simultaneously
device.T1_values                      # the latest measured T1 values
device.latest_qc.draw('mpl')          # the latest executed quantum circuit

Behind the scenes, every measure_ method:

  1. creates a single quantum circuit containing one measurement block per measurement point, using mid-circuit measurements, so that a full experiment is executed as a single job,
  2. appends the readout calibration circuits, used for mitigating readout errors through the readout assignment matrix,
  3. executes the job on the backend, and stores the project record locally (by default inside the Documents/QuantumInspireProjects folder),
  4. fits the data, and stores the plots (PNG format) and the processed data (JSON format) inside the project folder,
  5. prints the extracted values, which are also stored as attributes of the class.

The data of any previous measurement can be loaded and re-analyzed through the load_data method of the corresponding measurement class, by passing the timestamp of the experiment, e.g. T1_Measurement.load_data(job_timestamp='YYYYMMDD_HHMMSS') (Sec. 7 of the user tutorial).

4.2. Single-qubit benchmark measurements

The following single-qubit experiments are available, closely following the procedures described in M. Reed's PhD thesis (2013), Chapter 5. All idle times are applied in integer multiples of the 20 ns cycle time of the Tuna backends.

Experiment Method What it measures
Rabi oscillation measure_rabi Population $P(\ket{1})$ versus rotation angle, fitted with a cosine. Checks whether the qubit behaves well as a two-level system.
Relaxation time measure_T1 Relaxation time $T_1$
Ramsey experiment measure_T2_ramsey Dephasing time $T_2^*$ and qubit detuning
Hahn echo experiment measure_T2_echo Echo dephasing time $T_2^{\text{echo}}$
Flipping experiment measure_flipping Amplitude scale factor of the $\pi$ (or $\pi/2$) pulses, with ideal value 1
AllXY experiment measure_allxy Mean absolute deviation from the ideal AllXY "staircase", a quick diagnosis of single-qubit gate errors

In a $T_1$ measurement the qubit is excited with a $\pi$ pulse and left idle for a varied time $t$, with its excited state population decaying as

$$ P(\ket{1}) = a\cdot e^{-t/T_1} + b. \displaystyle $$

In a Ramsey experiment the qubit is placed on the equator of the Bloch sphere with a $\pi/2$ pulse, evolves freely for a time $t$, and is rotated back with a second $\pi/2$ pulse. An artificial detuning $f$ is imposed through a virtual Z rotation, such that the population follows a damped oscillation,

$$ P(\ket{1}) = a\cdot e^{-t/T_2^*}\cos(2\pi f t + \phi) + b. \displaystyle $$

In case a double beating is detected in the data (e.g. due to a qubit frequency switching between two values), the experiment is automatically re-launched with two adjusted artificial detunings. The Hahn echo experiment adds a refocusing $\pi$ pulse in the middle of the free evolution, making the qubit insensitive to low-frequency noise, typically resulting in $T_2^{\text{echo}} > T_2^*$.

4.3. Two-qubit benchmark measurements

The CZ gate is characterized with the conditional oscillation experiment (measure_conditional_oscillation), following M. A. Rol's PhD thesis (2020), Section 7.5.4. For each qubit pair, a Ramsey-like experiment is performed on the target qubit with the control qubit either in $\lvert 0\rangle$ ("Off") or in $\ket{1}$ ("On"). The phase difference between the two oscillations gives the conditional phase $\phi_c$ of the CZ gate, ideally $180^\circ$, while the missing fraction $m$ of the control qubit gives an estimate for the leakage of the gate, $L_1 \approx m/2$. Multiple CZ repetitions can be used to amplify phase errors.

The preparation of entangled states is benchmarked with two-qubit state tomography of a Bell state (measure_bell_state_fidelity). Both qubits are measured in all 9 two-qubit Pauli bases, and a physical density matrix $\rho = T^\dagger T / \mathrm{Tr}(T^\dagger T)$, with $T$ a lower triangular matrix, is fitted to the measured expectation values. The Bell-state fidelity is then given by

$$ F = \bra{\psi} \rho \ket{\psi}, $$

with $\ket{\psi}$ the target Bell state.

5. Error mitigation module

This module contains utility functions enabling quantum error mitigation using the zero-noise extrapolation (ZNE) technique on the superconducting backends of Quantum Inspire. These tools focus on the CZ gate, as this is the only native 2-qubit gate of the Tuna backends, but they can in principle be used for any other kind of two-qubit gate on any hardware.

The module contains the following tools for performing error mitigation, (along with their section in the tutorial).

  1. Pauli twirling (Sec. 3 of the user tutorial)
  2. Noise learning for CZ gates (Sec. 4 of the user tutorial)
  3. Probabilistic error amplification (PEA) (Sec. 5 of the user tutorial)
  4. Zero-noise extrapolation (ZNE) (Sec. 5 of the user tutorial)

5.1. Pauli twirling

We describe a noisy CZ gate $\widetilde{\mathrm{CZ}}$ as a general noise channel $\Lambda$ acting before an ideal CZ operation.

Pauli twirling is used to approximate the general channel $\Lambda$ with a stochastic Pauli error channel $\Lambda_P$, which is diagonal in the Pauli basis. A random two-qubit Pauli $P$ is applied before the CZ gate, and to preserve the ideal action of the circuit, its conjugate $P^\prime = \mathrm{CZ}\ P\ \mathrm{CZ}^\dagger$ is applied after the CZ gate. Averaging over different randomizations diagonalizes the noise channel, such that when acting on Pauli operators it only applies a multiplicative factor $f_i$ called the Pauli fidelity,

$$ \Lambda_P(P_i) = f_i P_i, $$

where $\Lambda_P$ is the Pauli channel and $P_i$ the two-qubit Pauli operator.

5.2. Learning the noise of a CZ gate

The noise learning tools closely follow the procedure shown by van den Berg, E., Minev, Z.K., Kandala, A. et al (2023), with the exception that we assume that when multiple CZ gates are performed in parallel, the noise channel can be approximated as multiple two-qubit noise channels acting on the individual CZ gates (assumes no or low CZ crosstalk).

The first step in the noise learning procedure is to learn the Pauli fidelities of the twirled noise channel $\Lambda_P$. We execute circuits containing a varying number of CZ gate repetitions, and fit exponential decays to the obtained expectation values, in order to extract the Pauli fidelities. However, using this technique one can only learn multiplicative pairs of Pauli fidelities for the CZ gate.

We use the symmetry condition assumption used by van den Berg, E., Minev, Z.K., Kandala, A. et al (2023) to solve the issue of the occuring pairs of Pauli fidelities: the two fidelities that appear in each pair are treated as equal. Finally we can fit the noise model and obtain the Pauli error rates ($\lambda_i$).

5.3. Probabilistic error amplification (PEA)

The noise amplification closely follows the procedure shown by Kim, Y., Eddins, A., Anand, S. et al (2023). We can selectively amplify the effective noise of a CZ gate once we have learned its twirled noise $\Lambda_P$. We sample errors from the noise model and apply them before the (Pauli twirled) CZ gate. Averaging over different randomizations adds an additional Pauli channel $\Lambda_P$ in front of the CZ gate with an appropriate scale factor $\alpha$, resulting in an effective noise gain of $G=\alpha+1$.

5.4. Zero-noise extrapolation (ZNE)

Once we have executed a circuit at multiple different noise gains $G$, we can use ZNE to get a noise mitigated estimate of the expectation values $E^{\text{ZNE}}$. We perform a fit (linear or exponential) on the measured expectation values $E(G)$; by extrapolating this fit to $G=0$ we get the noise-mitigated estimate of the expectation value.

6. TODOs

[2026-01-20] Current list of targeted upcoming new features:

  • Create utility functions and a demonstration notebook guide on variational quantum algorithms.

Metadata

Release files for qi-utilities 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for qi-utilities 0.4.1
File Size Uploaded Provenance Actions
qi_utilities-0.4.1.tar.gz 101.8 kB Without provenance Details for qi_utilities-0.4.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for qi-utilities 0.4.1
File Interpreter ABI Platform Actions
qi_utilities-0.4.1-py3-none-any.whl Python 3 none any Details for qi_utilities-0.4.1-py3-none-any.whl

Total release size: 213.2 kB

Release files / qi_utilities-0.4.1.tar.gz

Download URL qi_utilities-0.4.1.tar.gz
Size 101.8 kB
Tags Source
SHA-256 checksum
How to use checksums
37bc61ff2ae39efd27016152b80f65575dbd5603e622c790568abb1327c6d981
BLAKE2b-256 checksum
How to use checksums
4ab50217c32fb42f6f341204a0ae3224ddb7cce17e6c26de7ed0d96b8485a40d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.14

Release files / qi_utilities-0.4.1-py3-none-any.whl

Download URL qi_utilities-0.4.1-py3-none-any.whl
Size 111.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
78658fb9996fabf0c2a535d7c586f9a1fd0093c444079bb9566b76b5f7c361e2
BLAKE2b-256 checksum
How to use checksums
10f1b12a67e377592254d47e85ea409fbe69da9cd03aad444f85ea3bc5ee8527
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.14

Security for qi-utilities 0.4.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.4.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page