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

Serializable parametric pulse #7821

Merged
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
afe4f96
Symbolic parametric pulse
nkanazawa1989 Feb 27, 2022
9a8a582
Improve performance of parametrized pulse evaluation
wshanks Mar 16, 2022
6f2496a
Implement Constant pulse using Piecewise
wshanks Mar 17, 2022
0424636
Fall back to sympy for parametric pulse evaluation
wshanks Mar 17, 2022
1bf11fa
Use sympy Symbol with sympy lambdify
wshanks Mar 17, 2022
2335f32
WIP: cache symbolic pulse lambda functions
wshanks Mar 18, 2022
2af235d
Merge pull request #48 from wshanks/upgrade/serializable-parametric-p…
nkanazawa1989 Mar 23, 2022
0cc7383
move lambdify to init subclass for called once
nkanazawa1989 Mar 23, 2022
a59af77
turn parameter properties into attribute and remove slots
nkanazawa1989 Mar 23, 2022
21ef762
remove attribute and add __getattr__ and readd slots for better perfo…
nkanazawa1989 Mar 23, 2022
509470a
move symbolic funcs directly to _define
nkanazawa1989 Mar 23, 2022
ed2f661
Convert numerical_func to staticmethod
nkanazawa1989 Mar 23, 2022
c4b41d5
remove symbolic add constraints, numerical func is renamed to definit…
nkanazawa1989 Mar 27, 2022
71ef841
revert changes to parametric pulse and create new symbolic pulse file
nkanazawa1989 Apr 12, 2022
cf7f302
add ITE-like program
nkanazawa1989 Apr 12, 2022
c2981d0
sympy runtime import
nkanazawa1989 Apr 12, 2022
cf17341
update test notebook
nkanazawa1989 Apr 12, 2022
ba685ef
Merge branch 'main' of github.com:Qiskit/qiskit-terra into upgrade/se…
nkanazawa1989 Apr 12, 2022
f2ef950
add attribute docs
nkanazawa1989 Apr 12, 2022
2ea6390
fix non-constraints
nkanazawa1989 Apr 12, 2022
f48796e
remove pulse type instance variable
nkanazawa1989 Apr 12, 2022
0738497
use descriptor
nkanazawa1989 Apr 12, 2022
92f42eb
remove redundant comment
nkanazawa1989 Apr 12, 2022
1440a23
Merge branch 'main' of github.com:Qiskit/qiskit-terra into upgrade/se…
nkanazawa1989 Apr 13, 2022
4345c3b
Update
nkanazawa1989 Apr 13, 2022
1c63ddb
keep raw data for QPY encoding
nkanazawa1989 Apr 13, 2022
d121b0d
update unittest
nkanazawa1989 Apr 13, 2022
48ff3cc
update helper function name
nkanazawa1989 Apr 13, 2022
b9cab67
add reno
nkanazawa1989 Apr 13, 2022
42b3dd9
remove notebook
nkanazawa1989 Apr 13, 2022
761235d
fix lint
nkanazawa1989 Apr 13, 2022
cc12bf8
fix unittest and logic
nkanazawa1989 Apr 13, 2022
6c21edd
add more docs
nkanazawa1989 Apr 14, 2022
43e0e0b
review comments
nkanazawa1989 Apr 15, 2022
6b956de
Merge branch 'main' of github.com:Qiskit/qiskit-terra into upgrade/se…
nkanazawa1989 Apr 18, 2022
eefa5e4
lint fix
nkanazawa1989 Apr 18, 2022
252f62b
fix documentation
nkanazawa1989 Apr 18, 2022
f24e648
minor drawer fix
nkanazawa1989 Apr 19, 2022
4d191be
documentation upgrade
nkanazawa1989 Apr 21, 2022
2c8e7f8
Merge branch 'main' of github.com:Qiskit/qiskit-terra into upgrade/se…
nkanazawa1989 Apr 21, 2022
3a0f506
review comment misc
nkanazawa1989 Apr 28, 2022
d5517d5
remove abstract class methods
nkanazawa1989 May 2, 2022
be2ed0c
add error handling for amplitude
nkanazawa1989 May 5, 2022
67ac61f
treat amp as a special parameter
nkanazawa1989 May 6, 2022
78288ac
Remove expressions for amplitude validation
nkanazawa1989 May 19, 2022
cbada64
Merge branch 'main' of github.com:Qiskit/qiskit-terra into upgrade/se…
nkanazawa1989 May 20, 2022
ecb4ea7
support symengine
nkanazawa1989 Jun 2, 2022
45ae755
use real=False option
nkanazawa1989 Jun 2, 2022
a4a56db
review comment
nkanazawa1989 Jun 6, 2022
d957458
Merge branch 'upgrade/serializable-parametric-pulse-symengine' into u…
nkanazawa1989 Jun 6, 2022
6776743
- fix attribute
nkanazawa1989 Jun 6, 2022
d4e8c43
undo change to requirements-dev
nkanazawa1989 Jun 6, 2022
41bf4f5
fix __getattr__ mechanism
nkanazawa1989 Jun 6, 2022
2aa4f5a
fix type hint reference
nkanazawa1989 Jun 6, 2022
2e521a7
simplification
nkanazawa1989 Jun 6, 2022
09855d7
move amp from constructor to `parameters` dict
nkanazawa1989 Jun 7, 2022
b99eb5c
review comment
nkanazawa1989 Jun 8, 2022
ac23d6f
fix bug
nkanazawa1989 Jun 8, 2022
401c1f4
fix typo
nkanazawa1989 Jun 8, 2022
686e77b
add eval_conditions to skip waveform generation
nkanazawa1989 Jun 8, 2022
84344c2
fall back to sympy lamdify when function is not supported
nkanazawa1989 Jun 9, 2022
914018e
documentation update
nkanazawa1989 Jun 12, 2022
045d67b
replace eval_conditions with valid_amp_conditions
nkanazawa1989 Jun 12, 2022
3b2c571
update hashing and equality, redefine expressions more immutably
nkanazawa1989 Jun 12, 2022
8edaba9
add error message for missing parameter
nkanazawa1989 Jun 12, 2022
9b0adc3
cleanup
nkanazawa1989 Jun 12, 2022
cda7336
check parameter before hashing
nkanazawa1989 Jun 13, 2022
ef35cd9
move amp check to constructor
nkanazawa1989 Jun 13, 2022
15e9f7c
add envelope to hash
nkanazawa1989 Jun 14, 2022
d844253
update docs
nkanazawa1989 Jun 15, 2022
526aaed
Update qiskit/pulse/library/symbolic_pulses.py
nkanazawa1989 Jun 15, 2022
87d3538
Merge branch 'main' into upgrade/serializable-parametric-pulse
nkanazawa1989 Jun 15, 2022
be2b4e0
lint
nkanazawa1989 Jun 15, 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
1 change: 1 addition & 0 deletions qiskit/pulse/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@
Gaussian,
GaussianSquare,
ParametricPulse,
SymbolicPulse,
Waveform,
)
from qiskit.pulse.library.samplers.decorators import functional_pulse
Expand Down
10 changes: 6 additions & 4 deletions qiskit/pulse/library/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@
The :py:mod:`~qiskit.pulse.library.discrete` module will generate
:py:class:`~qiskit.pulse.library.Waveform`\ s for common waveform envelopes.

The parametric pulses, :py:class:`~qiskit.pulse.library.Gaussian`,
The symbolic pulses, :py:class:`~qiskit.pulse.library.Gaussian`,
:py:class:`~qiskit.pulse.library.GaussianSquare`, :py:class:`~qiskit.pulse.library.Drag` and
:py:class:`~qiskit.pulse.library.Constant` will generate parameterized descriptions of
those pulses, which can greatly reduce the size of the job sent to the backend.
:py:class:`~qiskit.pulse.library.Constant` will generate symbolic descriptions of
those pulses, which can greatly reduce the size of the job sent to the backend and
ensure serialization of these pulse data in QPY binary format.

.. autosummary::
nkanazawa1989 marked this conversation as resolved.
Show resolved Hide resolved
:toctree: ../stubs/
Expand All @@ -39,6 +40,7 @@

"""
from .discrete import *
from .parametric_pulses import ParametricPulse, Gaussian, GaussianSquare, Drag, Constant
from .parametric_pulses import ParametricPulse
from .symbolic_pulses import SymbolicPulse, Gaussian, GaussianSquare, Drag, Constant
from .pulse import Pulse
from .waveform import Waveform
9 changes: 9 additions & 0 deletions qiskit/pulse/library/parametric_pulses.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class ParametricPulseShapes(Enum):
...
new_supported_pulse_name = library.YourPulseWaveformClass
"""
import warnings
from abc import abstractmethod
from typing import Any, Dict, Optional, Union

Expand Down Expand Up @@ -70,6 +71,14 @@ def __init__(
amplitude is constrained to 1.
"""
super().__init__(duration=duration, name=name, limit_amplitude=limit_amplitude)

nkanazawa1989 marked this conversation as resolved.
Show resolved Hide resolved
nkanazawa1989 marked this conversation as resolved.
Show resolved Hide resolved
warnings.warn(
"ParametricPulse and its subclass have been deprecated and will be replaced with "
nkanazawa1989 marked this conversation as resolved.
Show resolved Hide resolved
nkanazawa1989 marked this conversation as resolved.
Show resolved Hide resolved
"SymbolicPulse and its subclass because of QPY serialization support. "
"See qiskit.pulse.library.symbolic_pulses for details.",
DeprecationWarning,
nkanazawa1989 marked this conversation as resolved.
Show resolved Hide resolved
stacklevel=3,
)
self.validate_parameters()

@abstractmethod
Expand Down
4 changes: 3 additions & 1 deletion qiskit/pulse/library/pulse.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class Pulse(ABC):
modulation phase and frequency are specified separately from ``Pulse``s.
"""

__slots__ = ("duration", "name")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will slotting this class have any upgrade implications. I don't think so because it's an abc and all the subclasses will have __dict__.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just added a slots for efficiency of instance generation. As experiment scales with larger processor, we need to create tons of pulse instance internally. Perhaps my code is doing something wrong in this context?


limit_amplitude = True

@abstractmethod
Expand All @@ -47,7 +49,7 @@ def __init__(
self.duration = duration
self.name = name
if limit_amplitude is not None:
self.limit_amplitude = limit_amplitude
self.__class__.limit_amplitude = limit_amplitude

@property
def id(self) -> int: # pylint: disable=invalid-name
Expand Down
Loading