If I have created a quantum circuit that stores some data, how can I use measurements to sequentially output this data for subsequent experimental use, rather than using qml.state()
to output all the data at once?
Hi @sun,
PennyLane has many options for measurements. You can find them in the docs here. Some of the most common ones are qml.expval(), qml.sample(), and qml.probs().
For expval
you must specify an operator, for example qml.Z(0)
. In this case you’d be measuring in the computational basis, and you’d just be measuring wire zero.
I’m not exactly sure of what you’re looking to do but it sounds like maybe what you’re looking for is actually mid-circuit measurements. In that case you’ll find what you need in our dynamic circuits section of the docs.
I hope this helps!
Hello, thank you for your response. What I want to do is to use a quantum circuit to store some classical data. For example, suppose I store 16 data points, each of dimension 8. How can we use measurement methods to retrieve, for instance, the second data point among these 16? Is this achievable in the PennyLane framework?
Hi @sun,
In that case you’d probably want to use something like qml.QROM().
If you look into the example provided in the documentation you’ll notice that the QROM routine encodes the bitstrings. In this case BasisEmbedding is what you can use to extract any particular one. In the example if you change this to qml.BasisEmbedding(0, wires = [0,1])
, you will obtain the first bitstring at the output.
I hope this helps!
Note:
We have a demo in progress about this topic (see draft here) so stay tuned to our social media and check it out when it’s published!