Skip to main content

A simulator of the Chalmers device to be used with qutip-qip

Project description

chalmers-qubit

Tests documentation license PyPI - Python Version

A simulation framework for Chalmers devices that can be used to simulate the running of quantum algorithms with realistic noise. We follow qutip-qip to build a processor that can take in a quantum circuit (e.g., a QASM cicruit) and performs a master equation simulation adding noise such as T1 and T2. It is also possible to perform a Monte-Carlo trajectory simulation and customize the processor to add various types of noise such as ZZCrossTalk.

The package is under development and testing.

Installation

The main requirement to use this package is qutip-qip based on qutip: The Quantum Toolbox in Python. The requirements are already specified in the setup.cfg file and you can install the package chalmers_qubit simply by downloading this folder or cloning this repository and running:

pip install .

to get the minimal installation. You can instead use '.[full]' to install the package with all optional dependencies, such as matplotlib. Moreover, it might be beneficial to install an editable version. In the editable version, changes to the code are reflected system-wide without requiring a reinstallation.

pip install -e '.[full]'

If you do not care about making changes to the source code and just want to try out the package (e.g., from Google Colab), you can do a git+ install with

pip install git+https://github.com/aqp-mc2-chalmers/chalmers-qubit.git

Usage

The usage of the package follows qutip-qip where first, a quantum circuit is defined using qutip-qip and then run on one of the custom Chalmers processors, e.g., the processor called sarimner. The custom processor is defined in chalmers_qubit.devices.sarimner.processor and can be initialized with a model, compiler and noise.

Note that only gates with compilation instructions in chalmers_qubit/sarimner/compiler.py will work for this particular processor.

Notebooks exploring the usage of the simulator is available in docs/examples/.

import numpy as np
from qutip import basis, tensor
from qutip_qip.circuit import QubitCircuit
from chalmers_qubit.devices.sarimner import (
    SarimnerProcessor,
    SarimnerModel,
    SarimnerCompiler,
    DecoherenceNoise,
    ZZCrossTalk,
)

# Define a quantum circuit
qc = QubitCircuit(2)
qc.add_gate("RX", targets=0, arg_value=np.pi / 2)
qc.add_gate("RY", targets=1, arg_value=np.pi / 2)
qc.add_gate("CZ", controls=0, targets=1)

# All frequencies are defined in GHz, and times in ns.
transmon_dict = {
    0: {"frequency": 5.0, "anharmonicity": -0.30},
    1: {"frequency": 5.4, "anharmonicity": -0.30},
}
coupling_dict = {
    (0, 1): 0.04,
}
# Construct model
model = SarimnerModel(transmon_dict=transmon_dict,
                      coupling_dict=coupling_dict)

# Load a compiler
compiler = SarimnerCompiler(model=model)

# Define all the noise objects as a list.
decoherence_dict = {
    0: {"t1": 60e3, "t2": 80e3},
    1: {"t1": 100e3, "t2": 105e3},
}
cross_talk_dict = {
    (0, 1): 1e-4,
}
noise = [
    DecoherenceNoise(decoherence_dict=decoherence_dict),
    ZZCrossTalk(cross_talk_dict=cross_talk_dict),
]

# Initialize the processor
processor = SarimnerProcessor(model=model, compiler=compiler, noise=noise)

# Load the circuit that generates the pulses to run the simulation
tlist, coeffs = processor.load_circuit(qc)

# Initial state for the simulation.
# The default assumptions is that each transmon is a qudit with 3 levels.
init_state = tensor(basis(3, 1), basis(3, 1))

# Run master equation simulation
result = processor.run_state(init_state)
print("Final state", result.states[-1])

# Run the same circuit but with mcsolve using 100 trajectories.
result = processor.run_state(init_state, solver="mcsolve", ntraj=100)
print("Final state", result.states[-1])

It is also possible to import QASM circuits.

Development

In order to add new custom pulses or modify the device, edit the processor, or compiler the tutorials and detailed instructions in qutip-qip.

The tutorials show examples of how to customize the processor. If you have installed the package in the develop mode, any changes to the processor, e.g., adding a new gate will be reflected immediately system-wide without requiring a reinstallation of the package.

Support

This package was built from contributions by Pontus Vikstål and Shahnawaz Ahmed.

Contact vikstal@chalmers.se, shahnawaz.ahmed95@gmail.com or anton.frisk.kockum@chalmers.se for help and support.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

chalmers_qubit-2.1.1.tar.gz (30.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

chalmers_qubit-2.1.1-py3-none-any.whl (36.6 kB view details)

Uploaded Python 3

File details

Details for the file chalmers_qubit-2.1.1.tar.gz.

File metadata

  • Download URL: chalmers_qubit-2.1.1.tar.gz
  • Upload date:
  • Size: 30.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for chalmers_qubit-2.1.1.tar.gz
Algorithm Hash digest
SHA256 c6a795bad71a0140b6dfbd501f550d5e2a48cf4519d52b27e3375fc43d69ade5
MD5 ef88c0dc93611fe59f16a49aff118104
BLAKE2b-256 e0b95a6f9f293a67b1ec6330f1a9f572af365b7dc8ed21542bdb8805f1d33e9c

See more details on using hashes here.

Provenance

The following attestation bundles were made for chalmers_qubit-2.1.1.tar.gz:

Publisher: release.yml on aqp-mc2-chalmers/chalmers-qubit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file chalmers_qubit-2.1.1-py3-none-any.whl.

File metadata

  • Download URL: chalmers_qubit-2.1.1-py3-none-any.whl
  • Upload date:
  • Size: 36.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for chalmers_qubit-2.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bad07a4e0fb5373a53e7c2828db3c1eac761092d61d3416c46837af25e28c789
MD5 01020bbf6500904b26909753f9bc7445
BLAKE2b-256 c0f8dea0709779e0737f0f28f79f2a6c3a6f9f7780345d5dc4adeaac7ee65fff

See more details on using hashes here.

Provenance

The following attestation bundles were made for chalmers_qubit-2.1.1-py3-none-any.whl:

Publisher: release.yml on aqp-mc2-chalmers/chalmers-qubit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page