Skip to content

Include endpoints when unrolling qubit ranges - #442

Open
danielgaskins wants to merge 1 commit into
qBraid:mainfrom
danielgaskins:fix/inclusive-qubit-ranges
Open

danielgaskins wants to merge 1 commit into
qBraid:mainfrom
danielgaskins:fix/inclusive-qubit-ranges

Conversation

@danielgaskins

Copy link
Copy Markdown
Contributor

Summary of changes

OpenQASM qubit ranges include their endpoint, but pyqasm was treating it like Python's exclusive slice bound. A gate on q[0:1] would run only on q[0], and q[3:3] would do nothing. This fixes the shared range helper for forward and reverse steps. It also rejects an endpoint beyond the register.

I updated tests that expected the old behavior, including aliases, barriers, measurements, subroutine arguments, CLI fixtures, and circuit drawing. New regression tests cover single-element, stepped, open-ended, alias, and out-of-bounds ranges.

The full suite passes with 915 tests and 3 skips. Pylint, Black, isort, mypy, the license-header check, and whitespace checks pass.

Closes #432.

Signed-off-by: Daniel Gaskins <danielgaskins99@gmail.com>
@argus-eye

argus-eye Bot commented Sep 24, 2026

Copy link
Copy Markdown

Argus review

Auto-review is off for this repo. Tick the box below to run a review on this PR.

  • Trigger Argus review

Estimated cost

  • Files changed: 14
  • Diff lines (±): 108
  • Historical avg: ~317.3k tokens · ~$1.35 · across last 12 review(s)

Tip: you can also comment @argus-eye review at any time.

@coderabbitai

coderabbitai Bot commented Sep 24, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository: qBraid/pyqasm/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 61b118d0-04c8-4c57-94f5-2c53eb460a96

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@TheGupta2012

TheGupta2012 commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

Thanks @danielgaskins for the work!

I think this looks good overall, but would you also be able to figure out the blast radius inside qBraid SDK qbraid.transpiler as well as qbraid-qir qasm to QIR converter? Those 2 sub-modules heavily depend on pyqasm for parsing and validating qasm programs. Since this will be a breaking change in the qubit indexing, we should first make sure we have the downstream effects of this change scoped.

This branch has not been deployed

No deployments
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.

[BUG] Register ranges are expanded with an exclusive upper bound, silently dropping the last qubit

3 participants