How to return a cudaq.qvector after measuring ancillas #1671
Unanswered
babreu-ncsa
asked this question in
Q&A
Replies: 1 comment
-
I know I get the state I want because if I add
I get something like
when I sample the kernel so |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm building quantum states for distributed algorithms. One of the nodes in my network is an entanglement generator (G) that can send quantum states (qubits) to all other nodes. In this particular case, G creates a 4-qubit entangled state$\lvert \Psi \rangle$ and passes two to node A, one to node B, and another one to node C. This is just for context.
It happens that$\lvert \Psi \rangle$ is a superposition of states $\lvert \Psi \rangle = \lvert \Phi_1 \rangle + \lvert \Phi_2 \rangle$ and I know the circuits $C_i$ that generate $\lvert \Phi_i \rangle$ , so I'm using controlled boxes and a rotated ancilla to tune the superposition. However, the state I want only is generated when the ancilla is measured at a certain state. So I want to build a
cudaq.kernel
that measures the ancilla and, if I get the right value, it returns me the quantum state with the remaining qubits. I'm not sure how to do this.Here's what I have:
I think I need some logic at the end of$Z$ -measured but I can't really find in the documentation how to handle kernel returns (does a kernel always need to be measured in the end?) and if I write
superpose()
to returnregister
given the ancilla state whendef superpose() -> cudaq.qvector:
toreturn register
in the end (even without the postselection) I get errors likeAny comments and suggestions are welcome! Thanks!!!
Beta Was this translation helpful? Give feedback.
All reactions