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

Cast ParameterExpression to float in RZXBuilder and RZXCalibrationBuilderNoEcho #8965

Merged
merged 8 commits into from
Oct 25, 2022
14 changes: 13 additions & 1 deletion qiskit/transpiler/passes/calibration/rzx_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,21 @@ def get_calibration(self, node_op: CircuitInst, qubits: List) -> Union[Schedule,
schedule: The calibration schedule for the RZXGate(theta).

Raises:
QiskitError: if rotation angle is not assigned.
QiskitError: If the control and target qubits cannot be identified.
CalibrationNotAvailable: RZX schedule cannot be built for input node.
"""
theta = node_op.params[0]

try:
theta = float(theta)
except TypeError as ex:
raise QiskitError("Target rotation angle is not assigned.") from ex

rzx_theta = Schedule(name="rzx(%.3f)" % theta)
rzx_theta.metadata["publisher"] = CalibrationPublisher.QISKIT

if np.isclose(theta, 0.0):
if np.isclose(float(theta), 0.0):
mtreinish marked this conversation as resolved.
Show resolved Hide resolved
return rzx_theta

cx_sched = self._inst_map.get("cx", qubits=qubits)
Expand Down Expand Up @@ -275,12 +281,18 @@ def get_calibration(self, node_op: CircuitInst, qubits: List) -> Union[Schedule,
schedule: The calibration schedule for the RZXGate(theta).

Raises:
QiskitError: if rotation angle is not assigned.
QiskitError: If the control and target qubits cannot be identified,
or the backend does not natively support the specified direction of the cx.
CalibrationNotAvailable: RZX schedule cannot be built for input node.
"""
theta = node_op.params[0]

try:
theta = float(theta)
except TypeError as ex:
raise QiskitError("Target rotation angle is not assigned.") from ex

rzx_theta = Schedule(name="rzx(%.3f)" % theta)
rzx_theta.metadata["publisher"] = CalibrationPublisher.QISKIT

Expand Down