-
Notifications
You must be signed in to change notification settings - Fork 47
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
[TKET-1598] fix ConnectivityPredicate fails after FullPeepholeOptimise and AASRouting #194
Conversation
while (circ.has_implicit_wireswaps()) { | ||
bool foundswap = false; | ||
|
||
qubit_map_t perm = circ.implicit_qubit_permutation(); | ||
for (const std::pair<const Qubit, Qubit> &pair : perm) { | ||
if (pair.first != pair.second) { | ||
if (!foundswap) { | ||
circ.replace_implicit_wire_swap(pair.first, pair.second); | ||
foundswap = true; | ||
} | ||
} | ||
} | ||
} |
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.
Is the foundswap
variable really necessary? Can you not do something like:
while (circ.has_implicit_wireswaps()) { | |
bool foundswap = false; | |
qubit_map_t perm = circ.implicit_qubit_permutation(); | |
for (const std::pair<const Qubit, Qubit> &pair : perm) { | |
if (pair.first != pair.second) { | |
if (!foundswap) { | |
circ.replace_implicit_wire_swap(pair.first, pair.second); | |
foundswap = true; | |
} | |
} | |
} | |
} | |
while (circ.has_implicit_wireswaps()) { | |
qubit_map_t perm = circ.implicit_qubit_permutation(); | |
for (const std::pair<const Qubit, Qubit> &pair : perm) { | |
if (pair.first != pair.second) { | |
circ.replace_implicit_wire_swap(pair.first, pair.second); | |
} | |
} | |
} | |
} |
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.
Without the variable only one swap will create an infinity loop. The replace_implicit_wire_swap will remove one implicit wire swap and then add it again in the next iteration of the loop where pair.first != pair.second.
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.
Ah, okay. Would it be slightly faster then to have a break
rather than keep iterating through the loop but not replacing the swaps?
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.
I have added that.
Co-authored-by: Alexander Cowtan <[email protected]>
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 to me.
This is fixing #97
The problem has been a wrong handling of the implicit wire swaps in the aas pass