Skip to content

Add device preprocessing to from_plxpr#2557

Merged
mudit2812 merged 80 commits intomainfrom
capture-device-preprocessing
Mar 17, 2026
Merged

Add device preprocessing to from_plxpr#2557
mudit2812 merged 80 commits intomainfrom
capture-device-preprocessing

Conversation

@mudit2812
Copy link
Copy Markdown
Contributor

@mudit2812 mudit2812 commented Mar 6, 2026

Context:

  • This PR adds support for device preprocessing with program capture.

Description of the Change:

  • Add a new catalyst.from_plxpr.device_utils submodule, which contains a function for generating a device preprocessing pipeline based on device capabilities and the execution config.
    • For transforms that don't have a pass_name, the transform is processed as follows:
      • a dummy MLIR transform, empty, is used. This transform has a key string argument that is used to indicate to devs which transform this pass is standing in for.
      • If any dummy transforms are added to the pipeline, a warning is raised to let the user know that some dummy transforms are present.
        • Note that this is only true for dummy transforms added conditionally. Transforms that are always added which don't have native implementations do not trigger this warning.
  • Create a "device"pass pipeline that is added to the quantum_kernel_p binding in from_plxpr.
  • Add a skip_preprocess argument to qjit, trace_from_pennylane, from_plxpr, and WorkflowInterpreter, which can be used to skip appending device preprocessing transforms to the pass pipeline.
  • Add a _preprocess_warn=True argument to from_plxpr and WorkflowInterpreter which can be used to toggle the dummy transform warnings off. This argument is private and not exposed by qjit. I added it as a testing convenience.
  • The preprocessing function also does MCM related validation and preprocessing.

Benefits:

  • Device preprocessing available with program capture.

Possible Drawbacks:

  • Depending on the device being used (and hence, which preprocessing transforms are used), the dummy transform warning can get annoying.

Related GitHub Issues:

[sc-111493] [sc-112073]

mudit2812 added a commit that referenced this pull request Mar 12, 2026
**Context:**
We want an MLIR pass that can be used short-term to stand-in for other
passes that do not have implementations

**Description of the Change:**
* Add `EmptyPass` MLIR pass, with a string `key` option

**Benefits:**
* Can be used in #2557 to use instead of unimplemented passes

**Possible Drawbacks:**

**Related GitHub Issues:**


[sc-113732]
Base automatically changed from empty-mlir-pass to main March 12, 2026 13:49
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.91%. Comparing base (2fd67bd) to head (ee2688f).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2557      +/-   ##
==========================================
+ Coverage   96.90%   96.91%   +0.01%     
==========================================
  Files         155      156       +1     
  Lines       16974    17065      +91     
  Branches     1636     1659      +23     
==========================================
+ Hits        16448    16539      +91     
  Misses        390      390              
  Partials      136      136              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mudit2812 mudit2812 requested review from albi3ro and paul0403 March 12, 2026 19:19
Copy link
Copy Markdown
Member

@paul0403 paul0403 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing PR! This is a big step towards the device capabilities mliestone in capture! 💯 🥇

Comment thread frontend/catalyst/from_plxpr/device_utils.py Outdated
Comment thread frontend/catalyst/from_plxpr/device_utils.py
Comment thread frontend/catalyst/from_plxpr/device_utils.py
Comment thread frontend/catalyst/from_plxpr/device_utils.py
Comment thread frontend/catalyst/from_plxpr/from_plxpr.py
Comment thread frontend/test/pytest/from_plxpr/test_preprocessing.py
Comment thread frontend/test/pytest/from_plxpr/test_preprocessing.py Outdated
Comment thread frontend/test/pytest/from_plxpr/test_preprocessing.py Outdated
Comment thread frontend/test/pytest/from_plxpr/test_preprocessing.py Outdated
Comment thread frontend/test/pytest/from_plxpr/test_preprocessing.py
Comment thread frontend/test/pytest/from_plxpr/test_preprocessing.py
Copy link
Copy Markdown
Contributor

@albi3ro albi3ro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changelog?

@mudit2812 mudit2812 requested review from albi3ro and paul0403 March 17, 2026 16:00
Copy link
Copy Markdown
Member

@paul0403 paul0403 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥳

Copy link
Copy Markdown
Contributor

@albi3ro albi3ro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Thanks so much for getting this all done. 🚀

@mudit2812 mudit2812 merged commit ec9f5dc into main Mar 17, 2026
41 checks passed
@mudit2812 mudit2812 deleted the capture-device-preprocessing branch March 17, 2026 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants