Skip to content

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

Merged
merged 17 commits into from
Mar 28, 2020

Conversation

smitsanghavi
Copy link
Collaborator

Follow up to #2600 and part of #2423

@googlebot googlebot added the cla: yes Makes googlebot stop complaining. label Feb 12, 2020
@smitsanghavi
Copy link
Collaborator Author

Only adds support for gates that can be run by CliffordState. Does not, yet, try to decompose.

@smitsanghavi smitsanghavi added the Ready for Re-Review For when reviewers take their time. label Feb 17, 2020
@dstrain115 dstrain115 self-requested a review February 26, 2020 19:24
@smitsanghavi
Copy link
Collaborator Author

Ping!

def test_y_stabilizer():
gate = cirq.Y
assert cirq.has_stabilizer_effect(gate)
assert not cirq.has_stabilizer_effect(gate**0.5)
Copy link
Contributor

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.

Copy link
Collaborator Author

@smitsanghavi smitsanghavi Mar 18, 2020

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)
Copy link
Contributor

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)
Copy link
Contributor

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)
Copy link
Contributor

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)
Copy link
Contributor

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)
Copy link
Contributor

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)


Copy link
Contributor

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.

@smitsanghavi smitsanghavi requested a review from Strilanc March 18, 2020 06:23
@Strilanc Strilanc removed the Ready for Re-Review For when reviewers take their time. label Mar 28, 2020
@Strilanc Strilanc added the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Mar 28, 2020
@CirqBot CirqBot added the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Mar 28, 2020
@CirqBot CirqBot merged commit 459f644 into quantumlib:master Mar 28, 2020
@CirqBot CirqBot removed automerge Tells CirqBot to sync and merge this PR. (If it's running.) front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. labels Mar 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Makes googlebot stop complaining.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants