Skip to content
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

Merged
merged 87 commits into from
Feb 8, 2022
Merged
Show file tree
Hide file tree
Changes from 51 commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
ff5e9d7
Beginning implementation of T_phi
merav-aharoni Jul 22, 2021
c0f64c4
Added init files
merav-aharoni Jul 30, 2021
fef446b
Built circuits for T_phi
merav-aharoni Aug 18, 2021
1f2867c
Merge branch 'main' into t_phi
merav-aharoni Aug 18, 2021
8582ada
Defined class T_phi
merav-aharoni Aug 18, 2021
94a0408
Added run method to class Tphi
merav-aharoni Sep 9, 2021
5b742fd
Merged with main
merav-aharoni Sep 9, 2021
68ad6f8
First stage of Tphi - up to run
merav-aharoni Sep 22, 2021
0c063b1
Merge with main
merav-aharoni Oct 6, 2021
f0c0f84
Merged with main
merav-aharoni Jan 6, 2022
1b328e7
Added test for Tphi. Added backend for testing, based on T1 and T2Ram…
merav-aharoni Jan 6, 2022
8fa6dbb
black
merav-aharoni Jan 6, 2022
fdea969
Merged with main
merav-aharoni Jan 6, 2022
049a13f
Fixed return FakeJob from TphiBackend.run
merav-aharoni Jan 13, 2022
9db05c0
Merge branch 'main' of github.com:merav-aharoni/qiskit-experiments in…
merav-aharoni Jan 13, 2022
12292de
Merge branch 'main' into t_phi
merav-aharoni Jan 16, 2022
f2b6e03
Merged with main
merav-aharoni Jan 16, 2022
d0bc161
Get sub-experiment analysis results from expdata.child_data
merav-aharoni Jan 16, 2022
b1a0b9a
Added _run_analysis for TphiAnalysis. Added parameter to BatchExperi…
merav-aharoni Jan 16, 2022
ea8e5f1
Cleaned up return value for Tphi analysis results. Computed the final…
merav-aharoni Jan 18, 2022
7c79f02
black and lint
merav-aharoni Jan 18, 2022
c7b8728
Removed usage of 'units' in Tphi. Added usage of set_experiment_optio…
merav-aharoni Jan 18, 2022
f79d8a3
Removed unnecessary variable 'unit' and unnecessary imports.
merav-aharoni Jan 18, 2022
026b5e8
Added missing 'TphiAnalysis in __init__
merav-aharoni Jan 18, 2022
151f337
Added documentation for Tphi
merav-aharoni Jan 19, 2022
b0f710d
Added 'analysis' parameter to BatchExperiment and to CompositeExperiment
merav-aharoni Jan 20, 2022
b7395c5
Added title and section to tphi tutorial
merav-aharoni Jan 20, 2022
1ff54e4
Merge branch 'main' into t_phi
merav-aharoni Jan 20, 2022
2e5422a
Fixed Tphi computation. Wrote tutorial. Added computation with uncert…
merav-aharoni Jan 20, 2022
f970a68
black and lint
merav-aharoni Jan 20, 2022
28b9976
Merge branch 'main' into t_phi
merav-aharoni Jan 20, 2022
ca2ef67
Fixed title of tutorial
merav-aharoni Jan 23, 2022
e522c09
Merge branch 't_phi' of github.com:merav-aharoni/qiskit-experiments i…
merav-aharoni Jan 23, 2022
82f16f4
Removed unnecessary prints and empty lines
merav-aharoni Jan 23, 2022
13262ce
Merge branch 'main' into t_phi
merav-aharoni Jan 23, 2022
719e697
lint and black
merav-aharoni Jan 23, 2022
6ebcd23
Merge branch 't_phi' of github.com:merav-aharoni/qiskit-experiments i…
merav-aharoni Jan 23, 2022
1124684
Change of parameter merged from main
merav-aharoni Jan 23, 2022
6170765
lint
merav-aharoni Jan 23, 2022
77c9ff2
Added references for Tphi
merav-aharoni Jan 23, 2022
3cafd78
Updated copyright to 2022. Added _set_backend to Tphi
merav-aharoni Jan 24, 2022
28d9c32
black and lint
merav-aharoni Jan 24, 2022
0fd6120
Merge branch 'main' into t_phi
merav-aharoni Jan 25, 2022
9ecb257
Bug fix: parameter 'backend' was missing in calls to T1 and T2Ramsey
merav-aharoni Jan 26, 2022
9189c00
Cleaned up Tphi tutorial
merav-aharoni Jan 26, 2022
bdb4b9d
Merge branch 't_phi' of github.com:merav-aharoni/qiskit-experiments i…
merav-aharoni Jan 26, 2022
0f609a3
black
merav-aharoni Jan 26, 2022
a37d38c
Removed dataProcessor from default_options because it was causing a w…
merav-aharoni Jan 26, 2022
bcaacff
Merge branch 'main' into t_phi
merav-aharoni Jan 27, 2022
ccbba12
black and lint
merav-aharoni Jan 27, 2022
208e462
Added release notes for tphi
merav-aharoni Jan 27, 2022
97ebb23
Syntax changes resulting from code review
merav-aharoni Jan 27, 2022
e129cf7
Update qiskit_experiments/library/characterization/tphi.py
merav-aharoni Jan 27, 2022
031019a
Update qiskit_experiments/library/characterization/tphi.py
merav-aharoni Jan 27, 2022
dc7dc50
Removed two unnecessary methods, and did some cleaning following sugg…
merav-aharoni Jan 27, 2022
e6d9ca1
Added class documentation. Removed overriding of shots
merav-aharoni Jan 27, 2022
188d220
Removed unnecessary parameter that I previously added to BatchExperi…
merav-aharoni Jan 27, 2022
71c70c4
Merge branch 't_phi' of github.com:merav-aharoni/qiskit-experiments i…
merav-aharoni Jan 27, 2022
aca48fc
Removed setting of shots in backend options. Changed 'block_for_resul…
merav-aharoni Jan 30, 2022
e76c7f0
Merge branch 'main' into t_phi
merav-aharoni Jan 30, 2022
540a945
black
merav-aharoni Jan 30, 2022
c69f716
Syntax changes in tutorial
merav-aharoni Jan 30, 2022
993cde9
black
merav-aharoni Jan 30, 2022
45284b2
Fixed problems in math font in tutorial text
merav-aharoni Jan 30, 2022
23fbff3
Syntax changes in tutorial
merav-aharoni Jan 30, 2022
714d19e
Improved documentation in tutorial and in TphiExperiment class
merav-aharoni Jan 30, 2022
7080654
Removed 'name' that was added previously to t1 and t2ramsey. Instead,…
merav-aharoni Jan 30, 2022
6dddddf
Fixed setting of default options in Tphi
merav-aharoni Jan 31, 2022
15602b8
Added links to classes in the release notes
merav-aharoni Jan 31, 2022
cabd8d8
Merged with main
merav-aharoni Jan 31, 2022
1d00174
Added info on the tphi experiment to the release notes
merav-aharoni Feb 1, 2022
9ebb855
Implemented a set_experiment_options for tphi, that sets the options …
merav-aharoni Feb 1, 2022
5ab5b4c
Added test to check that circtuis are modified correctly when using s…
merav-aharoni Feb 1, 2022
0514857
Merge branch 'main' into t_phi
merav-aharoni Feb 2, 2022
a2e56c3
Added component analysis classes to the constructor of TphiAnalysis()…
merav-aharoni Feb 3, 2022
cff6af6
Merge branch 'main' into t_phi
merav-aharoni Feb 3, 2022
cb4fb0d
black
merav-aharoni Feb 3, 2022
feb4342
Merge branch 't_phi' of github.com:merav-aharoni/qiskit-experiments i…
merav-aharoni Feb 3, 2022
d5fafc3
Merge branch 'main' into t_phi
merav-aharoni Feb 3, 2022
b52dd6f
Added setting of osc_freq to set_experiment_options. Added a respecti…
merav-aharoni Feb 3, 2022
42e0139
Merge branch 't_phi' of github.com:merav-aharoni/qiskit-experiments i…
merav-aharoni Feb 3, 2022
66333e8
Merge branch 'main' into t_phi
merav-aharoni Feb 6, 2022
b20d38b
Merge branch 'main' into t_phi
merav-aharoni Feb 6, 2022
bafdcc3
Changed variable name
merav-aharoni Feb 7, 2022
e6563ce
Merge branch 'main' into t_phi
merav-aharoni Feb 8, 2022
9db90d8
Added to tests 'assertExperimentDone'
merav-aharoni Feb 8, 2022
bdb0828
Merge branch 't_phi' of github.com:merav-aharoni/qiskit-experiments i…
merav-aharoni Feb 8, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 23 additions & 44 deletions docs/tutorials/t2ramsey_characterization.ipynb

Large diffs are not rendered by default.

242 changes: 242 additions & 0 deletions docs/tutorials/tphi_characterization.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,242 @@
{
Copy link
Collaborator

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.

"cells": [
{
"cell_type": "markdown",
"id": "d90cef84",
"metadata": {},
"source": [
"# $T_\\phi$ characterization"
]
},
{
"cell_type": "markdown",
"id": "16825eb1",
"metadata": {},
"source": [
"T is defined as by T_2* when removing the effect of T1, or more precisely:\n",
"$1/T_2* = 1/2T_1 + 1/T_\\phi.$\n",
"We therefore create a composite experiment consisting of a $T_1$ experiment and a $T_2* $ experiment. From the results of these two, we compute the results for T$_\\phi.$"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "bb7abc10",
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"import numpy as np\n",
"import qiskit\n",
"from qiskit_experiments.library.characterization import Tphi\n",
"from qiskit_experiments.library.characterization import TphiAnalysis"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "ba59e1ef",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"T1 for FakeVigo = 0.00012170801410836628\n",
"[1.00e-06 1.10e-05 2.10e-05 3.10e-05 4.10e-05 5.10e-05 6.10e-05 7.10e-05\n",
" 8.10e-05 9.10e-05 1.01e-04 1.11e-04 1.21e-04 1.31e-04 1.41e-04 1.51e-04\n",
" 1.61e-04 1.71e-04 1.81e-04 1.91e-04 2.01e-04 2.11e-04 2.21e-04 2.31e-04\n",
" 2.41e-04 2.51e-04 2.61e-04 2.71e-04 2.81e-04 2.91e-04 3.01e-04 3.11e-04\n",
" 3.21e-04 3.31e-04 3.41e-04 3.51e-04 3.61e-04]\n",
"[1e-06, 3e-06, 5e-06, 7.000000000000001e-06, 9.000000000000002e-06, 1.1000000000000003e-05, 1.3000000000000003e-05, 1.5000000000000002e-05, 1.7000000000000003e-05, 1.9000000000000004e-05, 2.1000000000000006e-05, 2.3000000000000003e-05, 2.5000000000000005e-05, 2.7000000000000006e-05, 2.9000000000000004e-05, 3.1e-05, 3.3e-05, 3.5000000000000004e-05, 3.7000000000000005e-05, 3.9000000000000006e-05, 4.100000000000001e-05, 4.3e-05, 4.5e-05, 4.7000000000000004e-05, 4.9000000000000005e-05]\n"
]
}
],
"source": [
"# An Aer simulator\n",
"from qiskit.test.mock import FakeVigo\n",
"from qiskit.providers.aer import AerSimulator\n",
"from qiskit.providers.aer.noise import NoiseModel\n",
"\n",
"# Create a pure relaxation noise model for AerSimulator\n",
"noise_model = NoiseModel.from_backend(\n",
" FakeVigo(), thermal_relaxation=True, gate_error=False, readout_error=False\n",
")\n",
"\n",
"# Create a fake backend simulator\n",
"backend = AerSimulator.from_backend(FakeVigo(), noise_model=noise_model)\n",
"\n",
"# Look up target T1 of qubit-0 from device properties\n",
"qubit0_t1 = backend.properties().t1(0)\n",
"print(\"T1 for FakeVigo = \" + str(qubit0_t1))\n",
"\n",
"# Time intervals to wait before measurement\n",
"delays_t1 = np.arange(1e-6, 3 * qubit0_t1, 1e-5)\n",
"print(delays_t1)\n",
"\n",
"# set the desired delays\n",
"delays_t2 = list(np.arange(1e-6, 50e-6, 2e-6))\n",
"print(delays_t2)\n",
"qubit = 0\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "c7154472",
"metadata": {
"scrolled": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"in t2ramsey _set_backend\n"
]
}
],
"source": [
"# Create an experiment for qubit 0 with the specified time intervals\n",
"exp = Tphi(qubit=0, delays_t1=delays_t1, delays_t2=delays_t2, osc_freq=1e5)\n",
"# Set scheduling method so circuit is scheduled for delay noise simulation\n",
"exp.set_transpile_options(scheduling_method='asap')\n",
"\n",
"expdata = exp.run(backend=backend, analysis=TphiAnalysis()).block_for_results()\n",
"result = expdata.analysis_results(\"T_phi\")"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "1d3c529a",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"DbAnalysisResultV1\n",
"- name: T_phi\n",
"- value: 1.1713979863091273e-05 ± 3.1442018893973085e-05\n",
"- quality: bad\n",
"- device_components: ['Q0']\n",
"- verified: False\n"
]
}
],
"source": [
"# Print the result for T_phi\n",
"print(result)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "75b81403",
"metadata": {
"scrolled": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"---------------------------------------------------\n",
"Experiment: Tphi\n",
"Experiment ID: 8c52fb0e-3ab3-47a9-8550-1a2d65e1438d\n",
"Child Experiment Data: 2\n",
"Status: ExperimentStatus.DONE\n",
"Backend: aer_simulator(fake_vigo)\n",
"Data: 62\n",
"Analysis Results: 1\n",
"Figures: 0\n"
]
}
],
"source": [
"# It is possible to see the results of the sub-experiments:\n",
"print(expdata)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "5f69ac24",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"DbAnalysisResultV1\n",
"- name: T1\n",
"- value: 0.00012318856580158585 ± 2.2075141225835903e-06 s\n",
"- χ²: 1.4066670765740719\n",
"- quality: good\n",
"- device_components: ['Q0']\n",
"- verified: False\n"
]
}
],
"source": [
"print(expdata.child_data(0).analysis_results(\"T1\"))"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "17157f4c",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"DbAnalysisResultV1\n",
"- name: T2star\n",
"- value: 1.1182317523178244e-05 ± 2.865266987893251e-05 s\n",
"- χ²: 1.0430271249496532\n",
"- quality: bad\n",
"- device_components: ['Q0']\n",
"- verified: False\n"
]
}
],
"source": [
"print(expdata.child_data(1).analysis_results(\"T2star\"))"
]
},
{
"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
}
2 changes: 1 addition & 1 deletion qiskit_experiments/database_service/db_experiment_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ def add_analysis_callback(self, callback: Callable, **kwargs: Any):
"""Add analysis callback for running after experiment data jobs are finished.

This method adds the `callback` function to a queue to be run
asynchronously after complition of any running jobs, or immediately
asynchronously after completion of any running jobs, or immediately
if no running jobs. If this method is called multiple times the
callback functions will be executed in the order they were
added.
Expand Down
2 changes: 1 addition & 1 deletion qiskit_experiments/framework/base_experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def __init__(
self.analysis = analysis_cls() # pylint: disable = not-callable

# Set backend
# This should be called last incase `_set_backend` access any of the
# This should be called last in case `_set_backend` access any of the
# attributes created during initialization
self._backend = None
if isinstance(backend, (Backend, BaseBackend)):
Expand Down
12 changes: 9 additions & 3 deletions qiskit_experiments/framework/composite/batch_experiment.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2021.
# (C) Copyright IBM 2021, 2022.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
Expand All @@ -19,6 +19,7 @@
from qiskit import QuantumCircuit
from qiskit.providers.backend import Backend
from .composite_experiment import CompositeExperiment, BaseExperiment
from .composite_analysis import CompositeAnalysis


class BatchExperiment(CompositeExperiment):
Expand All @@ -40,7 +41,12 @@ class BatchExperiment(CompositeExperiment):
documentation for additional information.
"""

