-
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
HEAT experiments #625
Open
nkanazawa1989
wants to merge
54
commits into
qiskit-community:main
Choose a base branch
from
nkanazawa1989:experiment/heat
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
HEAT experiments #625
Changes from 16 commits
Commits
Show all changes
54 commits
Select commit
Hold shift + click to select a range
7b2bfc1
cleanup old PR #460
nkanazawa1989 fccf94c
write release note
nkanazawa1989 6e64321
serialization unittest
nkanazawa1989 49a7845
fix projection angle of Z measure
nkanazawa1989 b766f56
Merge branch 'main' of github.com:Qiskit/qiskit-experiments into expe…
nkanazawa1989 d32444f
add unittest for running experiments and minor doc fix
nkanazawa1989 c0e0da5
Update qiskit_experiments/library/hamiltonian/__init__.py
nkanazawa1989 423dad4
Update qiskit_experiments/library/hamiltonian/__init__.py
nkanazawa1989 8adcca2
Update qiskit_experiments/library/hamiltonian/heat_analysis.py
nkanazawa1989 942e558
Update qiskit_experiments/library/hamiltonian/heat_analysis.py
nkanazawa1989 4f70f6e
Update qiskit_experiments/library/hamiltonian/heat_base.py
nkanazawa1989 9cc247f
Update qiskit_experiments/library/hamiltonian/heat_base.py
nkanazawa1989 e8a11f7
Update qiskit_experiments/library/hamiltonian/heat_base.py
nkanazawa1989 00a991a
Update qiskit_experiments/library/hamiltonian/heat_base.py
nkanazawa1989 7c49da1
Update qiskit_experiments/library/hamiltonian/heat_base.py
nkanazawa1989 4a3c645
Update qiskit_experiments/library/hamiltonian/heat_zx.py
nkanazawa1989 ca871ac
Update qiskit_experiments/library/hamiltonian/heat_zx.py
nkanazawa1989 8ced3c2
Update qiskit_experiments/library/hamiltonian/heat_zx.py
nkanazawa1989 52a1439
Update qiskit_experiments/library/hamiltonian/heat_zx.py
nkanazawa1989 42f0768
Update releasenotes/notes/add-heat-experiment-047a73818407e733.yaml
nkanazawa1989 0cec011
Merge branch 'main' into experiment/heat
nkanazawa1989 16fb9ea
document overhaul for ZXHeat class
nkanazawa1989 6175036
document overhaul for HeatElement class
nkanazawa1989 532f855
black
nkanazawa1989 e379b49
update test tolerance
nkanazawa1989 c7318b8
Update qiskit_experiments/library/hamiltonian/heat_zx.py
nkanazawa1989 9a59715
Update qiskit_experiments/library/hamiltonian/heat_zx.py
nkanazawa1989 ef8c56c
Update qiskit_experiments/library/hamiltonian/heat_zx.py
nkanazawa1989 30f9200
Update qiskit_experiments/library/hamiltonian/heat_zx.py
nkanazawa1989 c4333fb
Update qiskit_experiments/library/hamiltonian/heat_zx.py
nkanazawa1989 6524858
Update qiskit_experiments/library/hamiltonian/heat_zx.py
nkanazawa1989 cf47445
Update qiskit_experiments/library/hamiltonian/heat_zx.py
nkanazawa1989 077d217
Update qiskit_experiments/library/hamiltonian/heat_zx.py
nkanazawa1989 a773faa
Update qiskit_experiments/library/hamiltonian/heat_base.py
nkanazawa1989 9819c16
update test tolerance to be more precise
nkanazawa1989 678af55
Merge branch 'experiment/heat' of github.com:nkanazawa1989/qiskit-exp…
nkanazawa1989 1ceff09
Update heat_zx.py
nkanazawa1989 e540446
Merge branch 'main' of github.com:Qiskit/qiskit-experiments into expe…
nkanazawa1989 e103640
udpate analysis constructor and remove BatchHeatHelper
nkanazawa1989 d918470
Merge branch 'experiment/heat' of github.com:nkanazawa1989/qiskit-exp…
nkanazawa1989 280cae1
fix lint
nkanazawa1989 4f7cd81
Update qiskit_experiments/library/hamiltonian/heat_base.py
nkanazawa1989 5c40d7d
Update qiskit_experiments/library/hamiltonian/heat_base.py
nkanazawa1989 4882e9e
Update qiskit_experiments/library/hamiltonian/heat_base.py
nkanazawa1989 a62cc8f
Update qiskit_experiments/library/hamiltonian/heat_zx.py
nkanazawa1989 5d4945e
Update qiskit_experiments/library/hamiltonian/heat_zx.py
nkanazawa1989 c908105
Update qiskit_experiments/library/hamiltonian/heat_zx.py
nkanazawa1989 6c1a556
Merge branch 'main' of github.com:Qiskit/qiskit-experiments into expe…
nkanazawa1989 995a009
Update qiskit_experiments/library/hamiltonian/heat_zx.py
nkanazawa1989 caf945a
Merge branch 'main' of github.com:Qiskit/qiskit-experiments into expe…
nkanazawa1989 c400186
remove usage of fitval
nkanazawa1989 aba80ca
Merge branch 'experiment/heat' of github.com:nkanazawa1989/qiskit-exp…
nkanazawa1989 fec3997
lint
nkanazawa1989 1e21e36
fix bug due to #662
nkanazawa1989 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,8 +13,9 @@ | |
Composite Experiment abstract base class. | ||
""" | ||
|
||
from typing import List, Sequence, Optional, Union | ||
from typing import List, Sequence, Optional, Union, Type | ||
from abc import abstractmethod | ||
import functools | ||
import warnings | ||
from qiskit.providers.backend import Backend | ||
from qiskit_experiments.framework import BaseExperiment, ExperimentData | ||
|
@@ -131,3 +132,75 @@ def _postprocess_transpiled_circuits(self, circuits, **run_options): | |
for expr in self._experiments: | ||
if not isinstance(expr, CompositeExperiment): | ||
expr._postprocess_transpiled_circuits(circuits, **run_options) | ||
|
||
|
||
def sync_transpile_options( | ||
composite_cls: Type[CompositeExperiment], | ||
) -> Type[CompositeExperiment]: | ||
"""A class decorator that overrides the transpile option setter method. | ||
|
||
This method overrides the behavior of :meth:`set_transpile_options` method. | ||
The option values set to the composite instance | ||
will be propagated through all component experiments. | ||
|
||
Args: | ||
composite_cls: CompositeExperiment subclass to decorate. | ||
|
||
Returns: | ||
Composite experiment that implements option synchronization. | ||
|
||
Raises: | ||
TypeError: When class is not subclass of :class:`CompositeExperiment` | ||
""" | ||
if not issubclass(composite_cls, CompositeExperiment): | ||
raise TypeError("Class is not composite experiment. Cannot override method.") | ||
|
||
options_setter = getattr(composite_cls, "set_transpile_options") | ||
|
||
@functools.wraps(options_setter) | ||
def sync_opts(instance, **fields): | ||
options_setter(instance, **fields) | ||
# set the same options to component experiments | ||
for comp in instance.component_experiment(): | ||
comp.set_transpile_options(**fields) | ||
|
||
# override set method | ||
setattr(composite_cls, "set_transpile_options", sync_opts) | ||
|
||
return composite_cls | ||
|
||
|
||
def sync_experiment_options( | ||
composite_cls: Type[CompositeExperiment], | ||
) -> Type[CompositeExperiment]: | ||
Comment on lines
+182
to
+184
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. Same comment as above. Using decorators here only makes the code harder to follow. |
||
"""A class decorator that overrides the experiment option setter method. | ||
|
||
This method overrides the behavior of :meth:`set_experiment_options` method. | ||
The option values set to the composite instance | ||
will be propagated through all component experiments. | ||
|
||
Args: | ||
composite_cls: CompositeExperiment subclass to decorate. | ||
|
||
Returns: | ||
Composite experiment that implements option synchronization. | ||
|
||
Raises: | ||
TypeError: When class is not subclass of :class:`CompositeExperiment` | ||
""" | ||
if not issubclass(composite_cls, CompositeExperiment): | ||
raise TypeError("Class is not composite experiment. Cannot override method.") | ||
|
||
options_setter = getattr(composite_cls, "set_experiment_options") | ||
|
||
@functools.wraps(options_setter) | ||
def sync_opts(instance, **fields): | ||
options_setter(instance, **fields) | ||
# set the same options to component experiments | ||
for comp in instance.component_experiment(): | ||
comp.set_experiment_options(**fields) | ||
|
||
# override set method | ||
setattr(composite_cls, "set_experiment_options", sync_opts) | ||
|
||
return composite_cls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Why is this needed in the first place? I wonder if this should be the default behavior of
CompositeExperiment
? Or why not have this as an extra function in theCompositeExperiment
? I don't see why the decorator framework is needed when we only decorate a single method of a single class.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 aims at making a batch experiment to behave as if a single experiment (because user doesn't need to recognize its implementation to use). This SHOUD not be default behavior (unfortunately it is now) because we should be able to transpile batch (I believe also parallel) experiment with its own configuration.