From 2cd8945befd74a98fa7dda0ff5590e2d4647e8d3 Mon Sep 17 00:00:00 2001 From: jon donovan Date: Fri, 6 May 2022 14:34:43 -0700 Subject: [PATCH 01/11] Update unitary for IonQ MS Gate --- cirq-ionq/cirq_ionq/ionq_native_gates.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cirq-ionq/cirq_ionq/ionq_native_gates.py b/cirq-ionq/cirq_ionq/ionq_native_gates.py index e9313b0c43a..4c79da4bc8d 100644 --- a/cirq-ionq/cirq_ionq/ionq_native_gates.py +++ b/cirq-ionq/cirq_ionq/ionq_native_gates.py @@ -186,13 +186,13 @@ def _value_equality_values_(self) -> Any: MS, """The MS gate is a 2 qubit gate. The unitary of this gate is - MS(\\phi_1 - \\phi_0) = - MS(t) = - \\frac{1}{\\sqrt{2}} - [[\\cos(t), 0, 0, -i*\\sin(t)], - [0, \\cos(t), -i*\\sin(t), 0], - [0, -i*\\sin(t), \\cos(t), 0], - [-i*\\sin(t), 0, 0, \\cos(t)]] + .. math:: + MS(\phi_0, _\phi_1) q_0, q_1 = + \frac{1}{\sqrt{2}}\begin{pmatrix} + 1 & 0 & 0 & -i*e^(-i*(\phi_0+\phi_1) \\ + 0 & 1 & -i*e^(-i*(\phi_0-\phi_1) & 0 \\ + 0 & -i*e^(i*(\phi_0-\phi_1) & 1 & 0 \\ + -i*e^(i*(\phi_0+\phi_1) & 0 & 0 & 1 https://ionq.com/best-practices """, From 7f5f286534886ec1b1188a123e4545bca4f999a2 Mon Sep 17 00:00:00 2001 From: jon donovan Date: Fri, 6 May 2022 14:37:00 -0700 Subject: [PATCH 02/11] Whoops, diff format --- cirq-ionq/cirq_ionq/ionq_native_gates.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cirq-ionq/cirq_ionq/ionq_native_gates.py b/cirq-ionq/cirq_ionq/ionq_native_gates.py index 4c79da4bc8d..d3e3a0f7126 100644 --- a/cirq-ionq/cirq_ionq/ionq_native_gates.py +++ b/cirq-ionq/cirq_ionq/ionq_native_gates.py @@ -188,11 +188,11 @@ def _value_equality_values_(self) -> Any: The unitary of this gate is .. math:: MS(\phi_0, _\phi_1) q_0, q_1 = - \frac{1}{\sqrt{2}}\begin{pmatrix} - 1 & 0 & 0 & -i*e^(-i*(\phi_0+\phi_1) \\ - 0 & 1 & -i*e^(-i*(\phi_0-\phi_1) & 0 \\ - 0 & -i*e^(i*(\phi_0-\phi_1) & 1 & 0 \\ - -i*e^(i*(\phi_0+\phi_1) & 0 & 0 & 1 + \frac{1}{\sqrt{2}} + [[1, 0, 0, -i*e^(-i*(\phi_0+\phi_1)], + [0, 1, -i*e^(-i*(\phi_0-\phi_1), 0], + [0, -i*e^(i*(\phi_0-\phi_1), 1, 0], + [-i*e^(i*(\phi_0+\phi_1), 0, 0, 1]] https://ionq.com/best-practices """, From cd49f10935f880aa6400ee11c524e88efb46c68c Mon Sep 17 00:00:00 2001 From: jon donovan Date: Fri, 6 May 2022 14:38:49 -0700 Subject: [PATCH 03/11] minor format --- cirq-ionq/cirq_ionq/ionq_native_gates.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cirq-ionq/cirq_ionq/ionq_native_gates.py b/cirq-ionq/cirq_ionq/ionq_native_gates.py index d3e3a0f7126..17974573a7a 100644 --- a/cirq-ionq/cirq_ionq/ionq_native_gates.py +++ b/cirq-ionq/cirq_ionq/ionq_native_gates.py @@ -186,8 +186,7 @@ def _value_equality_values_(self) -> Any: MS, """The MS gate is a 2 qubit gate. The unitary of this gate is - .. math:: - MS(\phi_0, _\phi_1) q_0, q_1 = + MS(\phi_0, _\phi_1) q_0, q_1 = \frac{1}{\sqrt{2}} [[1, 0, 0, -i*e^(-i*(\phi_0+\phi_1)], [0, 1, -i*e^(-i*(\phi_0-\phi_1), 0], From 79154ca1191726e32e365e9ca844f167570c4045 Mon Sep 17 00:00:00 2001 From: jon donovan Date: Fri, 6 May 2022 14:40:01 -0700 Subject: [PATCH 04/11] also minor fixup --- cirq-ionq/cirq_ionq/ionq_native_gates.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cirq-ionq/cirq_ionq/ionq_native_gates.py b/cirq-ionq/cirq_ionq/ionq_native_gates.py index 17974573a7a..575cc2551f6 100644 --- a/cirq-ionq/cirq_ionq/ionq_native_gates.py +++ b/cirq-ionq/cirq_ionq/ionq_native_gates.py @@ -188,10 +188,10 @@ def _value_equality_values_(self) -> Any: The unitary of this gate is MS(\phi_0, _\phi_1) q_0, q_1 = \frac{1}{\sqrt{2}} - [[1, 0, 0, -i*e^(-i*(\phi_0+\phi_1)], - [0, 1, -i*e^(-i*(\phi_0-\phi_1), 0], - [0, -i*e^(i*(\phi_0-\phi_1), 1, 0], - [-i*e^(i*(\phi_0+\phi_1), 0, 0, 1]] + [[1, 0, 0, -i*e^{-i*(\phi_0+\phi_1}], + [0, 1, -i*e^{-i*(\phi_0-\phi_1}, 0], + [0, -i*e^{i*(\phi_0-\phi_1}, 1, 0], + [-i*e^{i*(\phi_0+\phi_1}, 0, 0, 1]] https://ionq.com/best-practices """, From 989bba246b9688478e0110203c26608144e5dd9c Mon Sep 17 00:00:00 2001 From: jon donovan Date: Fri, 6 May 2022 14:49:21 -0700 Subject: [PATCH 05/11] Math mode please --- cirq-ionq/cirq_ionq/ionq_native_gates.py | 1 + 1 file changed, 1 insertion(+) diff --git a/cirq-ionq/cirq_ionq/ionq_native_gates.py b/cirq-ionq/cirq_ionq/ionq_native_gates.py index 575cc2551f6..33a8000b758 100644 --- a/cirq-ionq/cirq_ionq/ionq_native_gates.py +++ b/cirq-ionq/cirq_ionq/ionq_native_gates.py @@ -186,6 +186,7 @@ def _value_equality_values_(self) -> Any: MS, """The MS gate is a 2 qubit gate. The unitary of this gate is + .. math:: MS(\phi_0, _\phi_1) q_0, q_1 = \frac{1}{\sqrt{2}} [[1, 0, 0, -i*e^{-i*(\phi_0+\phi_1}], From 6570e65b104c00390f4fc907d6d22d1add5b487b Mon Sep 17 00:00:00 2001 From: jon donovan Date: Fri, 6 May 2022 14:52:28 -0700 Subject: [PATCH 06/11] Escape \ --- cirq-ionq/cirq_ionq/ionq_native_gates.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cirq-ionq/cirq_ionq/ionq_native_gates.py b/cirq-ionq/cirq_ionq/ionq_native_gates.py index 33a8000b758..c138a050614 100644 --- a/cirq-ionq/cirq_ionq/ionq_native_gates.py +++ b/cirq-ionq/cirq_ionq/ionq_native_gates.py @@ -187,12 +187,12 @@ def _value_equality_values_(self) -> Any: """The MS gate is a 2 qubit gate. The unitary of this gate is .. math:: - MS(\phi_0, _\phi_1) q_0, q_1 = - \frac{1}{\sqrt{2}} - [[1, 0, 0, -i*e^{-i*(\phi_0+\phi_1}], - [0, 1, -i*e^{-i*(\phi_0-\phi_1}, 0], - [0, -i*e^{i*(\phi_0-\phi_1}, 1, 0], - [-i*e^{i*(\phi_0+\phi_1}, 0, 0, 1]] + MS(\\phi_0, \\phi_1) q_0, q_1 = + \\frac{1}{\\sqrt{2}} + [[1, 0, 0, -i*e^{-i*(\\phi_0+\\phi_1}], + [0, 1, -i*e^{-i*(\\phi_0-\\phi_1}, 0], + [0, -i*e^{i*(\\phi_0-\\phi_1}, 1, 0], + [-i*e^{i*(\\phi_0+\\phi_1}, 0, 0, 1]] https://ionq.com/best-practices """, From a38ad88d1ceed3ecad144726d5fa42a965be7a80 Mon Sep 17 00:00:00 2001 From: jon donovan Date: Fri, 6 May 2022 14:59:07 -0700 Subject: [PATCH 07/11] Use r strings --- cirq-ionq/cirq_ionq/ionq_native_gates.py | 53 ++++++++++++------------ 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/cirq-ionq/cirq_ionq/ionq_native_gates.py b/cirq-ionq/cirq_ionq/ionq_native_gates.py index c138a050614..13b8fb159f7 100644 --- a/cirq-ionq/cirq_ionq/ionq_native_gates.py +++ b/cirq-ionq/cirq_ionq/ionq_native_gates.py @@ -25,10 +25,10 @@ @cirq.value.value_equality class GPIGate(cirq.Gate): - """The GPI gate is a single qubit gate. + r"""The GPI gate is a single qubit gate. The unitary of this gate is - [[0, e^{-i\\phi}], - [e^{-i\\phi}, 0]] + [[0, e^{-i\phi}], + [e^{-i\phi}, 0]] """ def __init__(self, *, phi): @@ -67,10 +67,10 @@ def _circuit_diagram_info_( GPI = GPIGate(phi=0) document( GPI, - """The GPI gate is a single qubit gate. + r"""The GPI gate is a single qubit gate. The unitary of this gate is - [[0, e^{-i\\phi}], - [e^{-i\\phi}, 0]] + [[0, e^{-i\phi}], + [e^{-i\phi}, 0]] It is driven by Rabi laser. https://ionq.com/best-practices """, @@ -79,10 +79,10 @@ def _circuit_diagram_info_( @cirq.value.value_equality class GPI2Gate(cirq.Gate): - """The GPI2 gate is a single qubit gate. + r"""The GPI2 gate is a single qubit gate. The unitary of this gate is - \\frac{1}{/\\sqrt{2}}[[1, -i*e^{-i\\phi}], - [-i*e^{-i\\phi}, 1]] + \frac{1}{/\sqrt{2}}[[1, -i*e^{-i\phi}], + [-i*e^{-i\phi}, 1]] """ def __init__(self, *, phi): @@ -121,10 +121,10 @@ def _value_equality_values_(self) -> Any: GPI2 = GPI2Gate(phi=0) document( GPI2, - """The GPI2 gate is a single qubit gate. + r"""The GPI2 gate is a single qubit gate. The unitary of this gate is - \\frac{1}{/\\sqrt{2}}[[1, -i*e^{-i\\phi}], - [-i*e^{-i\\phi}, 1]] + \frac{1}{/\sqrt{2}}[[1, -i*e^{-i\phi}], + [-i*e^{-i\phi}, 1]] It is driven by Rabi laser. https://ionq.com/best-practices """, @@ -133,15 +133,14 @@ def _value_equality_values_(self) -> Any: @cirq.value.value_equality class MSGate(cirq.Gate): - """The MS gate is a 2 qubit gate. + r"""The MS gate is a 2 qubit gate. The unitary of this gate is - MS(\\phi_1 - \\phi_0) = - MS(t) = - \\frac{1}{\\sqrt{2}} - [[\\cos(t), 0, 0, -i*\\sin(t)], - [0, \\cos(t), -i*\\sin(t), 0], - [0, -i*\\sin(t), \\cos(t), 0], - [-i*\\sin(t), 0, 0, \\cos(t)]] + MS(\phi_0, \phi_1) q_0, q_1 = + \frac{1}{\sqrt{2}} + [[1, 0, 0, -i*e^{-i*(\phi_0+\phi_1}], + [0, 1, -i*e^{-i*(\phi_0-\phi_1}, 0], + [0, -i*e^{i*(\phi_0-\phi_1}, 1, 0], + [-i*e^{i*(\phi_0+\phi_1}, 0, 0, 1]] """ def __init__(self, *, phi1, phi2): @@ -184,15 +183,15 @@ def _value_equality_values_(self) -> Any: MS = MSGate(phi1=0, phi2=0) document( MS, - """The MS gate is a 2 qubit gate. + r"""The MS gate is a 2 qubit gate. The unitary of this gate is .. math:: - MS(\\phi_0, \\phi_1) q_0, q_1 = - \\frac{1}{\\sqrt{2}} - [[1, 0, 0, -i*e^{-i*(\\phi_0+\\phi_1}], - [0, 1, -i*e^{-i*(\\phi_0-\\phi_1}, 0], - [0, -i*e^{i*(\\phi_0-\\phi_1}, 1, 0], - [-i*e^{i*(\\phi_0+\\phi_1}, 0, 0, 1]] + MS(\phi_0, \phi_1) q_0, q_1 = + \frac{1}{\sqrt{2}} + [[1, 0, 0, -i*e^{-i*(\phi_0+\phi_1}], + [0, 1, -i*e^{-i*(\phi_0-\phi_1}, 0], + [0, -i*e^{i*(\phi_0-\phi_1}, 1, 0], + [-i*e^{i*(\phi_0+\phi_1}, 0, 0, 1]] https://ionq.com/best-practices """, From 739feab95af229a7be1535e2f778cdd7907615bd Mon Sep 17 00:00:00 2001 From: jon donovan Date: Mon, 9 May 2022 13:57:32 -0700 Subject: [PATCH 08/11] Units and unitaries --- cirq-ionq/cirq_ionq/ionq_native_gates.py | 48 +++++++++++++----------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/cirq-ionq/cirq_ionq/ionq_native_gates.py b/cirq-ionq/cirq_ionq/ionq_native_gates.py index 13b8fb159f7..92d0bc4f1ac 100644 --- a/cirq-ionq/cirq_ionq/ionq_native_gates.py +++ b/cirq-ionq/cirq_ionq/ionq_native_gates.py @@ -27,16 +27,16 @@ class GPIGate(cirq.Gate): r"""The GPI gate is a single qubit gate. The unitary of this gate is - [[0, e^{-i\phi}], - [e^{-i\phi}, 0]] + [[0, e^{-i*2*\pi*\phi}], + [e^{-i*2*\pi*\phi}, 0]] """ def __init__(self, *, phi): self.phi = phi def _unitary_(self) -> np.ndarray: - top = cmath.exp(self.phi * 1j) - bot = cmath.exp(-self.phi * 1j) + top = cmath.exp(self.phi * 2 * math.pi * 1j) + bot = cmath.exp(-self.phi * 2 * math.pi * 1j) return np.array([[0, top], [bot, 0]]) def __str__(self) -> str: @@ -69,8 +69,8 @@ def _circuit_diagram_info_( GPI, r"""The GPI gate is a single qubit gate. The unitary of this gate is - [[0, e^{-i\phi}], - [e^{-i\phi}, 0]] + [[0, e^{-i*2*\pi*\phi}], + [e^{-i*2*\pi*\phi}, 0]] It is driven by Rabi laser. https://ionq.com/best-practices """, @@ -89,8 +89,8 @@ def __init__(self, *, phi): self.phi = phi def _unitary_(self) -> np.ndarray: - top = -1j * cmath.exp(self.phase * -1j) - bot = -1j * cmath.exp(self.phase * 1j) + top = -1j * cmath.exp(self.phase * 2 * math.pi * -1j) + bot = -1j * cmath.exp(self.phase * 2 * math.pi * 1j) return np.array([[1, top], [bot, 1]]) / math.sqrt(2) @property @@ -123,8 +123,8 @@ def _value_equality_values_(self) -> Any: GPI2, r"""The GPI2 gate is a single qubit gate. The unitary of this gate is - \frac{1}{/\sqrt{2}}[[1, -i*e^{-i\phi}], - [-i*e^{-i\phi}, 1]] + \frac{1}{/\sqrt{2}}[[1, -i*e^{-i*2*\pi*\phi}], + [-i*e^{-i*2*\phi}, 1]] It is driven by Rabi laser. https://ionq.com/best-practices """, @@ -137,22 +137,28 @@ class MSGate(cirq.Gate): The unitary of this gate is MS(\phi_0, \phi_1) q_0, q_1 = \frac{1}{\sqrt{2}} - [[1, 0, 0, -i*e^{-i*(\phi_0+\phi_1}], - [0, 1, -i*e^{-i*(\phi_0-\phi_1}, 0], - [0, -i*e^{i*(\phi_0-\phi_1}, 1, 0], - [-i*e^{i*(\phi_0+\phi_1}, 0, 0, 1]] + [[1, 0, 0, -i*e^{-i*2*\pi*(\phi_0+\phi_1}], + [0, 1, -i*e^{-i*2*\pi*(\phi_0-\phi_1}, 0], + [0, -i*e^{i*2*\pi*(\phi_0-\phi_1}, 1, 0], + [-i*e^{i*2*\pi*(\phi_0+\phi_1}, 0, 0, 1]] """ - def __init__(self, *, phi1, phi2): + def __init__(self, *, phi0, phi1): + self.phi0 = phi0 self.phi1 = phi1 - self.phi2 = phi2 def _unitary_(self) -> np.ndarray: - tee = self.phi2 - self.phi1 - diag = math.cos(tee) - adiag = -1j * math.sin(tee) - return np.array( - [[diag, 0, 0, adiag], [0, diag, adiag, 0], [0, adiag, diag, 0], [adiag, 0, 0, diag]] + diag = 1 / math.sqrt(2) + phi0 = self.phi0 + phi1 = self.phi1 + return numpy.array( + [ + [diag, 0, 0, diag * -1j * cmath.exp(-1j * 2 * math.pi * (phi0 + phi1))], + [0, diag, diag * -1j * cmath.exp(-1j * 2 * math.pi * (phi0 - phi1)), 0], + [0, diag * -1j * cmath.exp(1j * 2 * math.pi * (phi0 - phi1)), diag, 0], + [diag * -1j * cmath.exp(1j * 2 * math.pi * (phi0 + phi1)), 0, 0, diag], + ], + dtype=dtype, ) @property From c651073dfbb868526d19a53a33014127e0a4e5b7 Mon Sep 17 00:00:00 2001 From: jon donovan Date: Mon, 9 May 2022 13:59:02 -0700 Subject: [PATCH 09/11] fixup --- cirq-ionq/cirq_ionq/ionq_native_gates.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cirq-ionq/cirq_ionq/ionq_native_gates.py b/cirq-ionq/cirq_ionq/ionq_native_gates.py index 92d0bc4f1ac..2fff3e4d591 100644 --- a/cirq-ionq/cirq_ionq/ionq_native_gates.py +++ b/cirq-ionq/cirq_ionq/ionq_native_gates.py @@ -163,7 +163,7 @@ def _unitary_(self) -> np.ndarray: @property def phases(self) -> Sequence[float]: - return [self.phi1, self.phi2] + return [self.phi0, self.phi1] def __str__(self) -> str: return 'MS' From 1204c0547c56cc13233754c530794d8c3be5b460 Mon Sep 17 00:00:00 2001 From: jon donovan Date: Mon, 9 May 2022 14:33:33 -0700 Subject: [PATCH 10/11] phi1,2 -> phi0,1 for consistency with other SDKs --- cirq-ionq/cirq_ionq/ionq_native_gates.py | 8 ++++---- cirq-ionq/cirq_ionq/ionq_native_gates_test.py | 6 +++--- cirq-ionq/cirq_ionq/json_test_data/MSGate.json | 4 ++-- cirq-ionq/cirq_ionq/json_test_data/MSGate.repr | 2 +- cirq-ionq/cirq_ionq/serializer_test.py | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cirq-ionq/cirq_ionq/ionq_native_gates.py b/cirq-ionq/cirq_ionq/ionq_native_gates.py index 2fff3e4d591..55d687d2d70 100644 --- a/cirq-ionq/cirq_ionq/ionq_native_gates.py +++ b/cirq-ionq/cirq_ionq/ionq_native_gates.py @@ -177,16 +177,16 @@ def _circuit_diagram_info_( return protocols.CircuitDiagramInfo(wire_symbols=('MS',), exponent=self.phases) def __repr__(self) -> str: - return f'cirq_ionq.MSGate(phi1={self.phi1!r}, phi2={self.phi2!r})' + return f'cirq_ionq.MSGate(phi0={self.phi0!r}, phi1={self.phi1!r})' def _json_dict_(self) -> Dict[str, Any]: - return cirq.obj_to_dict_helper(self, ['phi1', 'phi2']) + return cirq.obj_to_dict_helper(self, ['phi0', 'phi1']) def _value_equality_values_(self) -> Any: - return (self.phi1, self.phi2) + return (self.phi0, self.phi1) -MS = MSGate(phi1=0, phi2=0) +MS = MSGate(phi0=0, phi1=0) document( MS, r"""The MS gate is a 2 qubit gate. diff --git a/cirq-ionq/cirq_ionq/ionq_native_gates_test.py b/cirq-ionq/cirq_ionq/ionq_native_gates_test.py index 7e7dd425c7a..5cb98b27469 100644 --- a/cirq-ionq/cirq_ionq/ionq_native_gates_test.py +++ b/cirq-ionq/cirq_ionq/ionq_native_gates_test.py @@ -21,7 +21,7 @@ @pytest.mark.parametrize( - "gate,nqubits", [(GPIGate(phi=0.1), 1), (GPI2Gate(phi=0.2), 1), (MSGate(phi1=0.1, phi2=0.2), 2)] + "gate,nqubits", [(GPIGate(phi=0.1), 1), (GPI2Gate(phi=0.2), 1), (MSGate(phi0=0.1, phi1=0.2), 2)] ) def test_gate_methods(gate, nqubits): assert str(gate) != "" @@ -30,7 +30,7 @@ def test_gate_methods(gate, nqubits): assert cirq.protocols.circuit_diagram_info(gate) is not None -@pytest.mark.parametrize("gate", [GPIGate(phi=0.1), GPI2Gate(phi=0.2), MSGate(phi1=0.1, phi2=0.2)]) +@pytest.mark.parametrize("gate", [GPIGate(phi=0.1), GPI2Gate(phi=0.2), MSGate(phi0=0.1, phi1=0.2)]) def test_gate_json(gate): g_json = cirq.to_json(gate) assert cirq.read_json(json_text=g_json) == gate @@ -59,7 +59,7 @@ def test_gpi2_unitary(phase): ) def test_ms_unitary(phases): """Tests that the MS gate is unitary.""" - gate = MSGate(phi1=phases[0], phi2=phases[1]) + gate = MSGate(phi0=phases[0], phi1=phases[1]) mat = cirq.protocols.unitary(gate) numpy.testing.assert_array_almost_equal(mat.dot(mat.conj().T), numpy.identity(4)) diff --git a/cirq-ionq/cirq_ionq/json_test_data/MSGate.json b/cirq-ionq/cirq_ionq/json_test_data/MSGate.json index 4b2268733a4..24eea58ec5a 100644 --- a/cirq-ionq/cirq_ionq/json_test_data/MSGate.json +++ b/cirq-ionq/cirq_ionq/json_test_data/MSGate.json @@ -1,5 +1,5 @@ { "cirq_type": "MSGate", - "phi1": 0.1, - "phi2": 0.55 + "phi0": 0.1, + "phi1": 0.55 } diff --git a/cirq-ionq/cirq_ionq/json_test_data/MSGate.repr b/cirq-ionq/cirq_ionq/json_test_data/MSGate.repr index 1e1116467e1..61e1ed5152a 100644 --- a/cirq-ionq/cirq_ionq/json_test_data/MSGate.repr +++ b/cirq-ionq/cirq_ionq/json_test_data/MSGate.repr @@ -1 +1 @@ -cirq_ionq.MSGate(phi1=0.1, phi2=0.55) +cirq_ionq.MSGate(phi0=0.1, phi1=0.55) diff --git a/cirq-ionq/cirq_ionq/serializer_test.py b/cirq-ionq/cirq_ionq/serializer_test.py index 3ddca1146b3..826fca96011 100644 --- a/cirq-ionq/cirq_ionq/serializer_test.py +++ b/cirq-ionq/cirq_ionq/serializer_test.py @@ -258,7 +258,7 @@ def test_serialize_native_gates(): q0, q1, q2 = cirq.LineQubit.range(3) gpi = GPIGate(phi=0.1).on(q0) gpi2 = GPI2Gate(phi=0.2).on(q1) - ms = MSGate(phi1=0.3, phi2=0.4).on(q1, q2) + ms = MSGate(phi0=0.3, phi1=0.4).on(q1, q2) circuit = cirq.Circuit([gpi, gpi2, ms]) serializer = ionq.Serializer() result = serializer.serialize(circuit) From a3b273e7cdaee9a199302965e7d61448c998ce4b Mon Sep 17 00:00:00 2001 From: jon donovan Date: Mon, 9 May 2022 14:41:38 -0700 Subject: [PATCH 11/11] np\. --- cirq-ionq/cirq_ionq/ionq_native_gates.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cirq-ionq/cirq_ionq/ionq_native_gates.py b/cirq-ionq/cirq_ionq/ionq_native_gates.py index 55d687d2d70..80eb49df6aa 100644 --- a/cirq-ionq/cirq_ionq/ionq_native_gates.py +++ b/cirq-ionq/cirq_ionq/ionq_native_gates.py @@ -151,14 +151,13 @@ def _unitary_(self) -> np.ndarray: diag = 1 / math.sqrt(2) phi0 = self.phi0 phi1 = self.phi1 - return numpy.array( + return np.array( [ [diag, 0, 0, diag * -1j * cmath.exp(-1j * 2 * math.pi * (phi0 + phi1))], [0, diag, diag * -1j * cmath.exp(-1j * 2 * math.pi * (phi0 - phi1)), 0], [0, diag * -1j * cmath.exp(1j * 2 * math.pi * (phi0 - phi1)), diag, 0], [diag * -1j * cmath.exp(1j * 2 * math.pi * (phi0 + phi1)), 0, 0, diag], - ], - dtype=dtype, + ] ) @property