🔍 Audit MLIR pass, verifier, and rewrite contracts - #2287
Conversation
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
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
…ontract # Conflicts: # mlir/lib/Compiler/Programs.cpp # mlir/lib/Dialect/QCO/IR/Modifiers/ModifierUtils.cpp # mlir/unittests/Conversion/QCToQCO/test_qc_to_qco.cpp
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
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
Move the invalid-QCO finding from pending withdrawal to closed and refresh the focused audit counts. Assisted-by: GPT-5.6 via Codex
…ontract # Conflicts: # mlir/include/mlir/Conversion/CBitToMemRef/CBitToMemRef.td # mlir/lib/Conversion/CBitToMemRef/CBitToMemRef.cpp
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
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
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
Preserve the audit mapping validation and failure-atomic rewrite while adopting the separated placement and routing implementation. Assisted-by: GPT-5.6 via Codex
Merge main and replace the residual implementation snapshot with five reproduced findings and their minimal CLI examples. Assisted-by: GPT-6 via Codex
Assisted-by: GPT-6 via Codex
|
@burgholzer I let Astra rerun the audit to only focus on reproducible and real findings. It identified 5 actionable items, let me know what you think and I'll be happy to implement them if needed. |
burgholzer
left a comment
There was a problem hiding this comment.
Thanks @simon1hofmann 🙏🏼 commented on all five findings. SHould hopefully be enough for resolving them 😌 let me know if not!
| ```qasm | ||
| OPENQASM 3.0; | ||
| include "stdgates.inc"; | ||
| qubit q; | ||
| bit c; | ||
| c = measure q; | ||
| x q; | ||
| ``` |
There was a problem hiding this comment.
Yeah, this can definitely not be a valid base profile program. (at least not without any passes commuting gates through measurements).
Let's fix this.
| cf.cond_br %c, ^then, ^else | ||
| ^then: | ||
| qc.x %q : !qc.qubit | ||
| return | ||
| ^else: | ||
| qc.z %q : !qc.qubit |
There was a problem hiding this comment.
we do not really support generic cf flow (yet). And I would rather like to hard-fail here with a diagnostic.
None of the input programs/program formats should currently produce such instructions; we just need to make this more explicit.
| Observed: exit 134 (`SIGABRT`) and `LLVM ERROR: No functions found in module`. | ||
| The stack reaches `deserializeFromFile` from `loadJeffFile`. The CLI failure was | ||
| executed; the byte/file library methods' use of the same fatal dependency was | ||
| checked in source, not in a separate host-process experiment. |
There was a problem hiding this comment.
This definitely needs to be fixed 👍🏼
| Observed: exit 0; `x` receives `inttoptr (i64 7 to ptr)`, but the entry point | ||
| declares `required_num_qubits="1"`. Preserving ID 7 requires a capacity of at | ||
| least 8. The emitted program therefore violates the target contract. | ||
|
|
||
| **Limits and disposition.** Proposed. Preserve physical-qubit identity; do not | ||
| silently renumber mapped qubits. The regression should check capacity and the | ||
| retained ID. Sparse result IDs and other pointer-provenance cases were not | ||
| separately reproduced and are not additional findings here. |
There was a problem hiding this comment.
Yeah, this should also be fixed. This is a valid program.
| scf.if %c { | ||
| %q = qco.alloc : !qco.qubit | ||
| %out = qco.x %q : !qco.qubit -> !qco.qubit | ||
| qco.sink %out : !qco.qubit | ||
| } |
There was a problem hiding this comment.
Puh. I am not sure we actually should allow this at the moment.
I believe none of the frontends we currently support allow qubit allocations in SCF constructs. Maybe we should just be rather explicit on forbidding this?
🤖 AI text below 🤖
Description
Records five reproduced correctness failures in MLIR lowering and JeFF import,
with minimal CLI examples, source evidence, ownership, and limits for each
proposed fix. The audit is based on
mainat6cc98f059.The diff contains only one 271-line audit report.
There are no production or test changes; the findings remain open for focused
fixes. The report also reconciles the merged and closed split PRs.
Passes may assume verified IR. The retained findings concern valid source
programs or an external import boundary. Generic pass-entry validation,
invalid-QCO regressions, blanket failure-atomicity requirements, and speculative
resource caps are excluded.
Confirmed findings
changing the recorded result.
qubit reference.
returning an import error.
metadata; ID 7 is emitted with
required_num_qubits="1".producing a dominance error and failing compilation.
Validation
jeff-mlir dependency.
confirm the existing failures; this PR does not implement their fixes.
uvx nox -s lintandgit diff --checkpassed.Tracks #2255.
Checklist
If PR contains AI-assisted content:
🤖 *AI text below* 🤖(titles are exempt).AI assistance disclosure: Codex refreshed the audit against current
main,reproduced the retained findings, removed the old implementation snapshot, and
updated this description under explicit human direction. Human review remains
required before acceptance or merge.