Fix overflow in disjoint layout coupling-map capacity estimate#16604
Fix overflow in disjoint layout coupling-map capacity estimate#16604ashishpatel26 wants to merge 2 commits into
Conversation
|
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 following people are relevant to this code:
|
The edge-capacity estimate in build_coupling_map assumed every qubit has a 1q operation in the Target, so num_qargs() - num_qubits underflowed (and panicked) for targets defining only 2q gates. Use saturating_sub. Fixes Qiskit#16272
3a09371 to
f7d4173
Compare
|
|
jakelishman
left a comment
There was a problem hiding this comment.
Please read the contributing guide, and ensure that a human is reviewing these PRs. It is not useful to the project to submit raw LLM output. "Good first issues" are typically left open for humans to learn, not LLMs.
In particular, the entire PR template has been replaced by raw LLM output, including the removal of the LLM attribution section that is specifically intended to point contributors to responsible disclosure.
I can't proceed with this (or any) PR until the LLM policies are being respected.
|
Apologies — I used Claude Code on this and mistakenly replaced the PR template, including the disclosure section, when editing the description. That was my error; I've restored the template and disclosed the tooling in the description. I've reviewed the change myself and can answer questions about it. If you'd prefer this issue stay open for a fully manual contribution, I completely understand — say the word and I'll close this. |
Fix #16272
The edge-capacity estimate in
build_coupling_map(target.num_qargs() - num_qubits) assumes every qubit has a 1q gate defined on it. For aTargetthat only defines 2q gates (the issue reproducer has 5 qubits but only 4 qargs), the subtraction underflows and the pass panics. Changed tosaturating_sub, the approach already confirmed by @jakelishman in the issue thread, and added a regression test using the reproducer target plus a release note.Tested with the issue reproducer (no panic, layout produced) and by running
test_sabre_layout.py,test_sabre_swap.py, andtest_sabre_pre_layout.pylocally, all passing.AI/LLM disclosure
The one-line Rust change, the regression test, and the release note were generated with Claude Code under my direction and reviewed by me. Apologies for having earlier removed the template and disclosure section — that was a mistake, now restored.