From f2a0c46a139e0db608250635d025955f579893fe Mon Sep 17 00:00:00 2001 From: nick bronn Date: Thu, 11 Aug 2022 09:52:32 -0400 Subject: [PATCH 1/5] committing changes but still debugging --- qiskit/transpiler/passes/calibration/rzx_builder.py | 4 ++-- qiskit/transpiler/passes/scheduling/scheduling/alap.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/qiskit/transpiler/passes/calibration/rzx_builder.py b/qiskit/transpiler/passes/calibration/rzx_builder.py index 6c4a6e4f2efd..323c1f14b7e6 100644 --- a/qiskit/transpiler/passes/calibration/rzx_builder.py +++ b/qiskit/transpiler/passes/calibration/rzx_builder.py @@ -171,8 +171,8 @@ def get_calibration(self, node_op: CircuitInst, qubits: List) -> Union[Schedule, rzx_theta = Schedule(name="rzx(%.3f)" % theta) rzx_theta.metadata["publisher"] = CalibrationPublisher.QISKIT - - if np.isclose(theta, 0.0): + #import pdb; pdb.set_trace() + if np.isclose(float(theta), 0.0): return rzx_theta cx_sched = self._inst_map.get("cx", qubits=qubits) diff --git a/qiskit/transpiler/passes/scheduling/scheduling/alap.py b/qiskit/transpiler/passes/scheduling/scheduling/alap.py index 9de6b162ec0b..eb8a18b06312 100644 --- a/qiskit/transpiler/passes/scheduling/scheduling/alap.py +++ b/qiskit/transpiler/passes/scheduling/scheduling/alap.py @@ -47,8 +47,9 @@ def run(self, dag): idle_before = {q: 0 for q in dag.qubits + dag.clbits} bit_indices = {bit: index for index, bit in enumerate(dag.qubits)} for node in reversed(list(dag.topological_op_nodes())): + import pdb; pdb.set_trace() op_duration = self._get_node_duration(node, bit_indices, dag) - + # compute t0, t1: instruction interval, note that # t0: start time of instruction # t1: end time of instruction From 2863d09a7f9d84714ae88372ce533dbc99f801c6 Mon Sep 17 00:00:00 2001 From: nick bronn Date: Thu, 11 Aug 2022 17:38:50 -0400 Subject: [PATCH 2/5] commiting to check necessary changes --- qiskit/transpiler/passes/calibration/rzx_builder.py | 1 - qiskit/transpiler/passes/scheduling/scheduling/alap.py | 1 - 2 files changed, 2 deletions(-) diff --git a/qiskit/transpiler/passes/calibration/rzx_builder.py b/qiskit/transpiler/passes/calibration/rzx_builder.py index 323c1f14b7e6..7f9bf35baa25 100644 --- a/qiskit/transpiler/passes/calibration/rzx_builder.py +++ b/qiskit/transpiler/passes/calibration/rzx_builder.py @@ -171,7 +171,6 @@ def get_calibration(self, node_op: CircuitInst, qubits: List) -> Union[Schedule, rzx_theta = Schedule(name="rzx(%.3f)" % theta) rzx_theta.metadata["publisher"] = CalibrationPublisher.QISKIT - #import pdb; pdb.set_trace() if np.isclose(float(theta), 0.0): return rzx_theta diff --git a/qiskit/transpiler/passes/scheduling/scheduling/alap.py b/qiskit/transpiler/passes/scheduling/scheduling/alap.py index eb8a18b06312..19cf2ea1b28c 100644 --- a/qiskit/transpiler/passes/scheduling/scheduling/alap.py +++ b/qiskit/transpiler/passes/scheduling/scheduling/alap.py @@ -47,7 +47,6 @@ def run(self, dag): idle_before = {q: 0 for q in dag.qubits + dag.clbits} bit_indices = {bit: index for index, bit in enumerate(dag.qubits)} for node in reversed(list(dag.topological_op_nodes())): - import pdb; pdb.set_trace() op_duration = self._get_node_duration(node, bit_indices, dag) # compute t0, t1: instruction interval, note that From cb72f3fa59f81579830846a23a60cf706c7cd5ec Mon Sep 17 00:00:00 2001 From: nick bronn Date: Wed, 19 Oct 2022 18:20:34 -0400 Subject: [PATCH 3/5] added explicit casting to get_calibration in rzx_builder.py in two places --- qiskit/transpiler/passes/calibration/rzx_builder.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/qiskit/transpiler/passes/calibration/rzx_builder.py b/qiskit/transpiler/passes/calibration/rzx_builder.py index 7f9bf35baa25..bc9c5b8c3eb9 100644 --- a/qiskit/transpiler/passes/calibration/rzx_builder.py +++ b/qiskit/transpiler/passes/calibration/rzx_builder.py @@ -164,13 +164,20 @@ 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(float(theta), 0.0): return rzx_theta @@ -274,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 From a57b7de26216fb444b9ae03473feaee199b83eda Mon Sep 17 00:00:00 2001 From: nick bronn Date: Wed, 19 Oct 2022 21:35:50 -0400 Subject: [PATCH 4/5] found a linting error in alap.py --- qiskit/transpiler/passes/scheduling/scheduling/alap.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qiskit/transpiler/passes/scheduling/scheduling/alap.py b/qiskit/transpiler/passes/scheduling/scheduling/alap.py index 19cf2ea1b28c..9de6b162ec0b 100644 --- a/qiskit/transpiler/passes/scheduling/scheduling/alap.py +++ b/qiskit/transpiler/passes/scheduling/scheduling/alap.py @@ -48,7 +48,7 @@ def run(self, dag): bit_indices = {bit: index for index, bit in enumerate(dag.qubits)} for node in reversed(list(dag.topological_op_nodes())): op_duration = self._get_node_duration(node, bit_indices, dag) - + # compute t0, t1: instruction interval, note that # t0: start time of instruction # t1: end time of instruction From 357d222a62da548525ccaf2b623dc3890d2ba671 Mon Sep 17 00:00:00 2001 From: Matthew Treinish Date: Tue, 25 Oct 2022 13:53:52 -0400 Subject: [PATCH 5/5] Remove redundant float cast --- qiskit/transpiler/passes/calibration/rzx_builder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qiskit/transpiler/passes/calibration/rzx_builder.py b/qiskit/transpiler/passes/calibration/rzx_builder.py index bc9c5b8c3eb9..b17af6e4c51a 100644 --- a/qiskit/transpiler/passes/calibration/rzx_builder.py +++ b/qiskit/transpiler/passes/calibration/rzx_builder.py @@ -178,7 +178,7 @@ def get_calibration(self, node_op: CircuitInst, qubits: List) -> Union[Schedule, rzx_theta = Schedule(name="rzx(%.3f)" % theta) rzx_theta.metadata["publisher"] = CalibrationPublisher.QISKIT - if np.isclose(float(theta), 0.0): + if np.isclose(theta, 0.0): return rzx_theta cx_sched = self._inst_map.get("cx", qubits=qubits)