I want to use the sf.ops.MeasureThreshold in pennylane, how do I go forward with it?
This is what I am doing presently, but it won’t work as MeasureThreshold does not take a wires argument.
qml.Beamsplitter(0, 0, wires=["wire-1", "wire-2"])
qml.Displacement(beta, 0, wires="wire-1")
Hi @say4n! Thank you for your question!
The way you’re using it will have several problems because effectively MeasureThreshold doesn’t take wires as an argument, but also expval can only take an input that inherits from the PennyLane class Obervable, meaning you can’t use MeasureThreshold.
If you try this code you will see that MeasureThreshold is the wrong type.
import pennylane as qml
import strawberryfields as sf`
dev = qml.device("strawberryfields.fock", wires=2, cutoff_dim=10)
qml.Beamsplitter(0, 0, wires=[0, 1])
qml.Displacement(beta, 0, wires=0)
print("MT type: ",type(sf.ops.MeasureThreshold(select=)))
MeasureThreshold is very similar to MeasureFock so maybe this tutorial can help you.
Please let me know if this helps!
In case it is useful, here is a minimum working example of using
sf.ops.MeasureThreshold() in StrawberryFields.
import numpy as np
import strawberryfields as sf
prog = sf.Program(1)
with prog.context as q:
sf.ops.Sgate(0.7) | q
sf.ops.MeasureThreshold() | q
eng = sf.Engine('gaussian')
result = eng.run(prog)
Hi @CatalinaAlbornoz and @Diego thank you so much from the prompt responses, I could not revert back earlier as I was travelling.
I look forward to trying out your proposed solutions and asking more questions in the forums!
Hi @say4n, I hope your trip went well! Let us know how it goes trying out Diego’s solution