qutritium 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- qutritium-0.0.1/LICENSE.txt +20 -0
- qutritium-0.0.1/PKG-INFO +74 -0
- qutritium-0.0.1/README.md +56 -0
- qutritium-0.0.1/pyproject.toml +3 -0
- qutritium-0.0.1/setup.cfg +29 -0
- qutritium-0.0.1/setup.py +28 -0
- qutritium-0.0.1/src/backend/__init__.py +0 -0
- qutritium-0.0.1/src/backend/backend_ibm.py +131 -0
- qutritium-0.0.1/src/benchmarking/__init__.py +0 -0
- qutritium-0.0.1/src/calibration/__init__.py +22 -0
- qutritium-0.0.1/src/calibration/discriminator.py +178 -0
- qutritium-0.0.1/src/calibration/drag.py +253 -0
- qutritium-0.0.1/src/calibration/fine_tune.py +148 -0
- qutritium-0.0.1/src/calibration/rough_rabi.py +341 -0
- qutritium-0.0.1/src/calibration/transmission_reflection.py +351 -0
- qutritium-0.0.1/src/calibration/utility.py +114 -0
- qutritium-0.0.1/src/characterization/__init__.py +0 -0
- qutritium-0.0.1/src/clifford/__init__.py +0 -0
- qutritium-0.0.1/src/decomposition/__init__.py +0 -0
- qutritium-0.0.1/src/decomposition/transpilation.py +403 -0
- qutritium-0.0.1/src/exceptions/__init__.py +0 -0
- qutritium-0.0.1/src/exceptions/pulse_exception.py +16 -0
- qutritium-0.0.1/src/quantumcircuit/QC.py +173 -0
- qutritium-0.0.1/src/quantumcircuit/__init__.py +3 -0
- qutritium-0.0.1/src/quantumcircuit/instruction_structure.py +169 -0
- qutritium-0.0.1/src/quantumcircuit/qc_elementary_matrices.py +180 -0
- qutritium-0.0.1/src/quantumcircuit/qc_utility.py +242 -0
- qutritium-0.0.1/src/qutritium.egg-info/PKG-INFO +74 -0
- qutritium-0.0.1/src/qutritium.egg-info/SOURCES.txt +34 -0
- qutritium-0.0.1/src/qutritium.egg-info/dependency_links.txt +1 -0
- qutritium-0.0.1/src/qutritium.egg-info/top_level.txt +10 -0
- qutritium-0.0.1/src/tomography/Qutrit_tomo.py +93 -0
- qutritium-0.0.1/src/tomography/__init__.py +0 -0
- qutritium-0.0.1/src/vm_backend/QASM_backend.py +190 -0
- qutritium-0.0.1/src/vm_backend/__init__.py +1 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2023 SON PHAM and TIEN NGUYEN
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
qutritium-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: qutritium
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Qutritium package provides basic calibration and features for qutrit system using Qiskit and other quantum packages
|
|
5
|
+
Home-page: https://github.com/spham1611/qutritium
|
|
6
|
+
Author: Son Pham, Tien Nguyen, Bao Bach
|
|
7
|
+
Author-email: reachphamhson@gmail.com
|
|
8
|
+
License: MIT License
|
|
9
|
+
Project-URL: Bug Tracker, https://github.com/spham1611/qutritium/~/issues
|
|
10
|
+
Project-URL: repository, https://github.com/spham1611/qutritium
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Topic :: Utilities
|
|
15
|
+
Requires-Python: >=3.6
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
License-File: LICENSE.txt
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
<div align="center">
|
|
22
|
+
<img src="project_images/csm_ritsch_slider_796236face.jpg" width=150%>
|
|
23
|
+
|
|
24
|
+
<div style="color: aquamarine" href="https://www.oeaw.ac.at/detail/news/qutrit-complex-quantum-teleportation-achieved-for-the-first-time-1"><b>IMAGE REFERENCE</b></div>
|
|
25
|
+
|
|
26
|
+
[](https://unitary.fund)
|
|
27
|
+
# Qutritium
|
|
28
|
+
</div>
|
|
29
|
+
|
|
30
|
+
## What is Qutritium?
|
|
31
|
+
It is a Python package that provides qutrit processing techniques such as calibration and decomposition, etc (not exclusive).
|
|
32
|
+
|
|
33
|
+
Qutritium enables students researchers to run a qutrit system on available quantum computers which mainly comes from IBM cloud quantum computers.
|
|
34
|
+
|
|
35
|
+
## 📦 Installation
|
|
36
|
+
|
|
37
|
+
**Qutritium** runs in python environment. User can download newest python released **[here](https://www.python.org/downloads/)**.\
|
|
38
|
+
Recommendation: **[Anaconda](https://www.anaconda.com/products/distribution)** for environment separation
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
pip install qutritium
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## ✅ Qutritium Available Functions
|
|
45
|
+
|
|
46
|
+
| Protocol | Purpose and functionalities |
|
|
47
|
+
|-----------------|-----------------------------|
|
|
48
|
+
| Calibration | ... |
|
|
49
|
+
| Virtual Machine | ... |
|
|
50
|
+
| Decomposition | ... |
|
|
51
|
+
|
|
52
|
+
## ✍️ Usage/Examples
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
from qutritium.calibration import TR01
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## 👥 Authors
|
|
60
|
+
|
|
61
|
+
- **[Son Pham](https://github.com/spham1611)**
|
|
62
|
+
- **[Tien Nguyen](https://github.com/ngdnhtien)**
|
|
63
|
+
- **[Bao Bach](https://github.com/bachbao)**
|
|
64
|
+
|
|
65
|
+
## 🧾License
|
|
66
|
+
|
|
67
|
+
[MIT License](LICENSE.txt)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
## 📌 Documentation
|
|
71
|
+
|
|
72
|
+
[Documentation](https://spham1611.github.io/qutritium/)
|
|
73
|
+
|
|
74
|
+
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
<div align="center">
|
|
4
|
+
<img src="project_images/csm_ritsch_slider_796236face.jpg" width=150%>
|
|
5
|
+
|
|
6
|
+
<div style="color: aquamarine" href="https://www.oeaw.ac.at/detail/news/qutrit-complex-quantum-teleportation-achieved-for-the-first-time-1"><b>IMAGE REFERENCE</b></div>
|
|
7
|
+
|
|
8
|
+
[](https://unitary.fund)
|
|
9
|
+
# Qutritium
|
|
10
|
+
</div>
|
|
11
|
+
|
|
12
|
+
## What is Qutritium?
|
|
13
|
+
It is a Python package that provides qutrit processing techniques such as calibration and decomposition, etc (not exclusive).
|
|
14
|
+
|
|
15
|
+
Qutritium enables students researchers to run a qutrit system on available quantum computers which mainly comes from IBM cloud quantum computers.
|
|
16
|
+
|
|
17
|
+
## 📦 Installation
|
|
18
|
+
|
|
19
|
+
**Qutritium** runs in python environment. User can download newest python released **[here](https://www.python.org/downloads/)**.\
|
|
20
|
+
Recommendation: **[Anaconda](https://www.anaconda.com/products/distribution)** for environment separation
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pip install qutritium
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## ✅ Qutritium Available Functions
|
|
27
|
+
|
|
28
|
+
| Protocol | Purpose and functionalities |
|
|
29
|
+
|-----------------|-----------------------------|
|
|
30
|
+
| Calibration | ... |
|
|
31
|
+
| Virtual Machine | ... |
|
|
32
|
+
| Decomposition | ... |
|
|
33
|
+
|
|
34
|
+
## ✍️ Usage/Examples
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
from qutritium.calibration import TR01
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## 👥 Authors
|
|
42
|
+
|
|
43
|
+
- **[Son Pham](https://github.com/spham1611)**
|
|
44
|
+
- **[Tien Nguyen](https://github.com/ngdnhtien)**
|
|
45
|
+
- **[Bao Bach](https://github.com/bachbao)**
|
|
46
|
+
|
|
47
|
+
## 🧾License
|
|
48
|
+
|
|
49
|
+
[MIT License](LICENSE.txt)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
## 📌 Documentation
|
|
53
|
+
|
|
54
|
+
[Documentation](https://spham1611.github.io/qutritium/)
|
|
55
|
+
|
|
56
|
+
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
[metadata]
|
|
2
|
+
name = qutritium
|
|
3
|
+
version = 0.0.1
|
|
4
|
+
author = Son Pham, Tien Nguyen
|
|
5
|
+
description = Qutritium package provides basic calibration and features for qutrit system using Qiskit and other quantum packages
|
|
6
|
+
long_description = file: README.md, LICENSE.txt
|
|
7
|
+
long_description_content_type = text/markdown
|
|
8
|
+
url = https://github.com/spham1611/qutritium
|
|
9
|
+
project_urls =
|
|
10
|
+
Bug Tracker = https://github.com/spham1611/qutritium/~/issues
|
|
11
|
+
repository = https://github.com/spham1611/qutritium
|
|
12
|
+
classifiers =
|
|
13
|
+
Programming Language :: Python :: 3
|
|
14
|
+
License :: OSI Approved :: MIT License
|
|
15
|
+
Operating System :: OS Independent
|
|
16
|
+
|
|
17
|
+
[options]
|
|
18
|
+
package_dir =
|
|
19
|
+
= src
|
|
20
|
+
packages = find:
|
|
21
|
+
python_requires = >=3.6
|
|
22
|
+
|
|
23
|
+
[options.packages.find]
|
|
24
|
+
where = src
|
|
25
|
+
|
|
26
|
+
[egg_info]
|
|
27
|
+
tag_build =
|
|
28
|
+
tag_date = 0
|
|
29
|
+
|
qutritium-0.0.1/setup.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
from setuptools import setup, find_packages
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
with open("README.md", "r", encoding="utf-8") as fh:
|
|
5
|
+
long_description = fh.read()
|
|
6
|
+
|
|
7
|
+
setup(
|
|
8
|
+
name="qutritium",
|
|
9
|
+
version="0.0.1",
|
|
10
|
+
author="Son Pham, Tien Nguyen, Bao Bach",
|
|
11
|
+
author_email="reachphamhson@gmail.com",
|
|
12
|
+
description="Qutritium package provides basic calibration and features for qutrit system using Qiskit and other "
|
|
13
|
+
"quantum packages",
|
|
14
|
+
long_description=long_description,
|
|
15
|
+
long_description_content_type="text/markdown",
|
|
16
|
+
license='MIT License',
|
|
17
|
+
url="https://github.com/spham1611/qutritium",
|
|
18
|
+
classifiers=[
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"License :: OSI Approved :: MIT License",
|
|
21
|
+
"Operating System :: OS Independent",
|
|
22
|
+
"Topic :: Utilities",
|
|
23
|
+
],
|
|
24
|
+
package_dir={"": "src"},
|
|
25
|
+
packages=find_packages(where="src"),
|
|
26
|
+
python_requires=">=3.6"
|
|
27
|
+
)
|
|
28
|
+
|
|
File without changes
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# MIT License
|
|
2
|
+
#
|
|
3
|
+
# Copyright (c) [2023] [son pham, tien nguyen, bach bao]
|
|
4
|
+
#
|
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
# furnished to do so, subject to the following conditions:
|
|
11
|
+
#
|
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
# copies or substantial portions of the Software.
|
|
14
|
+
#
|
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
# SOFTWARE.
|
|
22
|
+
|
|
23
|
+
"""List all the available backends and assign their empirically effective qubit"""
|
|
24
|
+
from qiskit_ibm_provider import IBMProvider, IBMBackend
|
|
25
|
+
|
|
26
|
+
from src.constant import QubitParameters
|
|
27
|
+
|
|
28
|
+
from typing import DefaultDict, Tuple, Optional
|
|
29
|
+
|
|
30
|
+
from collections import defaultdict
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def set_qubit_dict() -> DefaultDict:
|
|
34
|
+
""" Set initiated qubit for each ibm quantum computers
|
|
35
|
+
Returns:
|
|
36
|
+
Dictionary that has the following format
|
|
37
|
+
=============== ===============
|
|
38
|
+
IBMBackend Name Effective Qubit
|
|
39
|
+
'ibm_brisbane' 0
|
|
40
|
+
=============== ===============
|
|
41
|
+
"""
|
|
42
|
+
return defaultdict(lambda: 0)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class CustomProvider(IBMProvider):
|
|
46
|
+
""" Customize IBMProvider
|
|
47
|
+
An example of this flow::
|
|
48
|
+
|
|
49
|
+
from qutritium.backend.backend_ibm import EffProvider
|
|
50
|
+
|
|
51
|
+
eff_provider = EffProvider()
|
|
52
|
+
backend, _ = eff_provider.backend('ibmq_lima')
|
|
53
|
+
|
|
54
|
+
eff_provider.show()
|
|
55
|
+
|
|
56
|
+
Notes:
|
|
57
|
+
* This class inherits IBMProvider so the docs is analogous to IBMProvider.
|
|
58
|
+
|
|
59
|
+
Here is a list of available attributes in class "EffProvider" class, besides IBMProvider attrs:
|
|
60
|
+
* eff_dict: a dictionary that contains effective qubit number of respective quantum computer
|
|
61
|
+
* backend(): return the wanted backend and its parameters
|
|
62
|
+
* show(): print all available backends
|
|
63
|
+
"""
|
|
64
|
+
|
|
65
|
+
def __init__(
|
|
66
|
+
self,
|
|
67
|
+
token: Optional[str] = None,
|
|
68
|
+
url: Optional[str] = None,
|
|
69
|
+
name: Optional[str] = None,
|
|
70
|
+
instance: Optional[str] = None,
|
|
71
|
+
proxies: Optional[dict] = None,
|
|
72
|
+
verify: Optional[bool] = None,
|
|
73
|
+
custom_dict: Optional[DefaultDict] = None,
|
|
74
|
+
) -> None:
|
|
75
|
+
""" Refer to the IBMProvider doc
|
|
76
|
+
Args:
|
|
77
|
+
token:
|
|
78
|
+
url:
|
|
79
|
+
name:
|
|
80
|
+
instance:
|
|
81
|
+
proxies:
|
|
82
|
+
verify:
|
|
83
|
+
custom_dict: Dictionary contains name of the backend and their effective qubits. For example:
|
|
84
|
+
dict_eff = {'ibmq_lima': 2,
|
|
85
|
+
'ibm_nairobi': 6,}
|
|
86
|
+
|
|
87
|
+
Returns:
|
|
88
|
+
An instance of EffBackends
|
|
89
|
+
"""
|
|
90
|
+
super().__init__(token, url, name, instance, proxies, verify)
|
|
91
|
+
if not self.active_account():
|
|
92
|
+
raise ValueError('Can not find account saved on disk. Please provide token via constructor'
|
|
93
|
+
', or save_account() function')
|
|
94
|
+
self.custom_dict: DefaultDict[str, int] = custom_dict if custom_dict else set_qubit_dict()
|
|
95
|
+
|
|
96
|
+
def retrieve_backend_info(self, name: str) -> Tuple[IBMBackend, DefaultDict]:
|
|
97
|
+
"""
|
|
98
|
+
|
|
99
|
+
Args:
|
|
100
|
+
name: name of the quantum computer which appears on API
|
|
101
|
+
|
|
102
|
+
Returns:
|
|
103
|
+
Tuple: IBMBackend and its parameters
|
|
104
|
+
|
|
105
|
+
"""
|
|
106
|
+
backend = self.backends(name=name)[0]
|
|
107
|
+
default_freq = backend.defaults().qubit_freq_est[self.custom_dict[name]]
|
|
108
|
+
anharmonicity = backend.properties().qubits[self.custom_dict[name]][3].value * QubitParameters.GHZ.value
|
|
109
|
+
backend_params = defaultdict(lambda: 0,
|
|
110
|
+
{'effective_qubit': self.custom_dict[name],
|
|
111
|
+
'drive_frequency': default_freq,
|
|
112
|
+
'anharmonicity': anharmonicity})
|
|
113
|
+
# from src.simple_backend_log import write_log
|
|
114
|
+
#
|
|
115
|
+
# write_log(backend)
|
|
116
|
+
return backend, backend_params
|
|
117
|
+
|
|
118
|
+
def show(self) -> None:
|
|
119
|
+
"""
|
|
120
|
+
Show all available backends based on given provider
|
|
121
|
+
"""
|
|
122
|
+
print(f"{'Backend name:':<30}{'# Qubit used:':<40}")
|
|
123
|
+
for available_backend in self.backends():
|
|
124
|
+
name = available_backend.name
|
|
125
|
+
print(f"{name:<30}{self.custom_dict[name]:<40}")
|
|
126
|
+
|
|
127
|
+
def qubit_optimization(self):
|
|
128
|
+
...
|
|
129
|
+
|
|
130
|
+
def customize_qubit(self):
|
|
131
|
+
...
|
|
File without changes
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# MIT License
|
|
2
|
+
#
|
|
3
|
+
# Copyright (c) [2023] [son pham, tien nguyen, bach bao]
|
|
4
|
+
#
|
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
# furnished to do so, subject to the following conditions:
|
|
11
|
+
#
|
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
# copies or substantial portions of the Software.
|
|
14
|
+
#
|
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
# SOFTWARE.
|
|
22
|
+
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
# MIT License
|
|
2
|
+
#
|
|
3
|
+
# Copyright (c) [2023] [son pham, tien nguyen, bach bao]
|
|
4
|
+
#
|
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
# furnished to do so, subject to the following conditions:
|
|
11
|
+
#
|
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
# copies or substantial portions of the Software.
|
|
14
|
+
#
|
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
# SOFTWARE.
|
|
22
|
+
|
|
23
|
+
""" Discriminator circuit and iq plot function """
|
|
24
|
+
from qiskit.circuit import Gate
|
|
25
|
+
|
|
26
|
+
from src.pulse import Pulse12
|
|
27
|
+
from src.pulse_creation import GateSchedule
|
|
28
|
+
from src.backend.backend_ibm import CustomProvider
|
|
29
|
+
from src.calibration.utility import _SetAttribute
|
|
30
|
+
from src.constant import QubitParameters
|
|
31
|
+
|
|
32
|
+
from typing import List
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
ghz_unit = QubitParameters.GHZ.value
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class DiscriminatorQutrit(_SetAttribute):
|
|
39
|
+
""" A Simple Discriminator class that set up circuit and plot the iq graph
|
|
40
|
+
An example of using this class::
|
|
41
|
+
|
|
42
|
+
from qutritium.calibration.discriminator import Discriminator
|
|
43
|
+
from qutritium.backend.backend_ibm import EffProvider
|
|
44
|
+
from qutritium.pulse import Pulse01, Pulse12
|
|
45
|
+
|
|
46
|
+
efF_provider = EffProvider()
|
|
47
|
+
pulse01 = Pulse01(duration=144, x_amp=0.2)
|
|
48
|
+
pulse12 = Pulse12(pulse01=pulse01, duration=pulse01.duration, x_amp=pulse01.x_amp)
|
|
49
|
+
|
|
50
|
+
...Running Rough Rabi
|
|
51
|
+
|
|
52
|
+
discriminator = Discriminator(eff_provider, pulse12, num_shots=4096)
|
|
53
|
+
discriminator.prepare_circuit()
|
|
54
|
+
discriminator.run_monitor()
|
|
55
|
+
discriminator.plot_iq()
|
|
56
|
+
|
|
57
|
+
Here is a list of available attributes of "DiscriminatorQutrit" class:
|
|
58
|
+
* prepare_circuit(): prepares a discriminator with different QuantumCircuits
|
|
59
|
+
* run_monitor(): run custom execute
|
|
60
|
+
* plot_iq(): plot iq 012 graph
|
|
61
|
+
|
|
62
|
+
To see more details, visit:
|
|
63
|
+
...
|
|
64
|
+
"""
|
|
65
|
+
def __init__(self,
|
|
66
|
+
custom_provider: CustomProvider,
|
|
67
|
+
pulse_model: Pulse12,
|
|
68
|
+
backend_name: str = 'ibm_brisbane',
|
|
69
|
+
num_shots=4096,
|
|
70
|
+
delay_time: int = 22496) -> None:
|
|
71
|
+
""" ctor
|
|
72
|
+
|
|
73
|
+
Args:
|
|
74
|
+
custom_provider: EffProvider instance which contains necessary information
|
|
75
|
+
pulse_model: Pulse12 model only
|
|
76
|
+
backend_name: name to choose which backend running on IBM server
|
|
77
|
+
num_shots: number of experiments
|
|
78
|
+
delay_time: sending a time delay pulse
|
|
79
|
+
|
|
80
|
+
Notes:
|
|
81
|
+
* model_space parameter is not necessary as we are discriminating states not processing
|
|
82
|
+
"""
|
|
83
|
+
super().__init__(custom_provider=custom_provider,
|
|
84
|
+
pulse_model=pulse_model,
|
|
85
|
+
backend_name=backend_name,
|
|
86
|
+
num_shots=num_shots,
|
|
87
|
+
model_space='01')
|
|
88
|
+
self.ramsey_frequency01 = self.pulse_model.pulse01.frequency
|
|
89
|
+
self.ramsey_frequency12 = self.pulse_model.frequency
|
|
90
|
+
self._delay_gate = Gate('5mus_delay', 1, [])
|
|
91
|
+
self._x12 = Gate('X12', 1, [])
|
|
92
|
+
|
|
93
|
+
# Schedules
|
|
94
|
+
self._delay_schedule = GateSchedule.delay(backend=self.backend,
|
|
95
|
+
qubit=self.qubit,
|
|
96
|
+
delay_time=delay_time)
|
|
97
|
+
|
|
98
|
+
self._x12_schedule = GateSchedule.x_amp_gaussian(backend=self.backend,
|
|
99
|
+
qubit=self.qubit,
|
|
100
|
+
pulse_model=self.pulse_model,
|
|
101
|
+
x_amp=self.pulse_model.x_amp)
|
|
102
|
+
|
|
103
|
+
# Package
|
|
104
|
+
self.package: List = []
|
|
105
|
+
|
|
106
|
+
def prepare_circuit(self) -> None:
|
|
107
|
+
"""
|
|
108
|
+
Creating a circuit that can represent a single qutrit state in IBM superconducting quantum computer.
|
|
109
|
+
This helps us to visualize qutrit state with calibrated parameters.
|
|
110
|
+
"""
|
|
111
|
+
from qiskit import QuantumCircuit
|
|
112
|
+
|
|
113
|
+
ground_state_prep = QuantumCircuit(self.qubit + 1, self.cbit + 1)
|
|
114
|
+
ground_state_prep.append(self._delay_gate, [self.qubit])
|
|
115
|
+
ground_state_prep.add_calibration(self._delay_gate, [self.qubit], self._delay_schedule)
|
|
116
|
+
# noinspection DuplicatedCode
|
|
117
|
+
ground_state_prep.measure(self.qubit, self.cbit)
|
|
118
|
+
|
|
119
|
+
first_excited_state_prep = QuantumCircuit(self.qubit + 1, self.cbit + 1)
|
|
120
|
+
first_excited_state_prep.append(self._delay_gate, [self.qubit])
|
|
121
|
+
first_excited_state_prep.add_calibration(self._delay_gate, [self.qubit], self._delay_schedule)
|
|
122
|
+
first_excited_state_prep.x(self.qubit)
|
|
123
|
+
# noinspection DuplicatedCode
|
|
124
|
+
first_excited_state_prep.measure(self.qubit, self.cbit)
|
|
125
|
+
|
|
126
|
+
second_excited_state_prep = QuantumCircuit(self.qubit + 1, self.cbit + 1)
|
|
127
|
+
second_excited_state_prep.append(self._delay_gate, [self.qubit])
|
|
128
|
+
second_excited_state_prep.add_calibration(self._delay_gate, [self.qubit], self._delay_schedule)
|
|
129
|
+
second_excited_state_prep.x(self.qubit)
|
|
130
|
+
second_excited_state_prep.append(self._x12, [self.qubit])
|
|
131
|
+
second_excited_state_prep.add_calibration(self._x12, [self.qubit], self._x12_schedule)
|
|
132
|
+
second_excited_state_prep.measure(self.qubit, self.cbit)
|
|
133
|
+
|
|
134
|
+
self.package = [ground_state_prep, first_excited_state_prep, second_excited_state_prep]
|
|
135
|
+
|
|
136
|
+
# noinspection DuplicatedCode
|
|
137
|
+
def run_monitor(self,
|
|
138
|
+
num_shots: int = 4096,
|
|
139
|
+
meas_return='single',
|
|
140
|
+
meas_level=1,
|
|
141
|
+
**kwargs) -> None:
|
|
142
|
+
"""
|
|
143
|
+
Run via run_monitor in abstract class
|
|
144
|
+
Args:
|
|
145
|
+
num_shots:
|
|
146
|
+
meas_return:
|
|
147
|
+
meas_level:
|
|
148
|
+
**kwargs:
|
|
149
|
+
|
|
150
|
+
Returns:
|
|
151
|
+
|
|
152
|
+
"""
|
|
153
|
+
super().backend.run(num_shots=num_shots,
|
|
154
|
+
meas_return=meas_return,
|
|
155
|
+
meas_level=meas_level,
|
|
156
|
+
**kwargs)
|
|
157
|
+
|
|
158
|
+
def plot_iq(self,
|
|
159
|
+
x_min: int = -30,
|
|
160
|
+
x_max: int = 30,
|
|
161
|
+
y_min: int = -30,
|
|
162
|
+
y_max: int = 30) -> None:
|
|
163
|
+
""" Plot iq qutrit state
|
|
164
|
+
|
|
165
|
+
Args:
|
|
166
|
+
x_min: Min x-value of the plot
|
|
167
|
+
x_max: Max x-value of the plot
|
|
168
|
+
y_min: Min y-value of the plot
|
|
169
|
+
y_max: Max y-value of the plot
|
|
170
|
+
"""
|
|
171
|
+
import matplotlib.pyplot as plt
|
|
172
|
+
from src.analyzer import DataAnalysis
|
|
173
|
+
|
|
174
|
+
discriminator_job = self.backend.retrieve_job(self.submitted_job)
|
|
175
|
+
discriminator_data = DataAnalysis(discriminator_job)
|
|
176
|
+
discriminator_data.retrieve_data(True)
|
|
177
|
+
discriminator_data.iq_012_plot(x_min, x_max, y_min, y_max)
|
|
178
|
+
plt.savefig('output/0 1 2 Discrimination.svg', format='svg', dpi=1200)
|