Intel® Quantum SDK
Forum related to Intel Quantum SDK, a full-stack software kit for programming and executing algorithms on simulated quantum hardware.
38 Discussions

passing measurement results to gate parameters

zgural
Beginner
594 Views

Is there a way to pass the result of a measurement (a cbit) to subsequent gates?

For instance, in a teleportation algorithm the result of a measurement by Alice is used by Bob to choose a unitary operation to reconstruct the teleported state.

So is there a way to pass a cbit to a quantum_shared_double_array?

 

0 Kudos
1 Reply
KevinR_Intel
Moderator
590 Views

What a timely question! We explicitly addressed this concern in the update to the Intel(R) Quantum SDK that was released to the Intel DevCloud today. The new section from the README and associated example explain the constraints on what you want to accomplish.

(Also note that quantum_shared_double_array has been deprecated as the parameterized quantum gates will now work correctly with locally defined variables of the correct type.)

 

-------------------------------------------------------------------------------
# In-lining & quantum_kernels
-------------------------------------------------------------------------------

When the compiler prepares a quantum_kernel, it separates all the quantum
details from the classical details so that it can deliver a complete set
of instructions to the quantum hardware.

Local declarations and operations with traditional C++ data types are supported
to aid readability and preserve programming concepts. But the compiler does the
work to pull these 'classical' instructions out of the quantum_kernel. This has
a consequence on the cbit data type:
Any operation done with 'cbit' types written inside a quantum_kernel will occur
as though they are at the beginning of that quantum_kernel, unless they are
written after the final quantum gate in the quantum_kernel.

qbit q0;
qbit q1;

quantum_kernel void my_kernel() {
cbit c = 0;
std::cout << "c has value 0 here after initialization: "
<< (int)c << "\n";
PrepZ(q0);
X(q0);
MeasZ(q0,c);
std::cout << "c still has value 0 here since the quantum_kernel is not complete: "
<< (int)c << "\n";
PrepZ(q1);
std::cout << "After all gates in quantum_kernel have executed, c has value 1: "
<< (int)c << "\n";
}
0 Kudos
Reply