Repository navigation
Conversation
…r error
QLX has no reset action, so cudaq.logical.reset in a function decorated
with cudaq.logical.program fell back to apply_standard("reset") and
failed with an MLIRError while parsing #qlx.action<reset>. Raise a
TypeError that names the operation and where it is available (a gadget
body or a P3 physical trace) instead. Gadget and physical traces keep
their existing reset paths.
Signed-off-by: Raunak Burrows <raunakburrows@gmail.com>
This branch has not been deployed
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.
Fixes #5908
Problem
cudaq.logical.resetinside a function decorated withcudaq.logical.programgives no diagnostic about an unsupported operation. Tracing the program fails deep in the builder:ops/_impl.py'sresetcallstrace.reset(...)when the trace has one and otherwise falls back totrace.apply_standard("reset", ...). The P0 program builder (UnplacedBuilder) has noreset, and QLX has noresetbuiltin action, so the fallback builds an attribute that cannot be parsed. The fallback is still needed for gadget bodies, whereapply_standard("reset")emitsfabric.reset.Fix
When the active trace is the P0 program builder,
cudaq.logical.resetraises:This follows the existing
barrier/releasechecks and theisinstance(trace, UnplacedBuilder)branch inmeasure. P3 physical traces (trace.reset) and gadget bodies (fabric.reset) take the same paths as before.flowchart TD A[cql.reset in a logical program] --> B{Trace the program} B -->|Before| C[MLIRError cannot parse qlx action reset] B -->|After| D[TypeError naming where reset is available]Narrated recording, before then after (sound on):
evidence.mp4
Reproducer
cudaq-logical0.2.0 from pip (aarch64 Linux,python:3.12container), with the installedops/_impl.pyreplaced bymain's (16e37c7) for the before run and by this branch's for the after run.On
main: theMLIRErrorabove. With this change: theTypeErrorabove.Edge cases and unchanged behaviour checked
In the running library (shown in the video):
measure_x, is rejected with the sameTypeError.reset(measure_z(h(q[0]))) compiles to the same P0 module.By tests only:
ql.reset(fabric.reset):test_verify_instruments.py40 passed andtest_gadget_verification.py19 passed, the same onmainand this branch.cql.resetpath (test_run_physical.py) does not collect against the 0.2.0 wheel (cudaq.num_available_gpusis missing from the installedcudaq); CI is the check for it.Tests
The 12 other failures are the same tests on
mainand on this branch (Quake import and build-provenance tests that need native parts newer than the 0.2.0 wheel).yapf --style google --diff(v0.40.2, the pre-commit version) reports no changes. I did not build CUDA-Q from source or run thectest/lit suites.AI tools (Claude Code) assisted with this change; the bug was reproduced on main and the fix verified as shown.