-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
T phi experiment #355
T phi experiment #355
Changes from 8 commits
ff5e9d7
c0f64c4
fef446b
1f2867c
8582ada
94a0408
5b742fd
68ad6f8
0c063b1
f0c0f84
1b328e7
8fa6dbb
fdea969
049a13f
9db05c0
12292de
f2b6e03
d0bc161
b1a0b9a
ea8e5f1
7c79f02
c7b8728
f79d8a3
026b5e8
151f337
b0f710d
b7395c5
1ff54e4
2e5422a
f970a68
28b9976
ca2ef67
e522c09
82f16f4
13262ce
719e697
6ebcd23
1124684
6170765
77c9ff2
3cafd78
28d9c32
0fd6120
9ecb257
9189c00
bdb4b9d
0f609a3
a37d38c
bcaacff
ccbba12
208e462
97ebb23
e129cf7
031019a
dc7dc50
e6d9ca1
188d220
71c70c4
aca48fc
e76c7f0
540a945
c69f716
993cde9
45284b2
23fbff3
714d19e
7080654
6dddddf
15602b8
cabd8d8
1d00174
9ebb855
5ab5b4c
0514857
a2e56c3
cff6af6
cb4fb0d
feb4342
d5fafc3
b52dd6f
42e0139
66333e8
b20d38b
bafdcc3
e6563ce
9db90d8
bdb0828
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"id": "bb7abc10", | ||
"metadata": { | ||
"scrolled": true | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"import qiskit\n", | ||
"from qiskit_experiments.library.characterization import Tphi" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"id": "65433519", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# set the computation units to microseconds\n", | ||
"unit = 'us' #microseconds\n", | ||
"qubit = 0\n", | ||
"# set the desired delays\n", | ||
"delays_t1 = list(range(1, 40, 3))\n", | ||
"delays_t2 = list(range(1, 50, 2))\n", | ||
"\n", | ||
"\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"id": "ba59e1ef", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"exp = Tphi(qubit=0, delays_t1=delays_t1, delays_t2=delays_t2, unit=\"s\", osc_freq=0.1)\n", | ||
" " | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"id": "c7154472", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
" ┌───┐┌─────────────┐┌─────────┐ ░ ┌───┐ ░ ┌─┐\n", | ||
"q_0: ┤ H ├┤ Delay(1[s]) ├┤ Rz(π/5) ├─░─┤ H ├─░─┤M├\n", | ||
" └───┘└─────────────┘└─────────┘ ░ └───┘ ░ └╥┘\n", | ||
"c: 1/═══════════════════════════════════════════╩═\n", | ||
" 0 \n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"print(exp._experiments[1].circuits()[0])" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 5, | ||
"id": "1d3c529a", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"2\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"print(exp.num_experiments)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 6, | ||
"id": "75b81403", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"backend = tphi_simulator\n", | ||
"t1_shots = 1024\n" | ||
] | ||
}, | ||
{ | ||
"ename": "AttributeError", | ||
"evalue": "'NoneType' object has no attribute 'job_id'", | ||
"output_type": "error", | ||
"traceback": [ | ||
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", | ||
"\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)", | ||
"\u001b[0;32m<ipython-input-6-4cbea993ed61>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0mbackend\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mTphiBackend\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mt1\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m10\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mt2ramsey\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m25\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mfreq\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m0.1\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdt_factor\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0;31m#print(backend)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 4\u001b[0;31m \u001b[0mexpdata\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mexp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrun\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mbackend\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mexperiment_data\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 5\u001b[0m \u001b[0;31m#print(expdata)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", | ||
"\u001b[0;32m~/work/t_phi/qiskit_experiments/library/characterization/tphi.py\u001b[0m in \u001b[0;36mrun\u001b[0;34m(self, backend, experiment_data, **run_options)\u001b[0m\n\u001b[1;32m 58\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 59\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mrun\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mbackend\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mexperiment_data\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mrun_options\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 60\u001b[0;31m \u001b[0mexpdata\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0msuper\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrun\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mbackend\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mshots\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m1000\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 61\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", | ||
"\u001b[0;32m~/work/t_phi/qiskit_experiments/framework/base_experiment.py\u001b[0m in \u001b[0;36mrun\u001b[0;34m(self, backend, analysis, experiment_data, **run_options)\u001b[0m\n\u001b[1;32m 139\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 140\u001b[0m \u001b[0;31m# Add experiment option metadata\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 141\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_add_job_metadata\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mexperiment_data\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mjob\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mrun_opts\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 142\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 143\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0manalysis\u001b[0m \u001b[0;32mand\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__analysis_class__\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", | ||
"\u001b[0;32m~/work/t_phi/qiskit_experiments/framework/composite/composite_experiment.py\u001b[0m in \u001b[0;36m_add_job_metadata\u001b[0;34m(self, experiment_data, job, **run_options)\u001b[0m\n\u001b[1;32m 70\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m_add_job_metadata\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mexperiment_data\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mjob\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mrun_options\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 71\u001b[0m \u001b[0;31m# Add composite metadata\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 72\u001b[0;31m \u001b[0msuper\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_add_job_metadata\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mexperiment_data\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mjob\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mrun_options\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 73\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 74\u001b[0m \u001b[0;31m# Add sub-experiment options\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", | ||
"\u001b[0;32m~/work/t_phi/qiskit_experiments/framework/base_experiment.py\u001b[0m in \u001b[0;36m_add_job_metadata\u001b[0;34m(self, experiment_data, job, **run_options)\u001b[0m\n\u001b[1;32m 375\u001b[0m \"\"\"\n\u001b[1;32m 376\u001b[0m metadata = {\n\u001b[0;32m--> 377\u001b[0;31m \u001b[0;34m\"job_id\"\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mjob\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mjob_id\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 378\u001b[0m \u001b[0;34m\"experiment_options\"\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mcopy\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcopy\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mexperiment_options\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__dict__\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 379\u001b[0m \u001b[0;34m\"transpile_options\"\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mcopy\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcopy\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtranspile_options\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__dict__\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", | ||
"\u001b[0;31mAttributeError\u001b[0m: 'NoneType' object has no attribute 'job_id'" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"\n", | ||
"from qiskit_experiments.test.tphi_backend import TphiBackend\n", | ||
"backend = TphiBackend(t1=10, t2ramsey=25, freq=0.1, dt_factor=1)\n", | ||
"#print(backend)\n", | ||
"expdata = exp.run(backend, experiment_data=None)\n", | ||
"#print(expdata)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "5f69ac24", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "17157f4c", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "f64045d7", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.8.10" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -111,7 +111,7 @@ def circuits(self, backend: Optional[Backend] = None) -> List[QuantumCircuit]: | |
circuits = [] | ||
|
||
for delay in self.experiment_options.delays: | ||
circ = QuantumCircuit(1, 1) | ||
circ = QuantumCircuit(1, 1, name="T1") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you ok with reverting this? I don't think we need it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was just for a sanity check. But if it bothers you, I can remove it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On second thought, let's discuss. |
||
circ.x(0) | ||
circ.barrier(0) | ||
circ.delay(delay, 0, self.experiment_options.unit) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# that they have been altered from the originals. | ||
""" | ||
Tphi Experiment class. | ||
""" | ||
|
||
from typing import List, Optional, Union | ||
import numpy as np | ||
from enum import Enum | ||
|
||
import qiskit | ||
from qiskit.providers import Backend | ||
from qiskit.circuit import QuantumCircuit | ||
from qiskit_experiments.framework import BaseExperiment | ||
from qiskit_experiments.framework.composite.batch_experiment import BatchExperiment | ||
from qiskit_experiments.library.characterization import T1, T2Ramsey | ||
from qiskit_experiments.library.characterization.tphi_analysis import TphiAnalysis | ||
|
||
class Tphi(BatchExperiment): | ||
"""Tphi Experiment Class""" | ||
|
||
__analysis_class__ = TphiAnalysis | ||
|
||
def __init__(self, | ||
qubit: int, | ||
delays_t1: List[Union[List[float], np.array]], | ||
delays_t2: List[Union[List[float], np.array]], | ||
unit: str = "s", | ||
osc_freq: float = 0.0, | ||
experiment_type: Optional[str] = None, | ||
): | ||
"""Initialize the experiments object. | ||
merav-aharoni marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Args: | ||
qubit: the qubit under test | ||
delays_t1: delay times of the T1 experiment | ||
delays_t2: delay times of the T2* experiment | ||
unit: Optional, time unit of `delays`. | ||
Supported units: 's', 'ms', 'us', 'ns', 'ps', 'dt'. | ||
The unit is used for both experiments | ||
osc_freq: the oscillation frequency induced using by the user for T2 | ||
experiment_type: String indicating the experiment type. | ||
|
||
merav-aharoni marked this conversation as resolved.
Show resolved
Hide resolved
|
||
""" | ||
#self._qubit = qubit | ||
self._delays_t1 = delays_t1 | ||
self._delays_t2 = delays_t2 | ||
self._unit = unit | ||
self._osc_freq = osc_freq | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use options |
||
|
||
expT1 = T1(qubit, self._delays_t1, self._unit) | ||
expT2 = T2Ramsey(qubit, self._delays_t2, self._unit, self._osc_freq) | ||
exps = [] | ||
exps.append(expT1) | ||
exps.append(expT2) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
# Run batch experiments | ||
merav-aharoni marked this conversation as resolved.
Show resolved
Hide resolved
|
||
batch_exp = super().__init__(exps) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The variable |
||
|
||
def run(self, backend, experiment_data, **run_options): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't override |
||
expdata = super().run(backend, shots=1000) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -108,7 +108,7 @@ def run(self, run_input, **options): | |
prob1[qubit] = 1 - prob1[qubit] | ||
elif op.name == "delay": | ||
delay = op.params[0] | ||
prob1[qubit] = prob1[qubit] * np.exp(-delay / self._t1[qubit]) | ||
prob1[qubit] = prob1[qubit] * np.exp(-delay / self._t1) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
elif op.name == "measure": | ||
meas_res = self._rng.binomial( | ||
1, prob1[qubit] * (1 - ro10[qubit]) + (1 - prob1[qubit]) * ro01[qubit] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't review the tutorial. Something's wrong with indent font. I'll review after it's fixed. Note that in Latex we're talking about
\varphi
and not\phi
.