🔀 Backport remaining compatible main changes for MQT Core 3.9.0 - #2159
Merged
Conversation
Record the compatible maintenance, SpecAudit, PennyLane, QDMI, and OpenQASM backport boundary. Assisted-by: GPT-5 via Codex
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> (cherry picked from commit 7bc99e3)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> (cherry picked from commit ee2e56b)
* ⬆️🩹 Update patch updates Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * 🐛 Include Qiskit C API sources in wheel tests Assisted-by: GPT-5 via Codex --------- Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Lukas Burgholzer <burgholzer@me.com> (cherry picked from commit 8893132)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> (cherry picked from commit 3d631c1)
Improve prose, terminology, and test guidance in AGENTS.md Assisted-by: Opus 5 via Claude Code (cherry picked from commit d9e7e1c)
* ✨ Add SpecAudits for finding and removing spec debt Assisted-by: Claude Opus 5 via Claude Code * 📝 Add the first SpecAudit for the PennyLane QDMI plugin Assisted-by: Claude Opus 5 via Claude Code * 📝 Add a changelog entry for SpecAudits Assisted-by: Claude Opus 5 via Claude Code * 🔧 Drop the removed `.agent/run.sh` wrapper from the SpecAudit tooling `.agent/run.sh` was removed when the agent development workflow was simplified, so the probe script can no longer route its commands through it. Call `uv`, `cmake`, and `ctest` directly, matching the build and test entry points `AGENTS.md` now documents, and update the coverage commands in `.agent/AUDITS.md` to match. Also refresh the `AGENTS.md` quotation in `.agent/AUDITS.md`, whose wording changed in the meantime. (cherry picked from commit 59174b1)
`test_qasm3_resolves_ddsim_aliases_and_inverse_gates` pinned the exact seventeen-digit spelling of three OpenQASM angle literals. Nothing published states how the converter renders a parameter; the promise is that it keeps double precision. Parse the emitted literals and compare them as floats. Exact float equality still fails on any real precision loss. Applies verdict 1 of `.agent/audits/pennylane-plugin.md`. (cherry picked from commit 945b03b)
`_format_parameter` rendered every angle with `.17g`, so `IsingXX(0.1)` reached the device as `rxx(0.10000000000000001)`. `repr` gives the shortest literal that reads back as the same double, so every emitted program stays exact and becomes readable. The helper had one caller and one line left, so fold it into that call site. Applies verdict 1 of `.agent/audits/pennylane-plugin.md`. (cherry picked from commit 5d42d2b)
A counts-only QDMI device exposes a histogram, and the device expands it into shots. QDMI relates histogram key order to shot order nowhere, so the expanded order carries no meaning, and asserting it advertised a guarantee the device does not make. Assert what the expansion must preserve: every bit string repeats exactly as often as its count. Every probability derived from a counts-only device depends on that. Applies verdict 3 of `.agent/audits/pennylane-plugin.md`. The expansion strategy in `QDMIDevice._shots_or_counts` is now free to change; this commit does not change it. (cherry picked from commit 35dcae3)
`test_qasm2_diagonalizes_observable_once` pinned the exact seventeen-digit angle of the X-basis rotation. The angle was believed to guard `rotations=False` in the QASM2 path, but re-running the audit probe at this commit confirms the flag is inert there: by the time a tape reaches the serializer through the device, `measurements_from_samples` has already replaced the observable with a `SampleMP`, so no diagonalizing gate is left to add. Flipping the flag to `rotations=True` fails no test. Keep the claim the test can still make -- the rotation appears once -- and drop the angle it cannot earn. Applies verdict 4 of `.agent/audits/pennylane-plugin.md`. `rotations=False` stays and remains protected by nothing; the reconciled audit records that. (cherry picked from commit 68056a6)
`QDMIDevice` read the clock as `time.monotonic`, so a test could only replace it by mutating the `time` module for every caller in the process. Import the function by name instead, so a test can replace this device's clock alone and see exactly two readings per submitted job. Prepares the strengthened `execution_time` assertion for verdict 5 of `.agent/audits/pennylane-plugin.md`. (cherry picked from commit eb147f0)
`device.execution_time >= 0.0` could not fail for its own purpose: delete the accumulation in `_execute_tape` and the attribute stays `0.0`, so the assertion still passed. It caught the property vanishing, being `None`, or going `NaN`, and nothing else. Freeze the clock over a three-job shot vector and assert the exact accumulated total. Replacing the accumulation with `+= 0.0` now fails this test. The broad execution test keeps an explicit finiteness check, which is what the old assertion really did. Applies verdict 5 of `.agent/audits/pennylane-plugin.md`. (cherry picked from commit 90947b8)
`test_converter.py` called the public `convert_program(tape, device, wires)` directly. That three-argument signature was the only reason the function had to stay public, and the only reason it could not receive state the device had already computed. Rewrite the file against `QDMIDevice` and `StubDevice.submissions`, the technique `test_device.py` already uses. Every test now asserts what a QDMI device actually receives. Three tests changed shape, because preprocessing now runs first: - `test_rejects_device_without_qasm` is deleted. Its code path is about to stop existing, and `test_device.py::test_rejects_device_without_openqasm` already asserts the same rule at construction. - `test_qasm3_failure_does_not_fall_back_to_qasm2` now uses `U3`, which PennyLane's OpenQASM 2 serializer can spell and the OpenQASM 3 operation table cannot. A fallback would now succeed silently, so the test detects one. - That test and `test_qasm2_rejects_non_intersection_operation` also execute a tape directly, which is the path where conversion, not preprocessing, has to do the refusing. Coverage of the plugin is unchanged except for `converter._preferred_format`, which the next commit deletes. Prepares verdicts 2 and 6 of `.agent/audits/pennylane-plugin.md`. (cherry picked from commit 3be4f6f)
`supports_operation` and `convert_program` were free functions that took the opened device and re-derived everything from it. `supports_operation` is PennyLane's per-operation `stopping_condition`, so a single preprocessing pass over a 100-gate circuit made 101 `Device.operations()` round trips and 1818 `Operation.name()` calls where 1 and 18 would do. A four-tape parameter-shift gradient multiplied that by four. Bind the conversion to the device instead. `ProgramConverter` reads the advertised operation table and the wire mapping once, when the session opens, and reuses them for every operation and every tape. Measured on a 100-gate circuit over an 18-operation device: 101 and 1818 per pass become 1 and 18 once, for the life of the device. Two duplicate implementations go with it: - `converter._preferred_format` repeated the QASM3-then-QASM2 rule that `QDMIDevice._select_program_format` already applies, down to a second wording of the same error. The device now hands the selected format to the converter. - The two textually identical `stopping_condition` lambdas become one bound method. PennyLane discards the first whenever the tape has shots, which is always. `convert_program` and `ConvertedProgram` leave the package's public surface. `QDMIDevice` is the documented entry point and was already the only caller. Also drop the unreachable finite-shots check in `_shot_copies`: `_validate_finite_shots` runs first in the pipeline and every later transform preserves `tape.shots`, so the second check reads as live validation and is not. Applies verdicts 2 and 6 of `.agent/audits/pennylane-plugin.md`. (cherry picked from commit 458aa6a)
Record the removal of `convert_program` and `ConvertedProgram` from `mqt.core.plugins.pennylane` and name `QDMIDevice` as the replacement. (cherry picked from commit 9d8c002)
Mark every verdict applied or narrowed, per the Reconciling section of the method. Each verdict gains a paragraph saying what landed and what did not, the summary table gains a status column, and the header records the reconciliation commit and the scope numbers after the change. Two facts the reconciliation records rather than hides. Verdict 4 is narrowed, not applied: the probe reproduced, so no code change was earned, and `rotations=False` remains protected by nothing. Verdict 6 removed round trips, not lines -- the test tree grew by 57 lines because driving conversion through the device costs QNode boilerplate. The one open item, probing the exact QASM2 payload assertion against a bumped PennyLane, stays open. (cherry picked from commit c174631)
(cherry picked from commit a65dad2)
`_validate_qdmi_contract` reads advertised sites, site pairs, and the device coupling map, and no test exercised any of it beyond one site-pair rejection. The converter's fallbacks for a tape that skips preprocessing had no test either. Add both. Plugin coverage goes from 85% to 90%, and the converter from 81% to 93%. (cherry picked from commit 9b86f86)
`_select_program_format` returns OpenQASM 3 or OpenQASM 2 and raises otherwise, so the third branch could never run. Every added source line in this branch is now covered. (cherry picked from commit e214e4a)
Codecov rejected the patch, which showed that the advertised-loci validation had almost no test behind it. Say so in the reconciliation, with the numbers. (cherry picked from commit 7d43bb0)
Restore finite-shot validation for direct device execution and keep the session converter implementation private. Assisted-by: OpenAI Codex (cherry picked from commit 4b435d0)
Signed-off-by: Lukas Burgholzer <burgholzer@me.com> (cherry picked from commit 248028b)
(cherry picked from commit 2b22cf5)
* 🐛 Let the QDMI client trigger a calibration run `Device::submitJob` rejected `CALIBRATION` and `BATCH_JOB` together, under one predicate that read as "carries no program payload". The two are not the same case, and the calibration half was wrong. QDMI declares `QDMI_PROGRAM_FORMAT_CALIBRATION` as `void*` "A calibration program" and says only that triggering a calibration run "does not require a program to be set", so the payload is optional rather than absent. MQT Core rejected the format outright, before any device call, so a calibration run could not be started at all. The client meanwhile reports `needs_calibration()`, telling a caller a device needs calibration while giving no way to act on it. Add `Device::submitCalibrationJob`, bound as `submit_calibration_job`. The payload is optional and may be text or bytes, and no shot count is set, because a calibration run executes no circuit. A batch job is a different matter. Its program is a list of job handles rather than a byte payload, so `submitJob` cannot express it whatever the check says. State that MQT Core does not support batch jobs, and leave the door open for real support once a device implements the feature. * 📝 Reference the pull request in the changelog entries * ♻️ Share regular and calibration job submission Route both submission APIs through one helper that accepts optional program and shot parameters. Treat an empty calibration byte span as no payload so Python b"" does not reach QDMI as an invalid zero-sized parameter. Assisted-by: GPT-5 via Codex --------- Co-authored-by: Lukas Burgholzer <burgholzer@me.com> (cherry picked from commit 1cf85c2)
* 🐛 Stop assignment type checking after expression errors Co-authored-by: Damian Rovara <damianrovara@gmail.com> Assisted-by: GPT-5 via Codex * 📝 Add changelog entry for #2156 Assisted-by: GPT-5 via Codex --------- Co-authored-by: Damian Rovara <damianrovara@gmail.com> (cherry picked from commit 665072c)
Co-authored-by: Damian Rovara <damianrovara@gmail.com> Assisted-by: GPT-5 via Codex (cherry picked from commit 6eaea2a)
Assisted-by: GPT-5 via Codex (cherry picked from commit 0009e39)
Direct callers of the removed public conversion helpers to execute through QDMIDevice. Assisted-by: GPT-5 via Codex
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> (cherry picked from commit 5332592)
Update the living plan with the completed ports, exact local results, and environment-specific validation limits. Apply the repository Markdown formatting to the PennyLane audit ledger.
Record the #2153 base update, repeated validation, successful Python 3.14 lint run, and local documentation limit. Assisted-by: GPT-5 via Codex
Record draft PR #2159, its metadata, and the initial check state in the living ExecPlan. Assisted-by: GPT-5 via Codex
burgholzer
marked this pull request as ready for review
August 18, 2026 23:16
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Remove the unreleased PennyLane migration note, close the gap between the new fixed entries, and order the added PR links. Assisted-by: GPT-5 via Codex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 AI text below 🤖
Description
Backport the remaining compatible changes from
mainfor MQT Core 3.9.0. This PR preserves the upstream commit order and authorship in signed commits, with cherry-pick provenance.The backport includes:
uv.lockis regenerated from v3 declarations;ConvertedProgramandconvert_program;fomac::Device, including optional bytes and text payloads without a shot count, Python bindings and stubs, and explicit diagnostics for unsupported generic calibration and batch submission;PennyLane support has not been released, so the removed converter symbols do not need a migration note.
This PR does not duplicate #2141, #2142, or #2146. The #2145 backport remains owned by #2153 and is present in the updated
v3.xbase. It excludes #2111, #2112, #2114, #2115, #2054, #2137, #2138, and #2154 because they are breaking v4 architecture or downstream transitions. It excludes #1973, #2118, #2119, #2125, #2127, #2133, #2136, and #2140 because their LLVM 22/23, QCO, or compiler layers do not exist on v3. It also excludes #2120 because checked-in v3 ExecPlans still depend on its worktree-local command wrapper.AI assistance: Codex scanned the live branch and PR boundary, prepared and adapted the backport, preserved commit provenance, ran validation, and authored this description. The maintainer must review the code and public text before merge.
Validation completed locally:
mqt-core-fomac-test: 276 passed.Qasm3ParserTestcases passed.ctest --preset release: 1,533 passed, 2 device-dependent tests skipped.setuptools-scmwithvcs-versioning(backport #2145) #2153: 522 passed, 5 skipped.uv lock --check, the complete lint suite under Python 3.14, commit signature verification, andgit diff --checkpassed.Local validation limits:
tests-3.14andminimums-3.12nox wrappers failed before collection because the local scikit-build-core 1.0.3 editable.starthook did not load compiled modules. Equivalent regular-wheel installations in the same environments passed as listed above.Checklist
If PR contains AI-assisted content:
🤖 *AI text below* 🤖(titles are exempt).