Skip to content

Conversation

@mudit2812
Copy link
Contributor

@mudit2812 mudit2812 commented Nov 17, 2025

This PR migrates all source code for the unified compiler to Catalyst.

Changes:

  • Add python_interface submodule to frontend/catalyst.
  • Add python_interface submodule to frontend/test/pytest.
  • Remove references to pennylane.compiler.python_compiler.
  • Add a utils.py file to frontend/test/pytest to house data that is used by multiple test files.

Remaining work:

  • Update the cookbook and associated notebooks to use catalyst.python_interface instead of pennylane.compiler.python_compiler.
  • Migrate alll changelog pertaining to the unified compiler from PennyLane's changelog.

Questions for reviewers:

  • Should I build wheels in this PR?
  • Should xdsl and xdsl-jax be hard dependencies?

Future work:

  • Add xDSL universe. This is needed to integrate lit testing for the unified compiler with the existing Catalyst infrastructure (see below).
  • Integrate unified compiler testing with Catalyst's testing infrastructure. This will involve removing all unit/integration lit tests from the frontend/test/pytest folder and adapting them so that they can be moved to the frontend/test/lit folder.
  • Begin the process of having documentation for the unified compiler on pennylane.ai.
  • Improve test coverage for the unified compiler.
  • Add tests and GitHub workflows to validate parity between xDSL and MLIR dialects.

[sc-99039] [sc-98172]

@mudit2812 mudit2812 added the unified compiler Pull requests for the integration with xDSL label Nov 17, 2025
@paul0403
Copy link
Member

Oh, the +20k lines 🤖

@mudit2812
Copy link
Contributor Author

Oh, the +20k lines 🤖

I'm not really sure what the review procedure should be for this PR. Beyond linting and updates to which modules we're referencing (pennylane.compiler.python_compiler -> catalyst.python_interface), there aren't any changes.

.codecov.yml Outdated
Comment on lines 11 to 12
ignore:
- "frontend/catalyst/python_interface"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

So far, we have been omitting the unified compiler's source code from test coverage reports. I have open PRs in pennylane to work towards improving coverage, but until then, we need to keep omitting the unified compiler from coverage reports.

Comment on lines +476 to +478
# Install graphviz for testing the mlir-op-graph integration
sudo apt-get install -y graphviz
python3 -m pip install graphviz
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If it is preferred to install graphviz in a different manner, please let me know.

Copy link
Contributor

Choose a reason for hiding this comment

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

We should be able to get a green make tests locally when installing Catalyst from source by following the installation guide. The problem with this approach is that it installs graphviz for ci tests but locally you would get an error if you don't have it installed. So I think we should either add graphviz to the requirements.txt and update the installation guide or completely decouple the python_interface tests from current Catalyst test suit, so it wouldn't be run in a regular call to make tests. I am fine with both but maybe the latter is more in line with previous discussions about making python_interface independent from Catalyst. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Another solution is that instead of letting those tests fail, I could just pytest.importoskip("graphviz"). Thoughts? It wouldn't decouple visualization tests from catalyst CI, but there won't be any failures.

Copy link
Contributor

Choose a reason for hiding this comment

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

That could work, but I just realized we want to include the visualization module in the release right? Then maybe should we actually have the related tests run in the CI or the wheels or both? Also after adding the pytest.importoskip("graphviz") let's trigger wheels to make sure the tests there don't fail.

@codecov
Copy link

codecov bot commented Nov 18, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.72%. Comparing base (a5aa5ec) to head (ca1aa3a).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2199      +/-   ##
==========================================
+ Coverage   97.55%   97.72%   +0.16%     
==========================================
  Files          93       93              
  Lines       11180    11180              
  Branches     1065     1065              
==========================================
+ Hits        10907    10926      +19     
+ Misses        208      192      -16     
+ Partials       65       62       -3     

☔ 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
Copy link
Contributor Author

Should I include wheel builds for this PR?

@mudit2812 mudit2812 requested a review from mehrdad2m November 18, 2025 21:17
irdl_options = [ParsePropInAttrDict()]

# pylint: disable=too-many-branches
def verify_(self):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mehrdad2m CodeFactor was complaining about DynamicBroadcastInDimOp.verify_ being too complex, so I broke it down into multiple smaller methods. Let me know if the split makes sense to you.


# pylint: disable=no-member
# pylint: disable=too-many-branches
def verify_(self):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mehrdad2m same thing here, CodeFactor was complaining about the method being too complex.

mudit2812 and others added 2 commits November 27, 2025 14:03
**Context:**
Migrates the `chore/xdsl-utils` branch from PennyLane.

**Description of the Change:**
Renames the visualization module to inspection and improves several xDSL
parsing utilities within the python interface.

**Benefits:**
Simplifies and augments existing utility functions within the
~visualization~ inspection module

**Possible Drawbacks:**

**Related GitHub Issues:**
[sc-104851]
Copy link
Contributor

@mehrdad2m mehrdad2m left a comment

Choose a reason for hiding this comment

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

I noticed there are still some remaining references to the Python compiler, so I added some suggestions for that.

Comment on lines +476 to +478
# Install graphviz for testing the mlir-op-graph integration
sudo apt-get install -y graphviz
python3 -m pip install graphviz
Copy link
Contributor

Choose a reason for hiding this comment

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

We should be able to get a green make tests locally when installing Catalyst from source by following the installation guide. The problem with this approach is that it installs graphviz for ci tests but locally you would get an error if you don't have it installed. So I think we should either add graphviz to the requirements.txt and update the installation guide or completely decouple the python_interface tests from current Catalyst test suit, so it wouldn't be run in a regular call to make tests. I am fine with both but maybe the latter is more in line with previous discussions about making python_interface independent from Catalyst. What do you think?

@mudit2812 mudit2812 requested a review from mehrdad2m December 1, 2025 21:30
@mudit2812
Copy link
Contributor Author

I have confirmed locally in a Python environment without xdsl and xdsl-jax that importing catalyst and using qjit does not raise any errors due to xdsl not being installed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

unified compiler Pull requests for the integration with xDSL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants