Skip to content
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

[Return-types] Test Lightning forward pass #2903

Merged
merged 2 commits into from
Aug 8, 2022
Merged
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
38 changes: 19 additions & 19 deletions tests/returntypes/test_new_return_types_qnode.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import pennylane as qml

wires = [2, 3, 4]
devices = ["default.qubit", "default.mixed"]
devices = ["default.qubit", "lightning.qubit", "default.mixed"]


class TestIntegrationSingleReturn:
Expand All @@ -36,7 +36,7 @@ def circuit(x):
qml.CRX(x, wires=[0, 1])
return qml.state()

qnode = qml.QNode(circuit, dev)
qnode = qml.QNode(circuit, dev, diff_method=None)
res = qnode(0.5)

assert res.shape == (2**wires,)
Expand All @@ -52,7 +52,7 @@ def circuit(x):
qml.CRX(x, wires=[0, 1])
return qml.state()

qnode = qml.QNode(circuit, dev)
qnode = qml.QNode(circuit, dev, diff_method=None)
res = qnode(0.5)

assert res.shape == (2**wires, 2**wires)
Expand All @@ -69,7 +69,7 @@ def circuit(x):
qml.CRX(x, wires=[0, 1])
return qml.density_matrix(wires=range(0, d_wires))

qnode = qml.QNode(circuit, dev)
qnode = qml.QNode(circuit, dev, diff_method=None)
res = qnode(0.5)

assert res.shape == (2**d_wires, 2**d_wires)
Expand All @@ -85,7 +85,7 @@ def circuit(x):
qml.CRX(x, wires=[0, 1])
return qml.expval(qml.PauliZ(wires=1))

qnode = qml.QNode(circuit, dev)
qnode = qml.QNode(circuit, dev, diff_method=None)
res = qnode(0.5)

assert res.shape == ()
Expand All @@ -101,7 +101,7 @@ def circuit(x):
qml.CRX(x, wires=[0, 1])
return qml.var(qml.PauliZ(wires=1))

qnode = qml.QNode(circuit, dev)
qnode = qml.QNode(circuit, dev, diff_method=None)
res = qnode(0.5)

assert res.shape == ()
Expand All @@ -117,7 +117,7 @@ def circuit(x):
qml.CRX(x, wires=[0, 1])
return qml.vn_entropy(wires=0)

qnode = qml.QNode(circuit, dev)
qnode = qml.QNode(circuit, dev, diff_method=None)
res = qnode(0.5)

assert res.shape == ()
Expand All @@ -133,7 +133,7 @@ def circuit(x):
qml.CRX(x, wires=[0, 1])
return qml.mutual_info(wires0=[0], wires1=[1])

qnode = qml.QNode(circuit, dev)
qnode = qml.QNode(circuit, dev, diff_method=None)
res = qnode(0.5)

assert res.shape == ()
Expand All @@ -158,7 +158,7 @@ def circuit(x):
qml.CRX(x, wires=[0, 1])
return qml.probs(op=op, wires=wires)

qnode = qml.QNode(circuit, dev)
qnode = qml.QNode(circuit, dev, diff_method=None)
res = qnode(0.5)

if wires is None:
Expand Down Expand Up @@ -246,7 +246,7 @@ def circuit(x):
qml.CRX(x, wires=[0, 1])
return qml.state()

qnode = qml.QNode(circuit, dev)
qnode = qml.QNode(circuit, dev, diff_method=None)
res = qnode(tf.Variable(0.5))

assert res.shape == (2**wires, 2**wires)
Expand Down Expand Up @@ -461,7 +461,7 @@ def circuit(x):
qml.CRX(x, wires=[0, 1])
return qml.state()

qnode = qml.QNode(circuit, dev)
qnode = qml.QNode(circuit, dev, diff_method=None)
res = qnode(torch.tensor(0.5, requires_grad=True))

assert res.shape == (2**wires, 2**wires)
Expand Down Expand Up @@ -675,7 +675,7 @@ def circuit(x):
qml.CRX(x, wires=[0, 1])
return qml.state()

qnode = qml.QNode(circuit, dev)
qnode = qml.QNode(circuit, dev, diff_method=None)
res = qnode(jax.numpy.array(0.5))

assert res.shape == (2**wires, 2**wires)
Expand Down Expand Up @@ -854,7 +854,7 @@ def circuit(x):

wires = [([0], [1]), ([1], [0]), ([0], [0]), ([1], [1])]

devices = ["default.qubit", "default.mixed"]
devices = ["default.qubit", "lightning.qubit", "default.mixed"]


class TestIntegrationMultipleReturns:
Expand All @@ -872,7 +872,7 @@ def circuit(x):
qml.CRX(x, wires=[0, 1])
return qml.expval(qml.Projector([0], wires=0)), qml.expval(qml.PauliZ(wires=1))

qnode = qml.QNode(circuit, dev)
qnode = qml.QNode(circuit, dev, diff_method=None)
res = qnode(0.5)

assert isinstance(res, tuple)
Expand All @@ -894,7 +894,7 @@ def circuit(x):
qml.CRX(x, wires=[0, 1])
return qml.var(qml.PauliZ(wires=0)), qml.var(qml.Hermitian([[1, 0], [0, 1]], wires=1))

qnode = qml.QNode(circuit, dev)
qnode = qml.QNode(circuit, dev, diff_method=None)
res = qnode(0.5)

assert isinstance(res, tuple)
Expand Down Expand Up @@ -929,7 +929,7 @@ def circuit(x):
qml.CRX(x, wires=[0, 1])
return qml.probs(op=op1, wires=wires1), qml.probs(op=op2, wires=wires2)

qnode = qml.QNode(circuit, dev)
qnode = qml.QNode(circuit, dev, diff_method=None)
res = qnode(0.5)

assert isinstance(res, tuple)
Expand Down Expand Up @@ -964,7 +964,7 @@ def circuit(x):
qml.expval(qml.PauliZ(wires=wires4)),
)

qnode = qml.QNode(circuit, dev)
qnode = qml.QNode(circuit, dev, diff_method=None)
res = qnode(0.5)

if wires1 is None:
Expand Down Expand Up @@ -1045,7 +1045,7 @@ def circuit(x):
qml.CRX(x, wires=[0, 1])
return [qml.expval(qml.PauliZ(wires=0))]

qnode = qml.QNode(circuit, dev)
qnode = qml.QNode(circuit, dev, diff_method=None)
res = qnode(0.5)

assert isinstance(res, list)
Expand Down Expand Up @@ -2354,7 +2354,7 @@ def circuit(x):
qml.CRX(x, wires=[0, 1])
return qml.apply(meas1), qml.apply(meas2)

qnode = qml.QNode(circuit, dev)
qnode = qml.QNode(circuit, dev, diff_method=None)
res = qnode(0.5)

all_shots = sum([shot_tuple.copies for shot_tuple in dev.shot_vector])
Expand Down