Skip to content
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

ZXGraphlikeOptimisation() can cause RunTime error #1566

Closed
IlanIwumbwe opened this issue Sep 5, 2024 · 4 comments · Fixed by #1690
Closed

ZXGraphlikeOptimisation() can cause RunTime error #1566

IlanIwumbwe opened this issue Sep 5, 2024 · 4 comments · Fixed by #1690
Assignees

Comments

@IlanIwumbwe
Copy link

Benny and I found this by generating a random Pytket circuit.

When we run this code:

from pytket import Circuit
from pytket.passes import ZXGraphlikeOptimisation

main_circ = Circuit(6, 0, "main_circ")

# Applying gates 
main_circ.Rx(-0.78,3)
main_circ.Rx(1.069,5)
main_circ.CX(0, 3)
main_circ.CX(3, 5)
main_circ.CX(0, 5)
main_circ.Rx(1.069,3)
main_circ.Rx(-5.958,4)
main_circ.CX(3, 4)
main_circ.CX(3, 5)
main_circ.CX(0, 3)

ZXGraphlikeOptimisation().apply(main_circ)

We get this runtime error:

RuntimeError: Error during extraction from ZX diagram: diagram does not have gflow

We tried to minimize the test case but deleting any one of the gates would make it work. Additionally, if any of the arguments to the rotation gates are integers, it also works.

@cqc-alec
Copy link
Collaborator

cqc-alec commented Sep 5, 2024

Any ideas @willsimmons1465 ? Seems like ZXGraphlikeOptimisation should be applicable to this circuit?

@willsimmons1465
Copy link
Contributor

Hi, sorry only just seen this. Someone else internally reported a similar error last week which looks to be the same thing. We found this to be a device-dependent error, failing e.g. on arm64 macs but not on x86 macs. I'll have a hunt around to see if I can find some culprits and borrow someone else's device.

The behaviour where it works for integer angles is somewhat expected, since rotations with multiples of pi/2 have additional simplification rules for them in ZX, so whatever the bug is, these extra rules seem to drag the diagram out of the buggy edge case

@willsimmons1465
Copy link
Contributor

@IlanIwumbwe Thanks for reporting this error. The fix from #1690 will be included in the next release of pytket. In the meantime, this input was found to work correctly (at least most of the time) on a variety of devices, so if you need the results soon try rerunning your task on a different system

@IlanIwumbwe
Copy link
Author

Thanks for authoring a fix. This was detected by a fuzz testing tool Benny and I built so we were just interested in finding bugs in compilers like this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants