-
Notifications
You must be signed in to change notification settings - Fork 990
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
Fix Problem with Y gates in Clifford Simulator #2960
Conversation
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.
Thank you!
@@ -291,6 +291,19 @@ def test_clifford_stabilizerStateChForm_repr(): | |||
assert repr(state) == 'StabilizerStateChForm(num_qubits=2)' | |||
|
|||
|
|||
def test_clifforf_circuit_SHSYSHS(): |
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 suppose a simple test would check whether XZ and Y yield the same state up to global phase, but this should work just as well.
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 was looking for something that could be exposed as a measurement. The error in the Y gate can only be exposed when there is a Y stabilize, and this is not the case in the proposed test.
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.
Fair enough. Thank you for adding the test!
wave_function_simulator = cirq.Simulator() | ||
|
||
np.testing.assert_almost_equal( | ||
clifford_simulator.simulate(circuit).final_state.wave_function(), |
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.
@viathor Not related to this PR: What do you think about the fact that the clifford simulator needs a .wave_function()
appended while the wave_function_simulator
does not from a usability perpective? Should we make these consistent?
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.
Such inconsistency is definitely a problem in the API. Would you like to file an issue about this?
Thanks for catching.
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.
Why should there be an exponential cost in this otherwise polynomial simulator?
Generating the state vector is exponential in the number of qubits, but everything else is quadratic in the number of qubits? You would need to work around this.
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 agree exponential cost computation should not be executed implicitly in a surprising context. This does not conflict with API consistency. For example, some simulators already require that a user calls wave_function
explicitly if they wish to see the reconstructed wavefunction.
In any case, none of this blocks this PR.
Was trying to consolidate into a single commit. |
@@ -291,6 +291,19 @@ def test_clifford_stabilizerStateChForm_repr(): | |||
assert repr(state) == 'StabilizerStateChForm(num_qubits=2)' | |||
|
|||
|
|||
def test_clifforf_circuit_SHSYSHS(): |
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.
Fair enough. Thank you for adding the test!
wave_function_simulator = cirq.Simulator() | ||
|
||
np.testing.assert_almost_equal( | ||
clifford_simulator.simulate(circuit).final_state.wave_function(), |
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 agree exponential cost computation should not be executed implicitly in a surprising context. This does not conflict with API consistency. For example, some simulators already require that a user calls wave_function
explicitly if they wish to see the reconstructed wavefunction.
In any case, none of this blocks this PR.
Automerge cancelled: A required status check is not present. Missing statuses: ['Build docs', 'Build protos', 'Changed files test', 'Coverage check', 'Doc test', 'Format check', 'Lint check', 'Misc check', 'Pytest MacOS', 'Pytest Ubuntu', 'Pytest Windows', 'Type check'] |
As there seems to be a problem with the automatic testing, would you mind if I close the PR and then re-send it? |
I found a bug in the Y gate for the tableau circuit simulator. Here is a fix and a test
I found a bug in the Y gate for the tableau circuit simulator. Here is a fix and a test