mirror of https://github.com/Qiskit/qiskit.git
Fix RZX builder rescaled amplitude (#8031)
* Fix RZX builder rescale amplitude bug * Update releasenotes/notes/fix-rzx-builder-pulse-amp-ba5c876ddea17c41.yaml Co-authored-by: Jake Lishman <jake@binhbar.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
parent
9374449d69
commit
829f2324c8
|
@ -153,7 +153,13 @@ class RZXCalibrationBuilder(CalibrationBuilder):
|
|||
|
||||
Raises:
|
||||
QiskitError: if the pulses are not GaussianSquare.
|
||||
QiskitError: if rotation angle is not assigned.
|
||||
"""
|
||||
try:
|
||||
theta = float(theta)
|
||||
except TypeError as ex:
|
||||
raise QiskitError("Target rotation angle is not assigned.") from ex
|
||||
|
||||
pulse_ = instruction.pulse
|
||||
if isinstance(pulse_, GaussianSquare):
|
||||
amp = pulse_.amp
|
||||
|
@ -165,8 +171,8 @@ class RZXCalibrationBuilder(CalibrationBuilder):
|
|||
gaussian_area = abs(amp) * sigma * np.sqrt(2 * np.pi) * math.erf(n_sigmas)
|
||||
area = gaussian_area + abs(amp) * width
|
||||
|
||||
target_area = abs(float(theta)) / (np.pi / 2.0) * area
|
||||
sign = theta / abs(float(theta))
|
||||
target_area = abs(theta) / (np.pi / 2.0) * area
|
||||
sign = np.sign(theta)
|
||||
|
||||
if target_area > gaussian_area:
|
||||
width = (target_area - gaussian_area) / abs(amp)
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
fixes:
|
||||
- |
|
||||
Fixed a bug in the :class:`.RZXCalibrationBuilder` transpiler pass where
|
||||
the scaled cross-resonance pulse amplitude could appear to be parametrized
|
||||
even after assignment. This could cause the pulse visualization tools to
|
||||
use the parametrized format instead of the expected numeric one.
|
|
@ -122,3 +122,19 @@ class TestRZXCalibrationBuilderNoEcho(TestCalibrationBuilder):
|
|||
# Check whether the durations of the RZX pulse and
|
||||
# the scaled CR pulse from the CX gate match.
|
||||
self.assertEqual(rzx_qc_duration, duration)
|
||||
|
||||
def test_pulse_amp_typecasted(self):
|
||||
"""Test if scaled pulse amplitude is complex type."""
|
||||
fake_play = Play(
|
||||
GaussianSquare(duration=800, amp=0.1, sigma=64, risefall_sigma_ratio=2),
|
||||
ControlChannel(0),
|
||||
)
|
||||
fake_theta = circuit.Parameter("theta")
|
||||
assigned_theta = fake_theta.assign(fake_theta, 0.01)
|
||||
|
||||
scaled = RZXCalibrationBuilderNoEcho.rescale_cr_inst(
|
||||
instruction=fake_play, theta=assigned_theta
|
||||
)
|
||||
scaled_pulse = scaled.pulse
|
||||
|
||||
self.assertIsInstance(scaled_pulse.amp, complex)
|
||||
|
|
Loading…
Reference in New Issue