# chalmers-qubit
[](https://github.com/aqp-mc2-chalmers/chalmers-qubit/actions/workflows/tests.yml) [](https://squidfunk.github.io/mkdocs-material/) [](https://opensource.org/licenses/BSD-3-Clause) <a href="https://pypi.org/project/chalmers-qubit/"><img alt="PyPI - Python Version" src="https://img.shields.io/pypi/pyversions/chalmers-qubit"></a>
A simulation framework for Chalmers devices that can be used to simulate the running of quantum algorithms with realistic noise. We follow [qutip-qip](https://qutip-qip.readthedocs.io/en/stable/) 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](https://qutip-qip.readthedocs.io/en/latest/apidoc/qutip_qip.noise.html#qutip_qip.noise.ZZCrossTalk).
The package is under development and testing.
## Installation
The main requirement to use this package is [qutip-qip](https://qutip-qip.readthedocs.io/en/stable/) based on [qutip](https://qutip-qip.readthedocs.io/en/stable/): 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:
``` zsh
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.
``` zsh
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
``` zsh
pip install git+https://github.com/aqp-mc2-chalmers/chalmers-qubit.git
```
## Usage
The usage of the package follows [qutip-qip](https://qutip-qip.readthedocs.io/en/stable/) where first, a quantum circuit is defined using [`qutip-qip`](https://qutip-qip.readthedocs.io/en/stable/qip-simulator.html) and then run on one of the custom Chalmers processors, e.g., the processor called sarimner. The custom processor is defined in `chalmers_qubit.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 `examples/`.
``` python
import numpy as np
from qutip import basis, tensor
from qutip_qip.circuit import QubitCircuit
from chalmers_qubit.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](https://nbviewer.org/urls/qutip.org/qutip-tutorials/tutorials-v5/quantum-circuits/qasm.ipynb).
## 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](https://qutip-qip.readthedocs.io/en/stable/).
The [tutorials](https://qutip.org/qutip-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, Kamanasish Debnath and Shahnawaz Ahmed.
Contact vikstal@chalmers.se, shahnawaz.ahmed95@gmail.com or anton.frisk.kockum@chalmers.se for help and support.
Raw data
{
"_id": null,
"home_page": null,
"name": "chalmers-qubit",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": null,
"author": "Pontus Vikst\u00e5l, Kamanasish Debnath, Shahnawaz Ahmed",
"author_email": "vikstal@chalmers.se",
"download_url": "https://files.pythonhosted.org/packages/d5/ce/9607798d3f90f8786acebd5ff7ab815aad23a25c1bf7357b87b783dfe012/chalmers_qubit-2.0.0.tar.gz",
"platform": null,
"description": "# chalmers-qubit\n\n[](https://github.com/aqp-mc2-chalmers/chalmers-qubit/actions/workflows/tests.yml) [](https://squidfunk.github.io/mkdocs-material/) [](https://opensource.org/licenses/BSD-3-Clause) <a href=\"https://pypi.org/project/chalmers-qubit/\"><img alt=\"PyPI - Python Version\" src=\"https://img.shields.io/pypi/pyversions/chalmers-qubit\"></a>\n\n\nA simulation framework for Chalmers devices that can be used to simulate the running of quantum algorithms with realistic noise. We follow [qutip-qip](https://qutip-qip.readthedocs.io/en/stable/) 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](https://qutip-qip.readthedocs.io/en/latest/apidoc/qutip_qip.noise.html#qutip_qip.noise.ZZCrossTalk).\n\nThe package is under development and testing. \n\n## Installation\n\nThe main requirement to use this package is [qutip-qip](https://qutip-qip.readthedocs.io/en/stable/) based on [qutip](https://qutip-qip.readthedocs.io/en/stable/): 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:\n\n``` zsh\npip install .\n```\n\nto 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.\n\n``` zsh\npip install -e '.[full]'\n```\n\nIf 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\n\n``` zsh\npip install git+https://github.com/aqp-mc2-chalmers/chalmers-qubit.git\n```\n\n## Usage\n\nThe usage of the package follows [qutip-qip](https://qutip-qip.readthedocs.io/en/stable/) where first, a quantum circuit is defined using [`qutip-qip`](https://qutip-qip.readthedocs.io/en/stable/qip-simulator.html) and then run on one of the custom Chalmers processors, e.g., the processor called sarimner. The custom processor is defined in `chalmers_qubit.sarimner.processor` and can be initialized with a `model`, `compiler` and `noise`. \n\nNote that only gates with compilation instructions in `chalmers_qubit/sarimner/compiler.py` will work for this particular processor.\n\nNotebooks exploring the usage of the simulator is available in `examples/`. \n\n``` python\nimport numpy as np\nfrom qutip import basis, tensor\nfrom qutip_qip.circuit import QubitCircuit\nfrom chalmers_qubit.sarimner import (\n SarimnerProcessor,\n SarimnerModel,\n SarimnerCompiler,\n DecoherenceNoise,\n ZZCrossTalk,\n)\n\n# Define a quantum circuit\nqc = QubitCircuit(2)\nqc.add_gate(\"RX\", targets=0, arg_value=np.pi / 2)\nqc.add_gate(\"RY\", targets=1, arg_value=np.pi / 2)\nqc.add_gate(\"CZ\", controls=0, targets=1)\n\n# All frequencies are defined in GHz, and times in ns.\ntransmon_dict = {\n 0: {\"frequency\": 5.0, \"anharmonicity\": -0.30},\n 1: {\"frequency\": 5.4, \"anharmonicity\": -0.30},\n}\ncoupling_dict = {\n (0, 1): 0.04,\n}\n# Construct model\nmodel = SarimnerModel(transmon_dict=transmon_dict,\n coupling_dict=coupling_dict)\n\n# Load a compiler\ncompiler = SarimnerCompiler(model=model)\n\n# Define all the noise objects as a list.\ndecoherence_dict = {\n 0: {\"t1\": 60e3, \"t2\": 80e3},\n 1: {\"t1\": 100e3, \"t2\": 105e3},\n}\ncross_talk_dict = {\n (0, 1): 1e-4,\n}\nnoise = [\n DecoherenceNoise(decoherence_dict=decoherence_dict),\n ZZCrossTalk(cross_talk_dict=cross_talk_dict),\n]\n\n# Initialize the processor\nprocessor = SarimnerProcessor(model=model, compiler=compiler, noise=noise)\n\n# Load the circuit that generates the pulses to run the simulation\ntlist, coeffs = processor.load_circuit(qc)\n\n# Initial state for the simulation.\n# The default assumptions is that each transmon is a qudit with 3 levels.\ninit_state = tensor(basis(3, 1), basis(3, 1))\n\n# Run master equation simulation\nresult = processor.run_state(init_state)\nprint(\"Final state\", result.states[-1])\n\n# Run the same circuit but with mcsolve using 100 trajectories.\nresult = processor.run_state(init_state, solver=\"mcsolve\", ntraj=100)\nprint(\"Final state\", result.states[-1])\n```\n\nIt is also possible to import [QASM circuits](https://nbviewer.org/urls/qutip.org/qutip-tutorials/tutorials-v5/quantum-circuits/qasm.ipynb).\n\n## Development\n\nIn order to add new custom pulses or modify the device, edit the processor, or compiler the tutorials and detailed instructions in [qutip-qip](https://qutip-qip.readthedocs.io/en/stable/).\n\nThe [tutorials](https://qutip.org/qutip-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.\n\n## Support\n\nThis package was built from contributions by Pontus Vikst\u00e5l, Kamanasish Debnath and Shahnawaz Ahmed.\n\nContact vikstal@chalmers.se, shahnawaz.ahmed95@gmail.com or anton.frisk.kockum@chalmers.se for help and support.\n",
"bugtrack_url": null,
"license": "BSD 3-Clause License",
"summary": "A simulator of the Chalmers device to be used with qutip-qip",
"version": "2.0.0",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "53942cb10f90deb5fa3a854ed657b8350b454ad96783abf9c6231be567b752b6",
"md5": "decb7c42833144042ff66effec0dfbf7",
"sha256": "8500a0bb5c00e391fad6cea553e3815b1ee21220783a73c2bb86e7ff042b856c"
},
"downloads": -1,
"filename": "chalmers_qubit-2.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "decb7c42833144042ff66effec0dfbf7",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 21961,
"upload_time": "2024-10-17T13:54:04",
"upload_time_iso_8601": "2024-10-17T13:54:04.202573Z",
"url": "https://files.pythonhosted.org/packages/53/94/2cb10f90deb5fa3a854ed657b8350b454ad96783abf9c6231be567b752b6/chalmers_qubit-2.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "d5ce9607798d3f90f8786acebd5ff7ab815aad23a25c1bf7357b87b783dfe012",
"md5": "a434536033d6e183b4f079e952d8fbd2",
"sha256": "4e0bd0f5b3487ec3ef976b75a20186279d0405f30a544106e4c0b3977567bd2f"
},
"downloads": -1,
"filename": "chalmers_qubit-2.0.0.tar.gz",
"has_sig": false,
"md5_digest": "a434536033d6e183b4f079e952d8fbd2",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 21257,
"upload_time": "2024-10-17T13:54:06",
"upload_time_iso_8601": "2024-10-17T13:54:06.445881Z",
"url": "https://files.pythonhosted.org/packages/d5/ce/9607798d3f90f8786acebd5ff7ab815aad23a25c1bf7357b87b783dfe012/chalmers_qubit-2.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-17 13:54:06",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "chalmers-qubit"
}