Comments (6)
Hello @abhishekabhishek, thank you for double checking!
Your understanding of the problem is correct, you should remove the limitation concerning those measurements. And yes the main issue is that wires needs to be translated to operators and it seems that you are on a good track!
Let me know if anything is not clear
from pennylane.
Hi @abhishekabhishek, with the old device it is indeed part of the pipeline and called under the hood. With the new device it is not used and split non commuting is not necessary because it can handle non commuting measurements.
I would suggest to mainly use the transform directly on a tape (qml.tape.QuantumTape) and for integration testing you can apply it directly on the QNode. Even if it is not necessary, the transform will be applied as part of the transform program.
@qml.qnode(dev)
def circuit(params):
qml.RX(params[0], wires=0)
qml.RY(params[1], wires=1)
return qml.expval(qml.PauliZ(0) @ qml.PauliZ(1)), qml.expval(qml.PauliY(0)))
split_non_commuting(circuit)([0.1, 0.2])
In the test that you showed, I would suggest to explicitly apply the transform on the QNodes.
Let me know it that helps!
from pennylane.
Hi @Alex-Preciado,
I am currently working on this issue and just wanted to double check my understanding to make sure I'm on the right path. As I understand currently, the issue is the following:
Consider the following qnode:
dev = qml.device("default.qubit", wires=2)
@qml.qnode(dev)
def circuit(x):
qml.RX(x,wires=0)
return qml.probs(wires=[0, 1]), qml.expval(qml.PauliZ(0)), qml.expval(qml.PauliX(0))
>>> print(qml.draw(circuit)(0.5))
0: ──RX(0.50)─┤ ╭Probs <Z> <X>
1: ───────────┤ ╰Probs
Applying circuit = qml.transforms.split_non_commuting(circuit)
should return a circuit s.t.
>>> print(qml.draw(circuit)(0.5))
0: ──RX(0.50)─┤ ╭Probs <Z>
1: ───────────┤ ╰Probs
\
0: ──RX(0.50)─┤ <X>
1: ───────────┤
But the transform currently doesn't support SampleMP
, ProbabilityMP
or CountsMP
which can take either wires
or obs
. I think I have a solution which I'm currently implementing and testing i.e. using qml.PauliZ(wires[0])@qml.PauliZ(wires[1])@[email protected](wires[len(wires)-1])
as observables when either of these are used only with wires
argument and I'm looking into the reorder_fn
to determine if I need to make any changes to it.
Please let me know if you think I missed something 🙂
Cheers,
Abhi
from pennylane.
Hi @abhishekabhishek , thank you so much for looking into this 🚀 . @rmoyard will be providing some guidance here shortly.
from pennylane.
Thanks @rmoyard, I am currently writing tests for the modified transform but got a little confused by the existing integration and autodiff tests for e.g. the one below:
pennylane/tests/transforms/test_split_non_commuting.py
Lines 288 to 311 in f435f87
It seems that in this test, the split_non_commuting
transform does not get called on the Qnode. Am I missing something here? Does the transform automatically gets applied to the Qnode when more than one expval
are returned?
from pennylane.
Closed by #4972
from pennylane.
Related Issues (20)
- [BUG] `ValueError: Unrecognized keyword arguments passed to KerasLayer: {'dynamic': True}` HOT 1
- [BUG] Various `Operator.pow` methods with a batched exponent fail
- [BUG] `param_shift` with `broadcast=True` does not work with zero-length recipes HOT 1
- Add `StateMeasurement.process_density_matrix` method
- [BUG] Issues with `metric_tensor` and trainable params causing errors with jax
- Improve operator support for new `assert_equal` function: Group 1
- Improve measurement support in from_qasm
- Support native measurement-based snapshots in Default Clifford
- Improve operator support for new `assert_equal` function: Group 2
- Add a QutritChannel operation
- [BUG] Error when using `PauliRot` and `torch` interface HOT 3
- PennyLane Torch Implementation Question HOT 5
- Issue when using batched data on StronglyEntanglingLayers template.[BUG] HOT 2
- [BUG] `sum_expand` producing incorrect result dimensions
- [BUG] lighthing.qubit torch layer batch size issue HOT 1
- [BUG] Specs does not take into account transforms HOT 2
- How to support Prod observables in custom devices? HOT 1
- [BUG] Can't differentiate `dynamic_one_shot` with `autograd` and `jax` HOT 1
- [BUG] `dynamic_one_shot` does not work with TensorFlow HOT 1
- [BUG] CNOT decomposes to CNOT
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pennylane.