Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output whether the final quantum state is deterministic #125

Open
pablolh opened this issue Feb 2, 2023 · 1 comment
Open

Output whether the final quantum state is deterministic #125

pablolh opened this issue Feb 2, 2023 · 1 comment

Comments

@pablolh
Copy link

pablolh commented Feb 2, 2023

For one use case it is beneficial to know in the output whether the final quantum state is deterministic.

This is a hard problem but the simulator can output a new key "guaranteed_deterministic_state" with possible values True or False. In the first case, the state is deterministic. In the second, it is not known ("maybe").

More generally the simulator, when asked N iterations on a provably deterministic circuit, should not compute the final state N times, but just once. This is a major optimization that applies to a lot of cases. Going further, when a circuit only contains final measurements (therefore outputting a non-deterministic state), the simulator also should compute the pre-measurement state a single time.

Examples

h q[0]
measure q[0]

results in "guaranteed_deterministic_state": False.

h q[0]

results in "guaranteed_deterministic_state": True.

x q[0]
measure q[0]
cond(b[0]) x q[1]

results in "guaranteed_deterministic_state": False even though the circuit is perfectly deterministic. A more advanced implementation (detailed below) can here return "guaranteed_deterministic_state": True as it would know that the measure q[0] is in fact deterministic since q[0] is not in superposition beforehand.

Implementation ideas

For conditional gates we need to know whether a classical bit is non-deterministic.
The simulator can maintain a boolean flag for each measurement register bit, that tells whether a bit is "deterministic" so far (True at the start).
The state becomes "maybe non-deterministic" as soon as:

  • a qubit in superposition is measured/prepped (this sets the associated bit to "non-deterministic")
  • a conditional gate is performed based on a non-deterministic bit

When asked N iterations, the simulator can compute the state/measurement register once as long as it's deterministic. Then iterate N times the rest of the circuit by resetting the state/measurement register to its last deterministic value between each iteration.

@oschusler
Copy link
Collaborator

My suggestion would be to allow for a flag to prevent optimization. This would mean that the default behaviour is to optimize if possible. However, if the user really doesn't want to, we should be able to prevent it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants