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
Parse and implement class for permutation gates #891
Conversation
I'm a little surprised at |
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.
remarkably painless, lgtm
@ecpeterson pyQuil is a bit messy in this regard. Some places make sanity checks, others don't. |
I think I'd like that sanity check to be made when possible. I can't imagine anyone is relying on this bad behavior of generating illegal Quil. I suppose it doesn't have to be in this PR, though. |
72ff021
to
4f373c7
Compare
4f373c7
to
a82b94b
Compare
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.
Still looks fine to me.
Out of curiosity: when a user writes a Quil program with a bad permutation (like 0, 1, 1, 3
), who eventually catches this error and what error do they signal?
After this is merged quil-lang/quilc#234, the above is caught at parse time in quilc.
|
Cool. Still curious: what happens without this new quilc guard? Does tweedledum throw an error? Does it just give garbage results? (As an aside, I think the Quil spec promises only garbage-in-garbage-out with regards to non-unitary DEFGATEs, and we only deign to throw explicit errors as it suits us.) |
@ecpeterson something unhelpful like
|
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 we discussed @notmgsk this change is not backwards compatible with older versions of quilc (<= 1.7.2 I believe), and so we should make the extra effort to warn (and dare I say prevent) people from using this feature with those versions of quilc.
f96dd67
to
147b672
Compare
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.
one little change, otherwise i think this is Good 2 Go (TM).
Co-Authored-By: Robert Smith <robert@stylewarning.com>
The change requested above has been made
Introduces a class
DefPermutationGate
which subclassesDefGate
, so that gates can be defined using a permutation matrix:cnot = DefPermutationGate([0, 1, 3, 2])
. NormalDefGate
stuff works, likeDefGate.num_args()
andDefGate.get_constructor()
.Also update the parser to accept permutations: