Hello, attached code is an example code from qml.measure().
If I plot the function by the attached code, I will get a figure without mid-measurement of wires=1.
However, if I comment (add #) qml.qnode(dev), I will get a figure with mid-measurement correctly.
My questions are listed below:
(1) I wonder whether qml.measure support lightning.qubit.
Since I delete qml.cond(), the returned probability changes.
Then, it validates that the qml.cond() indeed works.
import pennylane as qml
import os
dev = qml.device("lightning.qubit", wires=2)
qml.qnode(dev)
def func(x, y):
qml.Hadamard(0)
qml.CNOT(wires=[0, 1])
m_0 = qml.measure(1)
qml.cond(m_0, qml.RY)(y, wires=0)
return qml.probs(wires=[0])
x = 1
y = 0.3
fig, ax = qml.draw_mpl(func)(x, y)
fig.savefig(os.path.join(os.getcwd(), "QNN_ex.jpg"))
(2)The note from qml.cond states that:
If the first argument of cond is a measurement value (e.g., m_0 in qml.cond(m_0, qml.RY)), then m_0 == 1 is considered internally.
Can I say that qml.cond implements qml.RY no matter what the mid-measurement value is?
Then, what does the mid-measurement operation affect wires=0?
***The environment I used:
Name: PennyLane
Version: 0.33.1
Summary: PennyLane is a Python quantum machine learning library by Xanadu Inc.
Home-page: https://github.com/PennyLaneAI/pennylane
Author:
Author-email:
License: Apache License 2.0
Location: /home/ihcl10f/anaconda3/envs/GJ_0122/lib/python3.8/site-packages
Requires: appdirs, autograd, autoray, cachetools, networkx, numpy, pennylane-lightning, requests, rustworkx, scipy, semantic-version, toml, typing-extensions
Required-by: PennyLane-Lightning
Platform info: Linux-6.5.0-14-generic-x86_64-with-glibc2.17
Python version: 3.8.18
Numpy version: 1.24.4
Scipy version: 1.10.1
Installed devices:
- default.gaussian (PennyLane-0.33.1)
- default.mixed (PennyLane-0.33.1)
- default.qubit (PennyLane-0.33.1)
- default.qubit.autograd (PennyLane-0.33.1)
- default.qubit.jax (PennyLane-0.33.1)
- default.qubit.legacy (PennyLane-0.33.1)
- default.qubit.tf (PennyLane-0.33.1)
- default.qubit.torch (PennyLane-0.33.1)
- default.qutrit (PennyLane-0.33.1)
- null.qubit (PennyLane-0.33.1)
- lightning.qubit (PennyLane-Lightning-0.33.1)
None
Thanks for replying in advance!