Skip to content

Commit

Permalink
Merge branch 'v0.38.0-rc0' into broadcast-expand-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
albi3ro authored Aug 27, 2024
2 parents 234f0fb + a62797c commit 473e651
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
11 changes: 11 additions & 0 deletions tests/devices/default_qubit/test_default_qubit_native_mcm.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,17 @@ def test_simple_dynamic_circuit(mcm_method, shots, measure_f, postselect, meas_o
The above combinations should work for finite shots, shot vectors and post-selecting of either the 0 or 1 branch.
"""

if (
isinstance(meas_obj, (qml.Z, qml.Y))
and measure_f == qml.var
and mcm_method == "tree-traversal"
and not qml.operation.active_new_opmath()
):
pytest.xfail(
"The tree-traversal method does not work with legacy opmath with "
"`qml.var` of pauli observables in the circuit."
)

if mcm_method == "one-shot" and shots is None:
pytest.skip("`mcm_method='one-shot'` is incompatible with analytic mode (`shots=None`)")

Expand Down
26 changes: 10 additions & 16 deletions tests/interfaces/legacy_devices_integration/test_autograd_legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ class TestBatchTransformExecution:
via qml.execute and batch_transform"""

def test_no_batch_transform(self, mocker):
"""Test that batch transforms can be disabled and enabled"""
"""Test that batch transforms cannot be disabled"""

dev = qml.device("default.qubit.legacy", wires=2, shots=100000)

H = qml.PauliZ(0) @ qml.PauliZ(1) - qml.PauliX(0)
Expand All @@ -196,23 +197,15 @@ def test_no_batch_transform(self, mocker):
qml.CNOT(wires=[0, 1])
qml.expval(H)

tape = qml.tape.QuantumScript.from_queue(q)
tape = qml.tape.QuantumScript.from_queue(q, shots=100000)
spy = mocker.spy(dev.target_device, "batch_transform")

if not qml.operation.active_new_opmath():
with pytest.raises(AssertionError, match="Hamiltonian must be used with shots=None"):
with pytest.warns(
qml.PennyLaneDeprecationWarning,
match="The device_batch_transform argument is deprecated",
):
_ = qml.execute([tape], dev, None, device_batch_transform=False)
else:
with pytest.warns(
qml.PennyLaneDeprecationWarning,
match="The device_batch_transform argument is deprecated",
):
res = qml.execute([tape], dev, None, device_batch_transform=False)
assert np.allclose(res[0], np.cos(y), atol=0.1)
with pytest.warns(
qml.PennyLaneDeprecationWarning,
match="The device_batch_transform argument is deprecated",
):
res = qml.execute([tape], dev, None, device_batch_transform=False)
assert np.allclose(res[0], np.cos(y), atol=0.1)

spy.assert_called()

Expand All @@ -221,6 +214,7 @@ def test_no_batch_transform(self, mocker):
match="The device_batch_transform argument is deprecated",
):
res = qml.execute([tape], dev, None, device_batch_transform=True)

spy.assert_called()

assert qml.math.shape(res[0]) == ()
Expand Down

0 comments on commit 473e651

Please sign in to comment.