-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add has_stabilizer_effect protocol and support native Clifford simulator gates #2760
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
Conversation
…rted_gates list and delete the old method
Only adds support for gates that can be run by CliffordState. Does not, yet, try to decompose. |
Ping! |
def test_y_stabilizer(): | ||
gate = cirq.Y | ||
assert cirq.has_stabilizer_effect(gate) | ||
assert not cirq.has_stabilizer_effect(gate**0.5) |
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.
Square root of Y is a stabilizer gate.
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.
As I mentioned in #2760 (comment), I'm just adding support for the operations that CliffordState supports right now (just like it was before this) and does not try to decompose. Y**0.5
is a stabilizer gate and so is iSwap
but just restricting myself to the original 7 gates before #2803 adds all of them to CliffordState since right now the simulator would just balk at Y**0.5
.
If you feel we should add all these gates to the protocol at once, I can wait for the #2803 to go in. I can then have the protocol just do what is_supported_gate doing now as described in https://github.com/quantumlib/Cirq/pull/2803/files#r390152850. It would save on redundant work and definitely seems like a better option than having to define _has_stabilizer_effect_
on all gates.
assert cirq.has_stabilizer_effect(gate) | ||
assert not cirq.has_stabilizer_effect(gate**0.5) | ||
assert cirq.has_stabilizer_effect(gate**0) | ||
assert not cirq.has_stabilizer_effect(gate**-0.5) |
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.
Should be true not false.
def test_x_stabilizer(): | ||
gate = cirq.X | ||
assert cirq.has_stabilizer_effect(gate) | ||
assert not cirq.has_stabilizer_effect(gate**0.5) |
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.
Should be true not false.
assert cirq.has_stabilizer_effect(gate) | ||
assert not cirq.has_stabilizer_effect(gate**0.5) | ||
assert cirq.has_stabilizer_effect(gate**0) | ||
assert not cirq.has_stabilizer_effect(gate**-0.5) |
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.
Should be true not false.
def test_z_stabilizer(): | ||
gate = cirq.Z | ||
assert cirq.has_stabilizer_effect(gate) | ||
assert cirq.has_stabilizer_effect(gate**0.5) |
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.
Should be true not false.
assert cirq.has_stabilizer_effect(gate) | ||
assert cirq.has_stabilizer_effect(gate**0.5) | ||
assert cirq.has_stabilizer_effect(gate**0) | ||
assert cirq.has_stabilizer_effect(gate**-0.5) |
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.
Should be true not false.
foo = sympy.Symbol('foo') | ||
assert not cirq.has_stabilizer_effect(gate**foo) | ||
|
||
|
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.
You should also test that measurement is a stabilizer effect, and that gates like CCZ and the depolarizing channel are not.
Follow up to #2600 and part of #2423