This repository was archived by the owner on Jan 12, 2024. It is now read-only.
Native Simulator: change prereq check in state injection to return false instead of throw #434
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I misunderstood specifications of PrepareArbitraryState. The API guarantees that if the qubits, the state is being injected for, are unentangled and each is in state |0>, then they will be transformed into the requested state, otherwise, the API will perform a valid albeit undefined unitary operator but it shouldn't throw.
Considered options:
(*) Given how state setting is implemented now. Conceivably, there might be other algorithms that are both efficient and guarantee unitariness even if prereqs aren't satisfied? Also, could we still do this for total state injection?
(**) I don't believe it's easy/efficient to implement emulation of adjoint state prep, but even if it were, the unitary we apply cannot depend on the state of qubits because the base/adjoint might be applied in different states.
Note: The bug was found in course of reviewing microsoft/QuantumLibraries#370