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

Avoid lossing precision when scaling frequencies (backport #12392) #12480

Merged
merged 2 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 6 additions & 6 deletions qiskit/qobj/converters/pulse_instruction.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def _convert_set_frequency(
"name": "setf",
"t0": time_offset + instruction.start_time,
"ch": instruction.channel.name,
"frequency": instruction.frequency / 1e9,
"frequency": instruction.frequency / 10**9,
}
return self._qobj_model(**command_dict)

Expand All @@ -266,7 +266,7 @@ def _convert_shift_frequency(
"name": "shiftf",
"t0": time_offset + instruction.start_time,
"ch": instruction.channel.name,
"frequency": instruction.frequency / 1e9,
"frequency": instruction.frequency / 10**9,
}
return self._qobj_model(**command_dict)

Expand Down Expand Up @@ -836,7 +836,7 @@ def _convert_setf(
.. note::

We assume frequency value is expressed in string with "GHz".
Operand value is thus scaled by a factor of 1e9.
Operand value is thus scaled by a factor of 10^9.

Args:
instruction: SetFrequency qobj instruction
Expand All @@ -845,7 +845,7 @@ def _convert_setf(
Qiskit Pulse set frequency instructions
"""
channel = self.get_channel(instruction.ch)
frequency = self.disassemble_value(instruction.frequency) * 1e9
frequency = self.disassemble_value(instruction.frequency) * 10**9

yield instructions.SetFrequency(frequency, channel)

Expand All @@ -858,7 +858,7 @@ def _convert_shiftf(
.. note::

We assume frequency value is expressed in string with "GHz".
Operand value is thus scaled by a factor of 1e9.
Operand value is thus scaled by a factor of 10^9.

Args:
instruction: ShiftFrequency qobj instruction
Expand All @@ -867,7 +867,7 @@ def _convert_shiftf(
Qiskit Pulse shift frequency schedule instructions
"""
channel = self.get_channel(instruction.ch)
frequency = self.disassemble_value(instruction.frequency) * 1e9
frequency = self.disassemble_value(instruction.frequency) * 10**9

yield instructions.ShiftFrequency(frequency, channel)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
fixes:
- |
Fixed a floating-point imprecision when scaling certain pulse units
between seconds and nanoseconds. If the pulse was symbolically defined,
an unnecessary floating-point error could be introduced by the scaling
for certain builds of ``symengine``, which could manifest in unexpected
results once the symbols were fully bound. See `#12392 <https://github.com/Qiskit/qiskit/pull/12392>`__.
Loading