Skip to content

Fix overflow in disjoint layout coupling-map capacity estimate#16604

Open
ashishpatel26 wants to merge 2 commits into
Qiskit:mainfrom
ashishpatel26:fix/issue-16272-sabre-coupling-overflow
Open

Fix overflow in disjoint layout coupling-map capacity estimate#16604
ashishpatel26 wants to merge 2 commits into
Qiskit:mainfrom
ashishpatel26:fix/issue-16272-sabre-coupling-overflow

Conversation

@ashishpatel26

@ashishpatel26 ashishpatel26 commented Jul 17, 2026

Copy link
Copy Markdown

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 a Target that only defines 2q gates (the issue reproducer has 5 qubits but only 4 qargs), the subtraction underflows and the pass panics. Changed to saturating_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, and test_sabre_pre_layout.py locally, all passing.

AI/LLM disclosure

  • I didn't use LLM tooling, or only used it privately.
  • I used the following tool to help write this PR description: Claude Code (Claude Fable 5)
  • I used the following tool to generate or modify code: Claude Code (Claude Fable 5)

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.

@ashishpatel26
ashishpatel26 requested a review from a team as a code owner July 17, 2026 11:25
@qiskit-bot qiskit-bot added the Community PR PRs from contributors that are not 'members' of the Qiskit repo label Jul 17, 2026
@qiskit-bot

Copy link
Copy Markdown
Collaborator

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:

  • @Qiskit/terra-core

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
@ashishpatel26
ashishpatel26 force-pushed the fix/issue-16272-sabre-coupling-overflow branch from 3a09371 to f7d4173 Compare July 17, 2026 11:26
@CLAassistant

CLAassistant commented Jul 17, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@jakelishman jakelishman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

@github-project-automation github-project-automation Bot moved this to Waiting for contributor in Contributor Monitoring Jul 17, 2026
@ashishpatel26

Copy link
Copy Markdown
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Community PR PRs from contributors that are not 'members' of the Qiskit repo

Projects

Status: Waiting for contributor

Development

Successfully merging this pull request may close these issues.

Coupling map construction in SabreSwap panics with an overflow error

4 participants