Skip to content

✨ Support whole-array OpenQASM copies - #2577

Open
simon1hofmann wants to merge 4 commits into
codex/openqasm-multidimensional-arraysfrom
codex/openqasm-array-copies
Open

simon1hofmann wants to merge 4 commits into
codex/openqasm-multidimensional-arraysfrom
codex/openqasm-array-copies

Conversation

@simon1hofmann

@simon1hofmann simon1hofmann commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

🤖 AI text below 🤖

Description

Support whole-array initialization (array[int, 2] b = a;) and assignment (b = a;) in the OpenQASM frontend. Source and destination must have matching shapes and element types, including widths. The source must be fully initialized. Copies use independent storage, preserve angle quantization, and support runtime updates and control flow. Self-assignment preserves the array.

Reuse memref.copy, fixed stack storage, and the QIR infrastructure from #2573. Copies remain compact in the emitted IR. The native QCO interpreter copies values without replacing storage shared with helper calls. Adaptive QIR handles residual copies; Base QIR accepts only programs whose unsupported storage and computation disappear during cleanup.

Stacked on #2574. Refs #2109; this is an intermediate slice and does not close the issue. Subarrays, ranges, concatenation, array outputs, and export of residual array storage remain follow-ups.

Validation

  • At this PR boundary, all 203 frontend/emitter, 237 compiler, and 202 native QCO tests pass, including QC/QCO round trips and Adaptive QIR execution.
  • Full-file C++ lint found no issues in this PR's changed files. Repository lint and diff-whitespace checks pass.
  • Hosted CI for the pushed commits has not been checked.

Codex assisted with implementation, tests, documentation, and this description.

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.
  • 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.

@simon1hofmann simon1hofmann added feature New feature or request MLIR Anything related to MLIR labels Sep 18, 2026
@simon1hofmann
simon1hofmann added this pull request to stack #2576 September 18, 2026 08:57
@simon1hofmann simon1hofmann self-assigned this Sep 18, 2026
@codecov

codecov Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

Codecov Report

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

Files with missing lines Patch % Lines
mlir/lib/Dialect/QCO/Utils/DDFunctionality.cpp 80.0% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@simon1hofmann
simon1hofmann force-pushed the codex/openqasm-array-copies branch from 496ea14 to 20ee9cc Compare September 21, 2026 08:16
@mergify mergify Bot added the conflict label Sep 24, 2026
@simon1hofmann
simon1hofmann force-pushed the codex/openqasm-array-copies branch from 20ee9cc to ae044ef Compare September 24, 2026 11:16
@mergify mergify Bot removed the conflict label Sep 24, 2026
@simon1hofmann
simon1hofmann force-pushed the codex/openqasm-array-copies branch from ae044ef to a31254f Compare September 26, 2026 10:23
@simon1hofmann
simon1hofmann force-pushed the codex/openqasm-array-copies branch from a31254f to 960e2cb Compare September 28, 2026 10:20
Copy matching arrays into independent storage with memref.copy. Preserve definite initialization and storage identity across control flow and native helper calls without expanding copies per element.

Assisted-by: GPT-5 via Codex
HTML and Markdown documentation builds execute notebooks concurrently.
Run the DD examples in temporary directories so their DOT and SVG files
do not overwrite each other during export and display.

Assisted-by: GPT-5 via Codex
Keep physical-qubit allocation checks for Adaptive QIR and assert that residual copy storage is rejected by Base Profile.

Assisted-by: GPT-5 via Codex
Do not silently treat newly parsed register slice syntax as a whole-array assignment in this earlier stack layer.

Assisted-by: OpenAI Codex
@simon1hofmann
simon1hofmann force-pushed the codex/openqasm-array-copies branch from 960e2cb to 427cacf Compare September 29, 2026 07:12

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

feature New feature or request MLIR Anything related to MLIR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant