-
Notifications
You must be signed in to change notification settings - Fork 131
HEAT experiments #625
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
base: main
Are you sure you want to change the base?
HEAT experiments #625
Changes from 6 commits
7b2bfc1
fccf94c
6e64321
49a7845
b766f56
d32444f
c0e0da5
423dad4
8adcca2
942e558
4f70f6e
9cc247f
e8a11f7
00a991a
7c49da1
4a3c645
ca871ac
8ced3c2
52a1439
42f0768
0cec011
16fb9ea
6175036
532f855
e379b49
c7318b8
9a59715
ef8c56c
30f9200
c4333fb
6524858
cf47445
077d217
a773faa
9819c16
678af55
1ceff09
e540446
e103640
d918470
280cae1
4f7cd81
5c40d7d
4882e9e
a62cc8f
5d4945e
c908105
6c1a556
995a009
caf945a
c400186
aba80ca
fec3997
1e21e36
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 |
|---|---|---|
|
|
@@ -30,3 +30,4 @@ Experiment Modules | |
| mod_randomized_benchmarking | ||
| mod_tomography | ||
| mod_quantum_volume | ||
| mod_hamiltonian | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| .. _qiskit-experiments-hamiltonian: | ||
|
|
||
| .. automodule:: qiskit_experiments.library.hamiltonian | ||
| :no-members: | ||
| :no-inherited-members: | ||
| :no-special-members: |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| # This code is part of Qiskit. | ||
| # | ||
| # (C) Copyright IBM 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 | ||
| # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. | ||
| # | ||
| # Any modifications or derivative works of this code must retain this | ||
| # copyright notice, and modified files need to carry a notice indicating | ||
| # that they have been altered from the originals. | ||
| """ | ||
| =============================================================================================== | ||
| Hamiltonian Characterization Experiments (:mod:`qiskit_experiments.library.hamiltonian`) | ||
| =============================================================================================== | ||
|
|
||
| .. currentmodule:: qiskit_experiments.library.hamiltonian | ||
|
|
||
| This module provides a set of experiments to characterize Hamiltonian level | ||
| properties of qubits or control sequences. | ||
nkanazawa1989 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| HEAT Experiments | ||
| ================ | ||
|
|
||
| HEAT stands for `Hamiltonian Error Amplifying Tomography` which amplifies the | ||
| dynamics of entangler along the interrogated axis on the target qubit with | ||
| the conventional error amplification (ping-pong) technique. | ||
nkanazawa1989 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| These are the base experiment classes for developer to write own experiments. | ||
nkanazawa1989 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| .. autosummary:: | ||
| :toctree: ../stubs/ | ||
| :template: autosummary/experiment.rst | ||
|
|
||
| HeatElement | ||
| BatchHeatHelper | ||
|
|
||
| HEAT for ZX Hamiltonian | ||
| ----------------------- | ||
eggerdj marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| .. autosummary:: | ||
| :toctree: ../stubs/ | ||
| :template: autosummary/experiment.rst | ||
|
|
||
| ZXHeat | ||
| ZX90HeatXError | ||
| ZX90HeatYError | ||
| ZX90HeatZError | ||
|
|
||
| HEAT Analysis | ||
| ------------- | ||
|
|
||
| .. autosummary:: | ||
| :toctree: ../stubs/ | ||
| :template: autosummary/analysis.rst | ||
|
|
||
| HeatElementAnalysis | ||
| HeatAnalysis | ||
|
|
||
| """ | ||
|
|
||
| from .heat_base import HeatElement, BatchHeatHelper | ||
| from .heat_zx import ZXHeat, ZX90HeatXError, ZX90HeatYError, ZX90HeatZError | ||
| from .heat_analysis import HeatElementAnalysis, HeatAnalysis | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,143 @@ | ||
| # This code is part of Qiskit. | ||
| # | ||
| # (C) Copyright IBM 2021. | ||
| # | ||
| # 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 | ||
| # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. | ||
| # | ||
| # Any modifications or derivative works of this code must retain this | ||
| # copyright notice, and modified files need to carry a notice indicating | ||
| # that they have been altered from the originals. | ||
| """ | ||
| Analysis for HEAT experiments. | ||
| """ | ||
|
|
||
| from typing import List | ||
|
|
||
| import numpy as np | ||
|
|
||
| from qiskit_experiments.curve_analysis import ErrorAmplificationAnalysis | ||
| from qiskit_experiments.exceptions import AnalysisError | ||
| from qiskit_experiments.framework import ( | ||
| CompositeAnalysis, | ||
| ExperimentData, | ||
| AnalysisResultData, | ||
| Options, | ||
| FitVal, | ||
| ) | ||
|
|
||
|
|
||
| class HeatElementAnalysis(ErrorAmplificationAnalysis): | ||
| """An analysis class for HEAT experiment to define the fixed parameters. | ||
|
|
||
| # section: overview | ||
|
|
||
| This is standard error amplification analysis. | ||
|
|
||
| # section: see_also | ||
| qiskit_experiments.curve_analysis.ErrorAmplificationAnalysis | ||
| """ | ||
|
|
||
| __fixed_parameters__ = ["angle_per_gate", "phase_offset", "amp"] | ||
|
|
||
| @classmethod | ||
| def _default_options(cls) -> Options: | ||
| """Default analysis options.""" | ||
| options = super()._default_options() | ||
| options.angle_per_gate = np.pi | ||
| options.phase_offset = np.pi / 2 | ||
| options.amp = 1.0 | ||
|
|
||
| return options | ||
|
|
||
|
|
||
| class HeatAnalysis(CompositeAnalysis): | ||
| r"""A composite error amplification analysis to get unitary error coefficients. | ||
|
Contributor
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. I think this docstring would be benefit from writting down the Hamiltonian so that we can better see how the terms
Collaborator
Author
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 model is written in the
Contributor
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. Why not write an example model and make it clear that this has a broader use.
Collaborator
Author
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. Any example of the model? (without assuming specific amplification sequence) I can write a model specific to for example ZX Hamiltonian but this may mislead user so that usecase is limited. |
||
|
|
||
| # section: fit_model | ||
|
|
||
| This analysis takes two error amplification experiment results performed with | ||
| different control qubit state to distinguish the local rotation term from | ||
| the controlled rotation term amplified along a specific error axis. | ||
nkanazawa1989 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| This analysis takes a set of `d_theta` parameters from child error amplification results | ||
| which might be represented by a unique name in the child experiment data. | ||
| With these fit parameters, two Hamiltonian coefficients will be computed as | ||
|
|
||
| .. math:: | ||
|
|
||
| A_{I\beta} = \frac{1}{2}\left( d\theta_{\beta 0} + d\theta_{\beta 1} \right) \\ | ||
|
|
||
| A_{Z\beta} = \frac{1}{2}\left( d\theta_{\beta 0} - d\theta_{\beta 1} \right) | ||
|
|
||
| where, :math:`\beta \in [X, Y, Z]` is one of single qubit Pauli term, | ||
| :math:`d\theta_{\beta k}` is `d_theta` parameter extracted from the HEAT experiment | ||
| with the control qubit state :math:`|k\rangle \in [|0\rangle, |1\rangle]`. | ||
nkanazawa1989 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| # section: see_also | ||
| qiskit_experiments.library.hamiltonian.HeatElementAnalysis | ||
nkanazawa1989 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| """ | ||
|
|
||
| def __init__(self, fit_params: List[str], out_params: List[str]): | ||
| """Create new HEAT analysis. | ||
|
|
||
| Args: | ||
| fit_params: Name of error parameters for each amplification sequence. | ||
| out_params: Name of Hamiltonian coefficients. | ||
|
|
||
| Raises: | ||
| AnalysisError: When size of ``fit_params`` or ``out_params`` are not 2. | ||
nkanazawa1989 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| """ | ||
| super().__init__() | ||
|
|
||
| if len(fit_params) != 2: | ||
| raise AnalysisError( | ||
| f"{self.__class__.__name__} assumes two fit parameters extracted from " | ||
| "a set of experiments with different control qubit state input. " | ||
| f"{len(fit_params)} input parameter names are specified." | ||
| ) | ||
| self.fit_params = fit_params | ||
nkanazawa1989 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| if len(out_params) != 2: | ||
| raise AnalysisError( | ||
| f"{self.__class__.__name__} assumes two output parameters computed with " | ||
| "a set of experiment results with different control qubit state input. " | ||
| f"{len(out_params)} output parameter names are specified." | ||
| ) | ||
| self.out_params = out_params | ||
|
|
||
| def _run_analysis(self, experiment_data: ExperimentData): | ||
|
|
||
| # wait for child experiments to complete | ||
| super()._run_analysis(experiment_data) | ||
eggerdj marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| # extract d_theta parameters | ||
| fit_results = [] | ||
| for i, pname in enumerate(self.fit_params): | ||
| fit_results.append(experiment_data.child_data(i).analysis_results(pname)) | ||
|
|
||
| # Check data quality | ||
| is_good_quality = all(r.quality == "good" for r in fit_results) | ||
|
|
||
| # Compute unitary terms | ||
| ib = (fit_results[0].value.value + fit_results[1].value.value) / 2 | ||
| zb = (fit_results[0].value.value - fit_results[1].value.value) / 2 | ||
|
|
||
| # Compute new variance | ||
| sigma = np.sqrt(fit_results[0].value.stderr ** 2 + fit_results[1].value.stderr ** 2) | ||
nkanazawa1989 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| estimate_ib = AnalysisResultData( | ||
| name=self.out_params[0], | ||
| value=FitVal(value=ib, stderr=sigma, unit="rad"), | ||
| quality="good" if is_good_quality else "bad", | ||
| ) | ||
|
|
||
| estimate_zb = AnalysisResultData( | ||
| name=self.out_params[1], | ||
| value=FitVal(value=zb, stderr=sigma, unit="rad"), | ||
| quality="good" if is_good_quality else "bad", | ||
| ) | ||
|
|
||
| return [estimate_ib, estimate_zb], None | ||
nkanazawa1989 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
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.
This is a fairly broad title. Should the contents in
cr_hamiltonian.pybe moved underqiskit_experiments.library.hamiltonianas well? Also, I put a comment by the reno as well -- I feel like experiments are characterizing a particular schedule more than the underlying Hamiltonian. One could tweak the pulse shape or cancellation tone to adjust observed errors from the target ZX90 operation.Uh oh!
There was an error while loading. Please reload this page.
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.
Probably
entanglerandEntangler characterization? But this could kick out JAZZ experiment from here. I think having static ZZ in the module improves accessibility.(edit)
Probably we may want to add sizzle too.