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

Modify and fix CliffordResynthesis pass #1476

Merged
merged 6 commits into from
Jul 2, 2024
Merged

Modify and fix CliffordResynthesis pass #1476

merged 6 commits into from
Jul 2, 2024

Conversation

cqc-alec
Copy link
Collaborator

@cqc-alec cqc-alec commented Jul 2, 2024

Description

Modify the promise made by, and the logic used in, the CliffordResynthesis() pass, to avoid the issue described in #1468 .

Related issues

Fixes #1468 .

Checklist

  • I have performed a self-review of my code.
  • I have commented hard-to-understand parts of my code.
  • I have made corresponding changes to the public API documentation.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have updated the changelog with any user-facing changes.

cqc-alec added 6 commits July 2, 2024 11:16
Repeat substituting the best found subcircuit as long as the two-qubit
gate count is decreasing. "Best" means the one that reduces the two-
qubit gate count the most.
@cqc-alec cqc-alec force-pushed the ae/fix-cliffresynth branch from 687ab31 to 9547488 Compare July 2, 2024 10:18
@cqc-alec cqc-alec changed the title Ae/fix cliffresynth Modify and fix CliffordResynthesis pass Jul 2, 2024
@cqc-alec cqc-alec requested a review from cqc-melf July 2, 2024 10:45
@cqc-alec cqc-alec marked this pull request as ready for review July 2, 2024 10:45
static bool resynthesise_cliffords(
Circuit &circ,
std::optional<std::function<Circuit(const Circuit &)>> transform = nullptr,
bool allow_swaps = true) {
bool changed = false;
for (const VertexSet &verts :
circ.get_subcircuits([](Op_ptr op) { return op->is_clifford(); })) {
while (true) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this maybe better contain the break condition in the while line?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's a matter of preference. That would mean introducing an extra boolean variable outside the loop to control it, and modifying the variable inside the loop, whereas this way we don't need to do that. On balance I think the function is sufficiently small that the logic is apparent.

@cqc-alec cqc-alec merged commit 3df27b8 into main Jul 2, 2024
32 checks passed
@cqc-alec cqc-alec deleted the ae/fix-cliffresynth branch July 2, 2024 12:28
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 this pull request may close these issues.

CliffordResynthesis pass can create invalid circuits
2 participants