From f354fa8d781bb0a30952c185dddb56f418364a8a Mon Sep 17 00:00:00 2001 From: JerryChen97 Date: Thu, 18 Sep 2025 10:45:09 -0400 Subject: [PATCH 1/2] Type v1 circuit --- pennylane_ionq/device.py | 2 +- tests/test_device.py | 30 ++++++++++++++++++++++++------ 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/pennylane_ionq/device.py b/pennylane_ionq/device.py index bec4b5a..a316693 100644 --- a/pennylane_ionq/device.py +++ b/pennylane_ionq/device.py @@ -164,7 +164,7 @@ def reset(self, circuits_array_length=1): self._samples = None self.histograms = [] self.input = { - "format": "ionq.circuit.v0", + "type": "ionq.circuit.v1", "qubits": self.num_wires, "circuits": [{"circuit": []} for _ in range(circuits_array_length)], "gateset": self.gateset, diff --git a/tests/test_device.py b/tests/test_device.py index e63f740..6da7426 100755 --- a/tests/test_device.py +++ b/tests/test_device.py @@ -485,7 +485,7 @@ def mock_submit_job(*args): dev.apply(tape.operations) - assert dev.job["input"]["format"] == "ionq.circuit.v0" + assert dev.job["input"]["type"] == "ionq.circuit.v1" assert dev.job["input"]["gateset"] == "qis" assert dev.job["target"] == "foo" assert dev.job["input"]["qubits"] == 1 @@ -511,7 +511,7 @@ def mock_submit_job(*args): dev.reset(circuits_array_length=1) dev.batch_apply(tape.operations, circuit_index=0) - assert dev.job["input"]["format"] == "ionq.circuit.v0" + assert dev.job["input"]["type"] == "ionq.circuit.v1" assert dev.job["input"]["gateset"] == "qis" assert dev.job["target"] == "foo" assert dev.job["input"]["qubits"] == 1 @@ -537,7 +537,7 @@ def mock_submit_job(*args): dev.apply(tape.operations) - assert dev.job["input"]["format"] == "ionq.circuit.v0" + assert dev.job["input"]["type"] == "ionq.circuit.v1" assert dev.job["input"]["gateset"] == "qis" assert dev.job["input"]["qubits"] == 1 @@ -569,7 +569,7 @@ def mock_submit_job(*args): dev.reset(circuits_array_length=1) dev.batch_apply(tape.operations, circuit_index=0) - assert dev.job["input"]["format"] == "ionq.circuit.v0" + assert dev.job["input"]["type"] == "ionq.circuit.v1" assert dev.job["input"]["gateset"] == "qis" assert dev.job["input"]["qubits"] == 1 @@ -602,7 +602,7 @@ def mock_submit_job(*args): dev.apply(tape.operations) - assert dev.job["input"]["format"] == "ionq.circuit.v0" + assert dev.job["input"]["type"] == "ionq.circuit.v1" assert dev.job["input"]["gateset"] == "native" assert dev.job["input"]["qubits"] == 3 @@ -655,7 +655,7 @@ def mock_submit_job(*args): except StopExecute: pass - assert dev.job["input"]["format"] == "ionq.circuit.v0" + assert dev.job["input"]["type"] == "ionq.circuit.v1" assert dev.job["input"]["gateset"] == "native" assert dev.job["target"] == "simulator" assert dev.job["input"]["qubits"] == 1 @@ -749,3 +749,21 @@ def test_simple_operations_controlled_gate(self, requires_api): assert np.allclose( result_ionq, result_simulator, atol=1e-5 ), "The IonQ and simulator results do not agree." + + def test_QDrift(self): + """QDrift could fail""" + dev = qml.device("ionq.simulator", wires=2, gateset="qis") + + coeffs = [0.25, 0.75] + ops = [qml.X(0), qml.Z(0)] + H = qml.dot(coeffs, ops) + + @qml.qnode(dev) + def circuit(): + qml.Hadamard(0) + qml.QDrift(H, time=1.2, n=10, seed=10) + return qml.probs() + + res = circuit() + expected = [0.65379493, 0.0, 0.34620507, 0.0] + assert np.allclose(res, expected, atol=tol(dev.shots)) \ No newline at end of file From 2bb84a2cabcc545706c2cb2fda00749b38b8489e Mon Sep 17 00:00:00 2001 From: JerryChen97 Date: Thu, 18 Sep 2025 10:51:31 -0400 Subject: [PATCH 2/2] remove my own temp test --- tests/test_device.py | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/tests/test_device.py b/tests/test_device.py index 6da7426..404998b 100755 --- a/tests/test_device.py +++ b/tests/test_device.py @@ -749,21 +749,3 @@ def test_simple_operations_controlled_gate(self, requires_api): assert np.allclose( result_ionq, result_simulator, atol=1e-5 ), "The IonQ and simulator results do not agree." - - def test_QDrift(self): - """QDrift could fail""" - dev = qml.device("ionq.simulator", wires=2, gateset="qis") - - coeffs = [0.25, 0.75] - ops = [qml.X(0), qml.Z(0)] - H = qml.dot(coeffs, ops) - - @qml.qnode(dev) - def circuit(): - qml.Hadamard(0) - qml.QDrift(H, time=1.2, n=10, seed=10) - return qml.probs() - - res = circuit() - expected = [0.65379493, 0.0, 0.34620507, 0.0] - assert np.allclose(res, expected, atol=tol(dev.shots)) \ No newline at end of file