Skip to content

🐛 Declare capacity for sparse QIR resource IDs - #2447

Merged
simon1hofmann merged 3 commits into
mainfrom
codex/2287-qir-static-capacity
Sep 7, 2026
Merged

🐛 Declare capacity for sparse QIR resource IDs#2447
simon1hofmann merged 3 commits into
mainfrom
codex/2287-qir-static-capacity

Conversation

@simon1hofmann

@simon1hofmann simon1hofmann commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

🤖 AI text below 🤖

Description

QIR metadata counted distinct static resource IDs, which understated the capacity needed for sparse IDs. The metadata pass now declares capacity through the highest recognized static qubit or recorded result ID: qc.static 7 retains ID 7 and declares required_num_qubits="8". It diagnoses IDs whose required capacity exceeds an unsigned 64-bit count before changing metadata.

Addresses the sparse-resource-capacity finding in #2287. This PR is independent of the other audit fixes and starts from main at 5f6a8cfa2. No new dependencies. The change retains the existing direct constant-to-pointer discovery and dynamic-resource behavior.

Validation: all 121 QIR IR tests and 165 compiler tests passed on the combined validation branch containing the four audit fixes. Coverage includes sparse and duplicate IDs, capacity boundaries, and compiler resource metadata. uvx nox -s lint and uvx nox -s cpp-lint passed; the latter checks every line of each changed C++ file.

GPT-6 via Codex assisted the implementation, tests, and PR text.

Checklist

  • The pull request only contains commits that are focused and relevant to this change.
  • I have added appropriate tests that cover the new/changed functionality.
  • I have updated the documentation to reflect these changes.
  • Changelog entries are not required for this unreleased v4 functionality.
  • Migration instructions are not required for this unreleased v4 functionality.
  • The changes follow the project's style guidelines and introduce no new warnings.
  • The changes are fully tested and pass the CI checks.
  • I have reviewed my own code changes.

If PR contains AI-assisted content:

  • Any agent that created, edited, or submitted GitHub content was explicitly authorized for that scope, as required by our AI Usage Guidelines.
  • Every agent-authored or agent-edited public text body begins with the visible disclosure 🤖 *AI text below* 🤖 (titles are exempt).
  • I have disclosed AI assistance in the PR description.
  • I confirm that I have personally reviewed and understood all AI-generated content, and accept full responsibility for it.

Preserve static qubit and result IDs while declaring capacity through the
highest ID. Reject capacities that cannot fit the QIR 64-bit count before
changing metadata.

Cover empty, dense, repeated, and sparse IDs in both profiles, preserve
qc.static 7 through the compiler, and check atomic capacity rejection.

Assisted-by: GPT-6 via Codex
Suppress the naming check only on the two SetUp overrides whose names
GoogleTest requires.

Assisted-by: GPT-6 via Codex
@simon1hofmann simon1hofmann added bug Something isn't working MLIR Anything related to MLIR QIR Anything related to QIR labels Sep 7, 2026
@simon1hofmann simon1hofmann self-assigned this Sep 7, 2026
Use designated initializers and trailing commas, and remove a redundant cast. Test behavior is unchanged.

Assisted-by: GPT-6 via Codex
@codecov

codecov Bot commented Sep 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.85714% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...lib/Dialect/QIR/Transforms/AttachQIRAttributes.cpp 92.8% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@burgholzer burgholzer 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.

This feels reasonable. Feel free to merge once green!

@simon1hofmann
simon1hofmann merged commit 999b333 into main Sep 7, 2026
26 checks passed
@simon1hofmann
simon1hofmann deleted the codex/2287-qir-static-capacity branch September 7, 2026 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working MLIR Anything related to MLIR QIR Anything related to QIR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants