Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
cd37e22
add gaussian square echo pulse
miamico Jan 12, 2023
859c451
address some PR comments
miamico Jan 24, 2023
760aa7c
fixed parameters of symbolicpulse
miamico Jan 26, 2023
fca8fd6
adding math description and reference
miamico Jan 31, 2023
2895969
change variable names
miamico Jan 31, 2023
755d16e
fix lint
miamico Jan 31, 2023
6f73a4c
remove width_echo parameter
miamico Jan 31, 2023
e1c731e
fix lint
miamico Jan 31, 2023
b083550
add release notes
miamico Jan 31, 2023
0c1ba46
fix conflicts
miamico Apr 12, 2023
d94fcc7
address some PR comments
miamico Jan 24, 2023
3d310c7
fixed parameters of symbolicpulse
miamico Jan 26, 2023
a1df97f
adding math description and reference
miamico Jan 31, 2023
a331c36
change variable names
miamico Jan 31, 2023
0d695dc
fix lint
miamico Jan 31, 2023
bfd2c5d
remove width_echo parameter
miamico Jan 31, 2023
7d79645
fix lint
miamico Jan 31, 2023
7ff1871
add release notes
miamico Jan 31, 2023
f1f5a90
Merge branch 'main' of github.com:miamico/miamico-gse
miamico Apr 12, 2023
75427a9
Update first paragraph
miamico Apr 12, 2023
310b727
Update amp param to float
miamico Apr 12, 2023
f3c1e50
Update angle def param to float
miamico Apr 12, 2023
b18df11
Update amp constrain
miamico Apr 12, 2023
877b285
drafting tests
miamico Apr 12, 2023
16f2b33
update docstring
miamico Apr 12, 2023
bba03a0
finish up test
miamico Apr 12, 2023
bbeba66
Merge branch 'main' into main
miamico Apr 13, 2023
4ead034
fix missing pulses from init
miamico Apr 13, 2023
d012580
addding Cos
miamico Apr 13, 2023
41af294
Merge branch 'main' of github.com:miamico/miamico-gse
miamico Apr 13, 2023
061aac4
missing sin
miamico Apr 14, 2023
d0d04ce
fixed tests
miamico Apr 14, 2023
050c001
black formatting
miamico Apr 17, 2023
fab388b
break string
miamico Apr 17, 2023
cb0749e
fixing strings
miamico Apr 17, 2023
170370e
reformatting
miamico Apr 17, 2023
92c4b29
fix lint
miamico Apr 17, 2023
17944ca
fixing last things
miamico Apr 17, 2023
ecc70c6
fix tests
miamico Apr 17, 2023
5259ff5
fix black
miamico Apr 17, 2023
686f342
Merge branch 'main' into main
miamico Apr 17, 2023
a0575d3
fix another test
miamico Apr 18, 2023
bff8bab
fix amp validation
miamico Apr 18, 2023
b4851fc
Merge branch 'main' of github.com:miamico/miamico-gse
miamico Apr 18, 2023
a55abd7
Merge branch 'main' into main
miamico Apr 18, 2023
257fd43
fixing docstring
miamico Apr 22, 2023
75183f2
Merge branch 'main' of github.com:miamico/miamico-gse
miamico Apr 22, 2023
97a1e5f
Merge branch 'main' into main
miamico Apr 22, 2023
bb744bd
Update qiskit/pulse/library/symbolic_pulses.py
miamico Apr 27, 2023
8be636a
Merge branch 'main' into main
miamico Apr 27, 2023
769b145
Merge branch 'main' into main
miamico May 2, 2023
88f045f
rename to gaussian_square_echo
miamico May 2, 2023
be39a8f
Merge branch 'main' of github.com:miamico/miamico-gse
miamico May 2, 2023
efb3b07
fix lint
miamico May 5, 2023
41647e1
Update qiskit/qobj/converters/pulse_instruction.py
miamico May 19, 2023
4328ce2
Update releasenotes/notes/gaussian-square-echo-pulse-84306f1a02e2bb28…
miamico May 19, 2023
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 @@ -142,6 +142,7 @@
Gaussian,
GaussianSquare,
GaussianSquareDrag,
GaussianSquareEcho,
ParametricPulse,
SymbolicPulse,
ScalableSymbolicPulse,
Expand Down
1 change: 1 addition & 0 deletions qiskit/pulse/library/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
Gaussian,
GaussianSquare,
GaussianSquareDrag,
GaussianSquareEcho,
Drag,
Constant,
)
Expand Down
152 changes: 152 additions & 0 deletions qiskit/pulse/library/symbolic_pulses.py
Original file line number Diff line number Diff line change
Expand Up @@ -1063,6 +1063,158 @@ def GaussianSquareDrag(
return instance


def GaussianSquareEcho(
duration: Union[int, ParameterExpression],
amp: Union[float, ParameterExpression],
sigma: Union[float, ParameterExpression],
width: Optional[Union[float, ParameterExpression]] = None,
angle: Optional[Union[float, ParameterExpression]] = 0.0,
active_amp: Optional[Union[float, ParameterExpression]] = 0,
Comment thread
miamico marked this conversation as resolved.
Outdated
active_angle: Optional[Union[float, ParameterExpression]] = 0,
Comment thread
miamico marked this conversation as resolved.
Outdated
risefall_sigma_ratio: Optional[Union[float, ParameterExpression]] = None,
name: Optional[str] = None,
limit_amplitude: Optional[bool] = None,
) -> SymbolicPulse:
"""An echoed Gaussian square pulse with an active tone overlaid on it.
Exactly one of the ``risefall_sigma_ratio`` and ``width`` parameters has to be specified.
If ``risefall_sigma_ratio`` is not ``None`` and ``width`` is ``None``:
.. math::
\\text{risefall} &= \\text{risefall_sigma_ratio} \\times \\text{sigma}\\\\
\\text{width} &= \\text{duration} - 2 \\times \\text{risefall}
If ``width`` is not None and ``risefall_sigma_ratio`` is None:
.. math:: \\text{risefall} = \\frac{\\text{duration} - \\text{width}}{2}
Gaussian :math:`g(x, c, σ)` and lifted gaussian :math:`g'(x, c, σ)` curves
can be written as:
.. math::
g(x, c, σ) &= \\exp\\Bigl(-\\frac12 \\frac{(x - c)^2}{σ^2}\\Bigr)\\\\
g'(x, c, σ) &= \\frac{g(x, c, σ)-g(-1, c, σ)}{1-g(-1, c, σ)}

Comment thread
miamico marked this conversation as resolved.
Outdated
Args:
duration: Pulse length in terms of the sampling period `dt`.
amp: The amplitude of the rise and fall and of the square pulse.
sigma: A measure of how wide or narrow the risefall is; see the class
docstring for more details.
width: The duration of the embedded square pulse.
Comment thread
miamico marked this conversation as resolved.
angle: The angle in radians of the complex phase factor uniformly
scaling the pulse. Default value 0.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It needs to be clarified that this angle affects only the echoed part of the pulse, not the entire pulse. I would change to amp and angle to echo_amp and echo_angle to put the two parts on equal footing, but I don't feel too strongly about it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I have tried to be more specific in the docstring on what refers to what. I'd like to avoid changing variable names as amp and angle are the standard variable names used for other pulses (and one could define a GaussianSquareEcho just by defining these two).

active_amp: The amplitude of the active cancellation tone.
Comment thread
miamico marked this conversation as resolved.
Outdated
active_angle: The angle in radian of the complex phase factor uniformly
scaling the active pulse. Default value 0.
risefall_sigma_ratio: The ratio of each risefall duration to sigma.
name: Display name for this pulse envelope.
limit_amplitude: If ``True``, then limit the amplitude of the
waveform to 1. The default is ``True`` and the amplitude is constrained to 1.
Returns:
ScalableSymbolicPulse instance.
Raises:
PulseError: When width and risefall_sigma_ratio are both empty or both non-empty.
"""
# Convert risefall_sigma_ratio into width which is defined in OpenPulse spec
if width is None and risefall_sigma_ratio is None:
raise PulseError(
"Either the pulse width or the risefall_sigma_ratio parameter must be specified."
)
if width is not None and risefall_sigma_ratio is not None:
raise PulseError(
"Either the pulse width or the risefall_sigma_ratio parameter can be specified"
" but not both."
)

if width is not None and risefall_sigma_ratio is None:
total_risefall = duration - width
echo_risefall = 2*total_risefall
width_echo = (duration - echo_risefall)/2

if width is None and risefall_sigma_ratio is not None:
width = duration - 2.0 * risefall_sigma_ratio * sigma
width_echo = (duration - 4.0 * risefall_sigma_ratio * sigma)/2



parameters = {"amp": amp, "angle": angle, "sigma": sigma, "width": width, "width_echo": width_echo,
Comment thread
miamico marked this conversation as resolved.
Outdated
"active_amp": active_amp, "active_angle": active_angle}

# Prepare symbolic expressions
_t, _duration, _amp, _sigma, _active_amp, _width, _width_echo, _angle, _active_angle = sym.symbols(
"t, duration, amp, sigma, active_amp, width, width_echo, angle, active_angle"
)

# gaussian square echo for rotary tone
_center = _duration / 4

_sq_t0 = _center - _width_echo / 2
_sq_t1 = _center + _width_echo / 2

_gaussian_ledge = _lifted_gaussian(_t, _sq_t0, -1, _sigma)
_gaussian_redge = _lifted_gaussian(_t, _sq_t1, _duration/2 + 1, _sigma)

envelope_expr_p = (
_amp
* sym.exp(sym.I * _angle)
* sym.Piecewise(
(_gaussian_ledge, _t <= _sq_t0),
(_gaussian_redge, _t >= _sq_t1),
(1, True),
)
)

_center_echo = _duration/2 + _duration / 4

_sq_t0_echo = _center_echo - _width_echo / 2
_sq_t1_echo = _center_echo + _width_echo / 2

_gaussian_ledge_echo = _lifted_gaussian(_t, _sq_t0_echo, _duration/2-1, _sigma)
_gaussian_redge_echo = _lifted_gaussian(_t, _sq_t1_echo, _duration + 1, _sigma)

envelope_expr_echo = (
-1*_amp
* sym.exp(sym.I * _angle)
* sym.Piecewise(
(_gaussian_ledge_echo, _t <= _sq_t0_echo),
(_gaussian_redge_echo, _t >= _sq_t1_echo),
(1, True),
)
)

envelope_expr = sym.Piecewise( (envelope_expr_p, _t <= _duration/2), (envelope_expr_echo, _t >= _duration/2), (0, True) )

# gaussian square for active cancellation tone
_center_xy = _duration/2
Comment thread
miamico marked this conversation as resolved.
Outdated

_sq_t0_xy = _center_xy - _width / 2
_sq_t1_xy = _center_xy + _width / 2

_gaussian_ledge_xy = _lifted_gaussian(_t, _sq_t0_xy, -1, _sigma)
_gaussian_redge_xy = _lifted_gaussian(_t, _sq_t1_xy, _duration + 1, _sigma)

envelope_expr_xy = _active_amp * sym.exp(sym.I * _active_angle) * sym.Piecewise(
(_gaussian_ledge_xy, _t <= _sq_t0_xy), (_gaussian_redge_xy, _t >= _sq_t1_xy), (1, True)
)

envelop_expr_total = envelope_expr + envelope_expr_xy
Comment thread
miamico marked this conversation as resolved.
Outdated


consts_expr = sym.And(_sigma > 0, _width >= 0, _duration >= _width, _duration/2 >= _width_echo)

# Check validity of amplitudes
valid_amp_conditions_expr = sym.And(sym.Abs(_amp) <= 1.0)
Comment thread
miamico marked this conversation as resolved.
Outdated
valid_amp_conditions_expr = sym.And(sym.Abs(_active_amp) <= 1.0)
Comment thread
miamico marked this conversation as resolved.
Outdated

instance = SymbolicPulse(
pulse_type="GaussianSquareEcho",
duration=duration,
parameters=parameters,
name=name,
limit_amplitude=limit_amplitude,
envelope=envelop_expr_total,
constraints=consts_expr,
valid_amp_conditions=valid_amp_conditions_expr,
)
instance.validate_parameters()

return instance


class Drag(metaclass=_PulseType):
"""The Derivative Removal by Adiabatic Gate (DRAG) pulse is a standard Gaussian pulse
with an additional Gaussian derivative component and lifting applied.
Expand Down
1 change: 1 addition & 0 deletions qiskit/qobj/converters/pulse_instruction.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class ParametricPulseShapes(Enum):
gaussian = "Gaussian"
gaussian_square = "GaussianSquare"
gaussian_square_drag = "GaussianSquareDrag"
gaussian_square_echo = "GaussianSquareEcho"
Comment thread
miamico marked this conversation as resolved.
Outdated
drag = "Drag"
constant = "Constant"

Expand Down