def __init__(self, experiments: List[BaseExperiment], backend: Optional[Backend] = None):
def __init__(
self,
experiments: List[BaseExperiment],
analysis: Optional[CompositeAnalysis] = None,
backend: Optional[Backend] = None,
):
"""Initialize a batch experiment.

Args:
Expand All @@ -57,7 +63,7 @@ def __init__(self, experiments: List[BaseExperiment], backend: Optional[Backend]
self._qubit_map[physical_qubit] = logical_qubit
logical_qubit += 1
qubits = tuple(self._qubit_map.keys())
super().__init__(experiments, qubits, backend=backend)
super().__init__(experiments, qubits, analysis=analysis, backend=backend)

def circuits(self):

Expand Down
6 changes: 3 additions & 3 deletions qiskit_experiments/framework/composite/composite_analysis.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2021.
# (C) Copyright IBM 2021, 2022.
merav-aharoni marked this conversation as resolved.
Show resolved Hide resolved
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
Expand Down Expand Up @@ -34,7 +34,7 @@ class CompositeAnalysis(BaseAnalysis):

.. note::

The the child :class:`ExperimentData` for each component experiment
If the child :class:`ExperimentData` for each component experiment
does not already exist in the experiment data they will be initialized
and added to the experiment data when :meth:`run` is called on the
composite :class:`ExperimentData`.
Expand All @@ -47,7 +47,7 @@ class CompositeAnalysis(BaseAnalysis):

def _run_analysis(self, experiment_data: ExperimentData):
# Extract job metadata for the component experiments so it can be added
# to the child experiment data incase it is required by the child experiments
# to the child experiment data in case it is required by the child experiments
# analysis classes
composite_exp = experiment_data.experiment
component_exps = composite_exp.component_experiment()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2021.
# (C) Copyright IBM 2021, 2022.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
Expand Down Expand Up @@ -28,6 +28,7 @@ def __init__(
self,
experiments: List[BaseExperiment],
qubits: Sequence[int],
analysis: Optional[CompositeAnalysis] = None,
backend: Optional[Backend] = None,
experiment_type: Optional[str] = None,
):
Expand All @@ -41,9 +42,10 @@ def __init__(
"""
self._experiments = experiments
self._num_experiments = len(experiments)
analysis = CompositeAnalysis() if analysis is None else analysis
super().__init__(
qubits,
analysis=CompositeAnalysis(),
analysis=analysis,
backend=backend,
experiment_type=experiment_type,
)
Expand Down
2 changes: 2 additions & 0 deletions qiskit_experiments/library/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@

~characterization.T1
~characterization.T2Ramsey
~characterization.Tphi
~characterization.QubitSpectroscopy
~characterization.EFSpectroscopy
~characterization.CrossResonanceHamiltonian
Expand Down Expand Up @@ -121,6 +122,7 @@ class instance to manage parameters and pulse schedules.
from .characterization import (
T1,
T2Ramsey,
Tphi,
QubitSpectroscopy,
EFSpectroscopy,
CrossResonanceHamiltonian,
Expand Down
Loading