-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Update Density Matrix and State Vector Simulators to work when an operation allocates new qubits as part of its decomposition #6108
Merged
Merged
Changes from 18 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
c2ff8bd
WIP add factoring and kron methods to sim state for adding and removi…
senecameeks e673105
add test cases
senecameeks 80fbbbc
add delegating gate test case
senecameeks 5f15d97
update test
senecameeks cd7a573
all tests pass
senecameeks 1cd81dd
add test case for unitary Y
senecameeks d9a46cc
nit
senecameeks 908ee77
addresses PR comments by adding empty checks. Applys formatter. Subse…
senecameeks c903d32
nit formatting changes, add docustring with input/output for remove_q…
senecameeks b92d6d8
Merge branch 'master' of https://github.com/quantumlib/cirq
senecameeks 70162d7
Merge branch 'master' into master
tanujkhattar 530a69e
merge this branch and tanujkhattar@ccde689
senecameeks 1be80c8
merging branches, adding test coverage in next push
senecameeks 2b06182
Merge branch 'master' of https://github.com/quantumlib/cirq
senecameeks 4adf75b
Merge branch 'master' of github.com:senecameeks/Cirq
senecameeks f70753b
format files
senecameeks f74f760
add coverage tests
senecameeks 5d31ce3
change assert
senecameeks 096fc14
coverage and type check tests should pass
senecameeks 964dc69
incorporate tanujkhattar@1db8ac5
senecameeks 40d5b33
nit
senecameeks 0ab07c2
Merge branch 'master' into master
tanujkhattar 40369ee
remove block comment
senecameeks ddd6fd9
Merge branch 'master' of github.com:senecameeks/Cirq
senecameeks 774d715
add coverage
senecameeks File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@daxfohl Do you know if we mess up the global phase as part of simulations ? The
factor
/kron
methods are messing up global phase since if I replacePhaseUsingCleanAncilla(theta=theta, ancilla_bitsize=num_ancilla).on(q)
withcirq.MatrixGate(cirq.unitary(PhaseUsingCleanAncilla(theta=theta, ancilla_bitsize=num_ancilla))).on(q)
; the tests pass usingassert np.allclose(test_sim, control_sim)
instead ofcirq.testing.assert_allclose_up_to_global_phase(test_sim, control_sim, atol=1e-6)
.Ideally, the resulting state vectors and density matrices should be identical and not equal upto global phase, but the factor / kron (or some other interaction of these methods in this PR) seems to mess up the global phase here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, so what is happening is as follows:
@daxfohl Do we not encounter this problem when factoring out measured / reset qubits when we construct
SimulationProductState
? I guess we can just multiply the extra phase to correct it, but curious if this is known pattern elsewhere as well? Seems very relevant.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I guess we never really "discard" qubits when constructing a
SimulationProductState
from unentangled states, and therefore this issue doesn't arise?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a fix in tanujkhattar@1db8ac5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought I fixed this in #5847. What is the difference in this scenario?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. Probably the linalg functions should take an extra bool parameter to force all phase into the reminder, and verify that the extracted axes are left in a classical basis state. All use cases of those functions, that's what they're ultimately trying to do.