From 885be273943b73756cb42b0d1ad21035d3606fa0 Mon Sep 17 00:00:00 2001 From: Raghav <83136390+Raghav-Bell@users.noreply.github.com> Date: Mon, 3 Jul 2023 23:29:35 +0530 Subject: [PATCH 1/6] Update circuits.py Added "diagonal" in line 282 --- qiskit/qpy/binary_io/circuits.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qiskit/qpy/binary_io/circuits.py b/qiskit/qpy/binary_io/circuits.py index 95adba8fdbd1..2073cd05681e 100644 --- a/qiskit/qpy/binary_io/circuits.py +++ b/qiskit/qpy/binary_io/circuits.py @@ -279,7 +279,7 @@ def _read_instruction(file_obj, circuit, registers, custom_operations, version, gate.ctrl_state = instruction.ctrl_state gate.condition = condition_tuple else: - if gate_name in {"Initialize", "StatePreparation", "UCRXGate", "UCRYGate", "UCRZGate"}: + if gate_name in {"Initialize", "StatePreparation", "UCRXGate", "UCRYGate", "UCRZGate","diagonal"}: gate = gate_class(params) else: if gate_name == "Barrier": From a43a59f2f74830810aaa40e7d0222b92c770c47b Mon Sep 17 00:00:00 2001 From: Raghav-Bell Date: Tue, 4 Jul 2023 12:39:11 +0530 Subject: [PATCH 2/6] added release notes/add-diagonal-to-DiagonalGate-c945e0f8adcd2940 --- .../add-diagonal-to-DiagonalGate-c945e0f8adcd2940.yaml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 releasenotes/notes/add-diagonal-to-DiagonalGate-c945e0f8adcd2940.yaml diff --git a/releasenotes/notes/add-diagonal-to-DiagonalGate-c945e0f8adcd2940.yaml b/releasenotes/notes/add-diagonal-to-DiagonalGate-c945e0f8adcd2940.yaml new file mode 100644 index 000000000000..2d221e30ad5e --- /dev/null +++ b/releasenotes/notes/add-diagonal-to-DiagonalGate-c945e0f8adcd2940.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + Fixes initiation of ``DiagonalGate``. Refer to + `#10364 ` for more + details. \ No newline at end of file From 394aa1bb2f3276840a980453ea8945b2dc47732b Mon Sep 17 00:00:00 2001 From: Raghav-Bell Date: Tue, 4 Jul 2023 18:15:46 +0530 Subject: [PATCH 3/6] corrected reformatting using tox --- qiskit/qpy/binary_io/circuits.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/qiskit/qpy/binary_io/circuits.py b/qiskit/qpy/binary_io/circuits.py index 2073cd05681e..98d67d70cb87 100644 --- a/qiskit/qpy/binary_io/circuits.py +++ b/qiskit/qpy/binary_io/circuits.py @@ -279,7 +279,14 @@ def _read_instruction(file_obj, circuit, registers, custom_operations, version, gate.ctrl_state = instruction.ctrl_state gate.condition = condition_tuple else: - if gate_name in {"Initialize", "StatePreparation", "UCRXGate", "UCRYGate", "UCRZGate","diagonal"}: + if gate_name in { + "Initialize", + "StatePreparation", + "UCRXGate", + "UCRYGate", + "UCRZGate", + "diagonal", + }: gate = gate_class(params) else: if gate_name == "Barrier": From 120e8ccc251d5a37358f2d370cf5e616b35e8d49 Mon Sep 17 00:00:00 2001 From: Raghav-Bell Date: Tue, 4 Jul 2023 22:17:26 +0530 Subject: [PATCH 4/6] Added test for diagonal gate. --- test/qpy_compat/test_qpy.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/qpy_compat/test_qpy.py b/test/qpy_compat/test_qpy.py index 2a4b112e1508..a3015ab7a603 100755 --- a/test/qpy_compat/test_qpy.py +++ b/test/qpy_compat/test_qpy.py @@ -574,6 +574,13 @@ def generate_open_controlled_gates(): return circuits +def generate_diagonal_gate_circuit(): + """Generate diagonal gate circuit.""" + diagonal_circuit = QuantumCircuit(2, name="diagonal_circuit") + diagonal_circuit.diagonal([1, -1, -1, 1], [0, 1]) + return diagonal_circuit + + def generate_circuits(version_parts): """Generate reference circuits.""" output_circuits = { From c07984cd404b6f5dee9d1841f5b8162df5ec1967 Mon Sep 17 00:00:00 2001 From: Raghav <83136390+Raghav-Bell@users.noreply.github.com> Date: Tue, 15 Aug 2023 15:23:31 +0530 Subject: [PATCH 5/6] Updated dynamical_decoupling.py Removed _mod2pi --- .../transpiler/passes/scheduling/dynamical_decoupling.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/qiskit/transpiler/passes/scheduling/dynamical_decoupling.py b/qiskit/transpiler/passes/scheduling/dynamical_decoupling.py index 5b17ca52d190..49e644951075 100644 --- a/qiskit/transpiler/passes/scheduling/dynamical_decoupling.py +++ b/qiskit/transpiler/passes/scheduling/dynamical_decoupling.py @@ -257,7 +257,7 @@ def run(self, dag): if gate is not None: new_dag.apply_operation_back(gate, [dag_qubit]) - new_dag.global_phase = _mod_2pi(new_dag.global_phase + sequence_gphase) + new_dag.global_phase = new_dag.global_phase + sequence_gphase return new_dag @@ -268,9 +268,3 @@ def __gate_supported(self, gate: Gate, qarg: int) -> bool: return False -def _mod_2pi(angle: float, atol: float = 0): - """Wrap angle into interval [-π,π). If within atol of the endpoint, clamp to -π""" - wrapped = (angle + np.pi) % (2 * np.pi) - np.pi - if abs(wrapped - np.pi) < atol: - wrapped = -np.pi - return wrapped From 8ad427ed3a81eddca616e7d6da91b8df9837ea92 Mon Sep 17 00:00:00 2001 From: Raghav-Bell Date: Tue, 15 Aug 2023 15:56:59 +0530 Subject: [PATCH 6/6] Added release notes. --- .../notes/fix-param-global-phase-300dacb389d2f26c.yaml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 releasenotes/notes/fix-param-global-phase-300dacb389d2f26c.yaml diff --git a/releasenotes/notes/fix-param-global-phase-300dacb389d2f26c.yaml b/releasenotes/notes/fix-param-global-phase-300dacb389d2f26c.yaml new file mode 100644 index 000000000000..b32966ebd6ea --- /dev/null +++ b/releasenotes/notes/fix-param-global-phase-300dacb389d2f26c.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - | + 2pi wrapping cannot be applied on a parameterized global phase.Use the + DAGCircuit global_phase setter to wrap the phase for floats only.Refer to + `#10569 ` for more + details. \ No newline at end of file