Skip to content

retire harmony (remove defaults) #112

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

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/devices.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ installed, you can use this device directly in PennyLane by specifying ``"ionq.q
import pennylane as qml
from pennylane_ionq import ops

dev = qml.device("ionq.qpu", backend="harmony", wires=2)
dev = qml.device("ionq.qpu", backend="aria-1", wires=2)

@qml.qnode(dev)
def circuit(x, y):
Expand Down
17 changes: 4 additions & 13 deletions pennylane_ionq/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
# and therefore does not support the Hermitian observable.
observables = {"PauliX", "PauliY", "PauliZ", "Hadamard", "Identity", "Prod"}

def __init__(

Check notice on line 130 in pennylane_ionq/device.py

View check run for this annotation

codefactor.io / CodeFactor

pennylane_ionq/device.py#L130

Too many arguments (8/5) (too-many-arguments)
self,
wires,
*,
Expand Down Expand Up @@ -171,13 +171,6 @@
}
if self.error_mitigation is not None:
self.job["error_mitigation"] = self.error_mitigation
if self.job["target"] == "qpu":
self.job["target"] = "qpu.harmony"
warnings.warn(
"The ionq_qpu backend is deprecated. Defaulting to ionq_qpu.harmony.",
UserWarning,
stacklevel=2,
)

def set_current_circuit_index(self, circuit_index):
"""Sets the index of the current circuit for which operations are applied upon.
Expand Down Expand Up @@ -274,7 +267,7 @@
if len(operations) == 0 and len(rotations) == 0:
warnings.warn("Circuit is empty. Empty circuits return failures. Submitting anyway.")

for i, operation in enumerate(operations):

Check notice on line 270 in pennylane_ionq/device.py

View check run for this annotation

codefactor.io / CodeFactor

pennylane_ionq/device.py#L270

Unused variable 'i' (unused-variable)
self._apply_operation(operation, circuit_index)

# diagonalize observables
Expand All @@ -299,7 +292,7 @@
if len(operations) == 0 and len(rotations) == 0:
warnings.warn("Circuit is empty. Empty circuits return failures. Submitting anyway.")

for i, operation in enumerate(operations):

Check notice on line 295 in pennylane_ionq/device.py

View check run for this annotation

codefactor.io / CodeFactor

pennylane_ionq/device.py#L295

Unused variable 'i' (unused-variable)
self._apply_operation(operation)

# diagonalize observables
Expand Down Expand Up @@ -459,8 +452,8 @@
or iterable that contains unique labels for the subsystems as numbers (i.e., ``[-1, 0, 2]``)
or strings (``['ancilla', 'q1', 'q2']``).
gateset (str): the target gateset, either ``"qis"`` or ``"native"``. Defaults to ``qis``.
backend (str): Optional specifier for an IonQ backend. Can be ``"harmony"``, ``"aria-1"``, etc.
Default to ``harmony``.
backend (str): Optional specifier for an IonQ backend. Can be ``"aria-1"``, ``"forte-1"``, etc.
Defaults to ``"aria-1"``.
shots (int, list[int]): Number of circuit evaluations/random samples used to estimate
expectation values of observables. Defaults to 1024. If a list of integers is passed, the
circuit evaluations are batched over the list of shots.
Expand All @@ -480,21 +473,19 @@
name = "IonQ QPU PennyLane plugin"
short_name = "ionq.qpu"

def __init__(

Check notice on line 476 in pennylane_ionq/device.py

View check run for this annotation

codefactor.io / CodeFactor

pennylane_ionq/device.py#L476

Too many arguments (8/5) (too-many-arguments)
self,
wires,
*,
gateset="qis",
shots=1024,
backend="harmony",
backend="aria-1",
error_mitigation=None,
sharpen=None,
api_key=None,
):
target = "qpu"
self.backend = backend
if self.backend is not None:
target += "." + self.backend
target = f"qpu.{self.backend}"
super().__init__(
wires=wires,
target=target,
Expand Down
17 changes: 16 additions & 1 deletion tests/test_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,22 @@ def test_prob_no_results(self, d):
dev = qml.device(d, wires=1, shots=1)
assert dev.prob is None

@pytest.mark.parametrize("backend", ["harmony", "aria-1", "aria-2", "forte-1", None])
def test_probability(self):
"""Test that device.probability works."""
dev = qml.device("ionq.simulator", wires=2)
dev.target_device._samples = np.array([[1, 1], [1, 1], [0, 0], [0, 0]])
assert np.array_equal(dev.probability(shot_range=(0, 2)), [0, 0, 0, 1])

uniform_prob = [0.25] * 4
with patch(
"pennylane_ionq.device.SimulatorDevice.prob", new_callable=PropertyMock
) as mock_prob:
mock_prob.return_value = uniform_prob
assert np.array_equal(dev.probability(), uniform_prob)

@pytest.mark.parametrize(
"backend", ["aria-1", "aria-2", "forte-1", None]
)
def test_backend_initialization(self, backend):
"""Test that the device initializes with the correct backend."""
dev = qml.device(
Expand Down
Loading