Skip to content

🔍 Audit MLIR pass, verifier, and rewrite contracts - #2287

Draft
simon1hofmann wants to merge 15 commits into
mainfrom
codex/2255-qir-base-contract
Draft

🔍 Audit MLIR pass, verifier, and rewrite contracts#2287
simon1hofmann wants to merge 15 commits into
mainfrom
codex/2255-qir-base-contract

Conversation

@simon1hofmann

@simon1hofmann simon1hofmann commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

🤖 AI text below 🤖

Description

Reconciles the complete MLIR contract audit from #2255 with the reviewer rule
that transformation passes may assume input accepted by the owning dialect and
whole-program validators.

The historical snapshot contained 118 files and 14,011 changed lines. Against
current main (b74fbb280), this branch contains 77 files with 9,952
insertions and 1,009 deletions: 41 files and 3,050 changed lines were removed.

This remains a draft audit snapshot and finding ledger, not a proposal to merge
the complete implementation. Accepted findings continue to land as focused pull
requests. The census, decisions, and validation record are in
.agent/plans/audit-mlir-contracts.md.

Revised audit invariant

  • Passes may assume structurally valid dialect IR and applicable MQT-owned
    whole-program invariants, including QCO linearity and program metadata.
  • Invalid-IR cases belong to the verifier or ingestion boundary that owns them.
    Pass tests may verify these invariants before and after a transformation.
  • External input, target representability, conversion atomicity, output
    validation, and resource limits reachable from valid IR remain valid audit
    boundaries.
  • Each retained finding requires a valid-input reproducer and a named ownership
    boundary.

Reconciliation

Removed generic pass-entry validation, invalid-IR defenses and regressions,
speculative traversal replacements, the shared arbitrary depth policy, rejected
findings, and code owned by focused pull requests.

The remaining snapshot contains unique compiler/import, conversion,
representability, verifier, numeric, mapping, DD resource, and QIR provenance
findings. The placement/routing split from #2316 is preserved, with the remaining
mapping findings applied only to explicit-topology routing.

Focused pull requests

Merged (12):

Open (5):

Closed without merge (4):

Validation

  • Configured and built with LLVM/MLIR 23.1.0.
  • After merging current main, all 3,111 MLIR unit tests pass.
  • The merge-affected suites pass independently: mapping 97/97, compiler 143/143,
    and QCO utilities 161/161.
  • uvx nox -s lint passes.
  • The CI-equivalent changed-file C++ lint with Clang-Tidy 22.1.8 reports zero
    Clang-Format and zero Clang-Tidy findings.
  • git diff --check passes.
  • The existing macOS/Python 3.14 nanobind exception-translation limitation
    remains documented; the rejected workaround from 🐛 Preserve MLIR runtime errors on macOS #2305 stays excluded.
  • Final GitHub CI is pending after this branch update.

Tracks #2255.

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

AI assistance disclosure: Codex performed the audit, reconciled reviewer
feedback and current main, extracted accepted findings into focused pull
requests, pruned duplicate implementations, and updated this description under
explicit human direction.

Audit every MQT-owned pass, verifier, rewrite pattern, conversion target, and registration surface. Harden diagnostics, atomicity, resource bounds, metadata checks, and importer boundaries.

Add focused regressions across conversions, QIR, mapping, JEFF, OpenQASM, decision diagrams, and Qiskit interoperability.

Assisted-by: GPT-5.6 Sol via Codex
…ontract

# Conflicts:
#	mlir/lib/Compiler/Programs.cpp
#	mlir/lib/Dialect/QCO/IR/Modifiers/ModifierUtils.cpp
#	mlir/unittests/Conversion/QCToQCO/test_qc_to_qco.cpp
@simon1hofmann simon1hofmann self-assigned this Sep 1, 2026
Preserve landed focused fixes while retaining the independent contract-audit guards and regressions.

Assisted-by: GPT-5.6 via Codex
Preserve the dependency-safe behavior from #2301 while retaining terminal-reset handling from the contract audit.

Assisted-by: GPT-5.6 via Codex
@mergify mergify Bot removed the conflict label Sep 1, 2026
Record the focused pull request outcomes and revise the audit gate so passes may assume verifier-valid IR. Withdraw speculative and invalid-input findings across the original snapshot.

Assisted-by: GPT-5.6 via Codex
@simon1hofmann simon1hofmann changed the title ♻️ Harden MLIR pass, verifier, and rewrite contracts 🔍 Audit MLIR pass, verifier, and rewrite contracts Sep 1, 2026
Move the invalid-QCO finding from pending withdrawal to closed and refresh the focused audit counts.

Assisted-by: GPT-5.6 via Codex
@mergify mergify Bot added the conflict label Sep 1, 2026
…ontract

# Conflicts:
#	mlir/include/mlir/Conversion/CBitToMemRef/CBitToMemRef.td
#	mlir/lib/Conversion/CBitToMemRef/CBitToMemRef.cpp
@burgholzer burgholzer added this to the v4.0.0 - IEEE Quantum Week milestone Sep 1, 2026
Remove focused, merged, closed, malformed-IR, and speculative changes from the audit snapshot. Retain only uniquely owned boundary, verifier, resource, semantic, and output-atomicity findings, with valid regressions.

Assisted-by: GPT-5.6 via Codex
…ontract

# Conflicts:
#	mlir/unittests/Conversion/QCOToQC/test_qco_to_qc.cpp
Accept valid QC programs whose dynamic register indices cannot be proven distinct, and remove a registration-only assertion without an executable reproducer. Finalize the reconciled audit counts and validation record.

Assisted-by: GPT-5.6 via Codex
@mergify mergify Bot added conflict and removed conflict labels Sep 1, 2026
Extract scalar floats from MLIR pass options before calling std::isfinite so the retained option validation compiles with MSVC.

Assisted-by: GPT-5.6 via Codex
@mergify mergify Bot added the conflict label Sep 1, 2026
Retain the audit conversion validation and atomicity changes while integrating the focused constant-folding, benchmark-registration, and idempotent QIR metadata updates now on main.

Assisted-by: GPT-5.6 via Codex
Remove the five implementation and regression copies now owned by #2318 through #2322 while preserving the complete audit ledger.

Clear the remaining changed-file Clang-Tidy warnings exposed by the reduced snapshot.

Assisted-by: GPT-5.6 via Codex
Preserve the audit mapping validation and failure-atomic rewrite while adopting the separated placement and routing implementation.

Assisted-by: GPT-5.6 via Codex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code quality Code quality improvements conflict MLIR Anything related to MLIR refactor Anything related to code refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants