-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove pybind11 modules from Catalyst's core MLIR libs #1187
base: main
Are you sure you want to change the base?
Conversation
Hello. You may have forgotten to update the changelog!
|
This reverts commit 0628a5e.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1187 +/- ##
=======================================
Coverage 98.37% 98.37%
=======================================
Files 78 78
Lines 11361 11361
Branches 990 990
=======================================
Hits 11176 11176
Misses 127 127
Partials 58 58 ☔ View full report in Codecov by Sentry. |
This reverts commit 848963f.
**Context:** I had observed when working on the pybind11 -> nanobind conversions in the MLIR python binding (#1187) that the `test_pipeline_error` test fails on some platforms because it asserts that the string `"Trace"` (with a capital "T") is in the error message, but it is not, even though the stack trace was printed. Normally, it would match the string `"Trace"` in the first line of the stack trace, which contains `"llvm::sys::PrintStackTrace"`. For whatever reason, this line is not always printed out. We can make this test more robust by matching a string not contained within the stack trace itself, but one immediately preceding it, which should always be part of the error message. I've chosen `"diagnostic emitted with trace"` for this purpose (but I'm happy to take other suggestions). **Description of the Change:** Change test from ```python assert "Trace" in e.value.args[0] ``` to ```python assert "diagnostic emitted with trace" in e.value.args[0] ``` and similarly when asserting that there is **no** stack trace in the error message. **Benefits:** More robust test; unblocks #1187.
We'll need to revisit this PR once #1285 is merged in, since it removes the Good news at least that the build system is now sorted out! 🟢 |
Now that #1285 has been merged, there is no need for nanobind in Catalyst's core MLIR libraries
With the removal of the mlir/python/PyCompilerDriver.cpp module in #1285, there is now no more pybind11 code to replace with nanobind in Catalyst's core MLIR libs! I've updated the title and description to reflect this change. |
Context:
Catalyst's core MLIR libraries originally contains two Python extension modules (importable Python modules written in C/C++):
The Python-C++ bindings were originally implemented using pybind11. This PR is part of a larger effort to replace all pybind11 code with nanobind.
However, mlir/python/PyCompilerDriver.cpp was removed in PR #1285, and we have decided to remove mlir/python/QuantumExtension.cpp entirely since we do not ship this module with our wheels. Therefore, we can remove all pybind11 code in Catalyst's core MLIR libs, with no need to replace these modules with nanobind.
Description of the Change:
This change replaces all the pybind11 code in mlir/python/PyCompilerDriver.cpp with the equivalent nanobind objects and operations.This change removes the MLIR python module
QuantumExtension
entirely, along with associated tests and infrastructure, since (a) it depends on upstream MLIR Python bindings written in pybind11: mlir/Bindings/Python/PybindAdaptors.h, which would be quite onerous to port to nanobind, and (b) we do not actually use these dialect extensions, nor do we ship them with our wheels.Benefits:
See Epic 68472 for a list of nanobind's benefits.
[sc-72842]