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

Add check for graph validity before commuting conditional gates in squashing passes #1716

Merged
merged 4 commits into from
Dec 10, 2024

Conversation

cqc-alec
Copy link
Collaborator

@cqc-alec cqc-alec commented Dec 10, 2024

Fixes #1324 .
Fixes #1357 .

I was a bit concerned about the performance impact of this but it increases the running time of the tket tests by only about 1% so I think it's OK. (If it does turn out to be a problem, an alternative would be never to commute these gates, but that would give poorer results -- or somehow to find a cheaper way to do the check.)

@cqc-alec cqc-alec requested a review from lmondada December 10, 2024 14:59
@cqc-alec cqc-alec marked this pull request as ready for review December 10, 2024 14:59
@cqc-alec cqc-alec requested a review from yao-cqc December 10, 2024 15:07
Copy link
Contributor

@lmondada lmondada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @cqc-alec!

For future reference, I'll mention here that an alternative that was discussed was to forbid the commutation of classically controlled gates, when one of the bits it is controlled on is i) overwritten by a future measurement (when squashing forward), or ii) is used as control for another operation in the past (when squashing backward).

This would be a sufficient condition to ensure correctness and would be very quick to check. It would still do the right thing for a (the most common?) subset of conditionally controlled gates, so might be a good half-way solution if the full check implemented here becomes too expensive.

@cqc-alec cqc-alec merged commit 1678c33 into main Dec 10, 2024
32 checks passed
@cqc-alec cqc-alec deleted the ae/sqrzpx branch December 10, 2024 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants