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

how can I check the probability of a state?

KevinR_Intel
Moderator
555 Views

A question from email communication:

Previously when we executed the code, the probability of the qubit states was shown in the result file. But now I could not see the probability of the qubit. So how can I check that?

0 Kudos
1 Solution
KevinR_Intel
Moderator
523 Views

[Response edited. In the version 1.0 release, we updated the names of the methods to conform to LLVM coding style:  getProbabilities, displayProbabilities, and getSamples.]

 

In an earlier release, we changed the SDK to no longer automatically write out the results of the quantum simulator [for performance reasons]. Instead, we added a class that represents the simulator in your code. And that class has two methods to interact directly with the probabilities from the simulator.

 

If you want to use the probabilities in your C++ code to perform some calculation or analysis, you need the getProbabilities method. On the other hand, if you only want to read them, e.g. during programming a quantum_kernel, you might compile and run just to confirm your intuition about the step you are writing, then you the displayProbabilities is the right choice. And nothing prevents you from using them both.

 

One last consideration:  remember that this method is an unrealizable way of getting results—i.e. real quantum hardware will not report the probability of a given state back. In that case, you will need an ensemble of measurement to reconstruct the probabilities. You can also simulate that workflow by using the getSamples method to generate many, many measurement results (while only having to run the quantum_kernel once).

View solution in original post

1 Reply
KevinR_Intel
Moderator
524 Views

[Response edited. In the version 1.0 release, we updated the names of the methods to conform to LLVM coding style:  getProbabilities, displayProbabilities, and getSamples.]

 

In an earlier release, we changed the SDK to no longer automatically write out the results of the quantum simulator [for performance reasons]. Instead, we added a class that represents the simulator in your code. And that class has two methods to interact directly with the probabilities from the simulator.

 

If you want to use the probabilities in your C++ code to perform some calculation or analysis, you need the getProbabilities method. On the other hand, if you only want to read them, e.g. during programming a quantum_kernel, you might compile and run just to confirm your intuition about the step you are writing, then you the displayProbabilities is the right choice. And nothing prevents you from using them both.

 

One last consideration:  remember that this method is an unrealizable way of getting results—i.e. real quantum hardware will not report the probability of a given state back. In that case, you will need an ensemble of measurement to reconstruct the probabilities. You can also simulate that workflow by using the getSamples method to generate many, many measurement results (while only having to run the quantum_kernel once).

Reply