Skip to content

🎨 Support alias-safe repeated qubit loads - #1987

Merged
burgholzer merged 17 commits into
mainfrom
agent/issue-1893-alias-safe-loads
Aug 5, 2026
Merged

🎨 Support alias-safe repeated qubit loads#1987
burgholzer merged 17 commits into
mainfrom
agent/issue-1893-alias-safe-loads

Conversation

@burgholzer

Copy link
Copy Markdown
Member

🤖 AI text below 🤖

Description

Make repeated and runtime-indexed qubit register loads alias-safe without relying
on CSE for correctness.

The QC-to-QCO conversion now treats qubit memref.load operations as access
provenance. It materializes register-backed qubits immediately around each
quantum operation, commits results in reverse extraction order, and carries
complete QTensor values through structured control flow. Local QTensor
canonicalizations only fold accesses whose indices MLIR proves equal.

The typed OpenQASM frontend now allocates non-scalar qubit declarations as
storage and emits checked point-of-use loads. Quantum register access therefore
no longer expands into width-dependent scf.index_switch dispatch. Exact
duplicate simultaneous operands are rejected semantically, while potentially
aliasing dynamic gate and barrier operands receive runtime assertions.

Fixes #1893

Validation

  • Clean LLVM/MLIR 22 release build.
  • All 4,404 configured CTest cases pass; two existing QDMI tests remain
    configured as skipped.
  • Focused QC, QCO, QTensor, QC-to-QCO, QCO-to-QC, OpenQASM, compiler, and
    round-trip suites pass.
  • mqt-cc successfully emits QC, QCO, and Adaptive QIR for dynamic gate,
    modifier, measurement, reset, and barrier accesses.
  • All repository lint hooks pass.
  • Fresh independent review of the exact published source found no actionable
    issues.

AI assistance

GPT-5.6 via Codex materially assisted with implementation, tests, validation,
and preparation of this pull-request description. The commits include
Assisted-by: GPT-5.6 via Codex trailers.

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.
  • I have added entries to the changelog for any noteworthy additions,
    changes, fixes, or removals.
  • I have added migration instructions to the upgrade guide (if needed).
  • 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.

@burgholzer burgholzer added enhancement Improvement of existing feature c++ Anything related to C++ code MLIR Anything related to MLIR labels Aug 1, 2026
@burgholzer burgholzer self-assigned this Aug 1, 2026
@codecov

codecov Bot commented Aug 1, 2026

Copy link
Copy Markdown

@mergify mergify Bot added the conflict label Aug 3, 2026
@burgholzer
burgholzer force-pushed the agent/issue-1893-alias-safe-loads branch from 004511d to e05771e Compare August 5, 2026 01:12
@mergify mergify Bot added conflict and removed conflict labels Aug 5, 2026
@burgholzer
burgholzer force-pushed the agent/issue-1893-alias-safe-loads branch from d29df02 to 8a85c4b Compare August 5, 2026 02:07
@mergify mergify Bot removed the conflict label Aug 5, 2026

@burgholzer burgholzer left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Just two small requests for changes. Otherwise, this should be good to go.

Comment thread CHANGELOG.md Outdated
Comment thread AGENTS.md Outdated
@mergify mergify Bot added the conflict label Aug 5, 2026
Treat QC qubit loads as register provenance and materialize QCO values only around each quantum operation. Carry complete QTensor state through structured control flow and restrict QTensor canonicalization to alias-safe local rewrites.

Assisted-by: GPT-5.6 via Codex
Allocate non-scalar declarations as storage and load checked static or dynamic references at each quantum use. Remove width-expanded quantum dispatch while preserving alias assertions and classical emission guards.

Assisted-by: GPT-5.6 via Codex
Add the direct declarations required by clang-tidy and keep local test helpers at internal linkage. Update the Python MLIR fixture to the canonical load-at-use ordering produced by the alias-safe pipeline.

Assisted-by: GPT-5.6 via Codex
Use MLIR region capture utilities, reject provably duplicate simultaneous operands, and remove dead modifier register state. Strengthen structured tensor linearity tests and normalize translation fixtures through the production conversion pipeline.

Clarify eager versus storage-only builder APIs and stop treating register loads as standalone allocations.

Assisted-by: GPT-5.6 via Codex
Count and emit only potentially aliasing register pairs instead of scanning every pair. Use LLVM dense containers for barrier uniqueness, reject unavoidable whole-register aliases early, and cover large static barriers without width-quadratic work.

Assisted-by: GPT-5.6 via Codex
Record the exhaustive remediation rounds, current-base integration, final validation, MLIR design decisions, and the remaining exact-head review step in the living ExecPlan.

Assisted-by: GPT-5.6 via Codex
Assisted-by: GPT-5.6 via Codex
Assisted-by: GPT-5.6 via Codex
Assisted-by: GPT-5.6 via Codex
Assisted-by: GPT-5.6 via Codex
Assisted-by: GPT-5.6 via Codex
Assisted-by: GPT-5.6 via Codex
Assisted-by: GPT-5.6 via Codex
Assisted-by: GPT-5.6 via Codex
Assisted-by: GPT-5.6 via Codex
@burgholzer
burgholzer force-pushed the agent/issue-1893-alias-safe-loads branch from fd2c950 to 6f1f76c Compare August 5, 2026 10:48
@mergify mergify Bot removed the conflict label Aug 5, 2026
Assisted-by: GPT-5.6 via Codex
@burgholzer
burgholzer enabled auto-merge (squash) August 5, 2026 13:35
@burgholzer
burgholzer merged commit b3e613f into main Aug 5, 2026
33 checks passed
@burgholzer
burgholzer deleted the agent/issue-1893-alias-safe-loads branch August 5, 2026 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Anything related to C++ code enhancement Improvement of existing feature MLIR Anything related to MLIR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🎨 Allow repeated memref.loads of the same qubit

1 participant