-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Fix DenseLayout when loose bits are present in input circuit #8843
Conversation
This commit fixes the DenseLayout transpiler pass to correctly handle when an input circuit contains loose bits. Previously the pass would incorrectly assume there was always a register in the circuit and only construct the output layout with registers. This caused the pass to return an empty layout if there were no quantum registers present in the circuit, even if there were qubits in the circuit. This commit fixes this by creating the layout per qubit and then only adding the registers as metadata to the layout after the fact.
Thank you for opening a new pull request. Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient. While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone. One or more of the the following people are requested to review this:
|
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, thanks!
for qreg in dag.qregs.values(): | ||
for i in range(qreg.size): | ||
layout[qreg[i]] = int(best_sub[map_iter]) | ||
map_iter += 1 | ||
layout.add_register(qreg) |
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 don't even know why Layout
tracks registers, but it does seem to be part of the interface, so best to keep it. I'm guessing it's from before, when registers owned qubits.
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.
Yeah, neither am I, and tbh I don't think it is 100% needed here anymore as without this all the tests passed, but I kept it in just in case there was something I wasn't considering.
Pull Request Test Coverage Report for Build 3199091475
💛 - Coveralls |
Summary
This commit fixes the DenseLayout transpiler pass to correctly handle when an input circuit contains loose bits. Previously the pass would incorrectly assume there was always a register in the circuit and only construct the output layout with registers. This caused the pass to return an empty layout if there were no quantum registers present in the circuit, even if there were qubits in the circuit. This commit fixes this by creating the layout per qubit and then only adding the registers as metadata to the layout after the fact.
Details and comments