-
Notifications
You must be signed in to change notification settings - Fork 1
Support cirq emit of rotation when axis is X,Y,Z #437
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
☂️ Python Coverage
Overall Coverage
New FilesNo new covered files... Modified Files
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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.
Nice! This should fix that problem from the random phase you told me about which causes the occasional failing CI run
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.
Everything looks good, I just want tests to trigger raising the EmitError (I believe codecov has already pointed this out too)
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.
Can you add a not happy path test? To trigger throwing the two EmitErrors I see in emit/op.py
?
Oh damn, this was actually part of #372. Sorry about that, I really need to be more careful with mixing commits. |
Actually, this implementation here is better since it nicely handles some error cases, which the one that was merged doesn't. @johnzl-777 please review again. I added the tests you asked for, but also slightly changed the implementation: the emit now returns e.g. Sorry about the chaos 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.
Looks good! I agree with the choice of Rz over the Pow
series here, just one thought on my end: is it ever desirable for us to be clever with the translations here or would that be bad UX? As in, lets say somebody requests Rot but the args turn out to be equivalent to a plain old pauli gate.
I imagine there'd be an upside for simulation performance but my concern is it might throw off a user if for some reason they really wanted to preserve Rot as much as possible.
@johnzl-777 that's a good question! In general, I'd say that whenever you are emitting / lowering you should try to stay as close as possible to a 1:1 mapping. Rewrites such as the one you mention should be other optimization passes afterwards. When lowering, this would be a rewrite. When emitting, such as in this PR, I'd say leave it to code you are emitting to be smart (or not). For example, it could be that cirq does such rewrites anyway (in which case, fine), or it doesn't. In either case, if we don't introduce any rewrites in the emit, we make sure that we come as close to what a user might expect as possible. That's just my take on things though ;) |
One of the things that dropped out of #436