Ship only the MLIR dialects numba-cuda-mlir uses #463
All Vouch review confidence checks passed
Residual risk 0.22 = Change Risk (0.52) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #463"
general
weight: 0.35
atmnp
xref https://github.com/NVIDIA/numba-cuda-mlir/issues/133#issuecomment-5025522204
numba-cuda-mlir bundles upstream's stock MLIR Python package. Its
_mlirRegisterEverythinglinks every upstream dialect, conversion and pass into the MLIR Python CAPI library, and the LLVM build compiles all of MLIR to get there. numba-cuda-mlir imports 18 dialects and runs one pass pipeline.This PR builds our own
numba_cuda_mlir._mlirinstead, incext/mlir-python/, the LLVM external project that #466 added. It takes upstream's declared Python sources for those 18 dialects and adds a_site_initialize_0module that registers only the dialects, interface models, pipeline passes and LLVM IR translations numba-cuda-mlir needs. No MLIR source patch is involved. The CAPI library keeps the unique name and Windows LLVM-C exports from #466.ci/build-llvm-modern.shthen builds and installs only LLVM distribution components: the package plus the librariescext/links viafind_package(MLIR). A first configure computes that list from the CMake link graph.Linux x86_64, same LLVM pin and flags,
-j8, no compiler cache:| | main | this PR |
|---|---|---|
| LLVM build, wall / CPU | 29m24s / 3h52m | 21m44s / 2h50m |
| MLIR Python CAPI library | 172 MB | 92 MB |
| wheel without
libLLVM-7.so, compressed | 57.9 MB | 28.3 MB || LLVM install dir (CI cache and artifact) | 980 MB | 636 MB |
CI wheel artifacts for cp312,
mainat f77f830 vs this PR:| | main | this PR |
|---|---|---|
| linux-64 | 70.6 MB | 41.7 MB |
| linux-aarch64 | 66.6 MB | 39.4 MB |
| win-64 | 41.5 MB | 21.5 MB |
| win-arm64 | 28.3 MB | 11.2 MB |
The full test suite gives identical results on both local Linux wheels.
tests/mlir/test_registration.pychecks that the base pipeline parses and that the dialects numba-cuda-mlir uses are registered, so a pass added tomlir_optimization.pywithout being registered fails there.Notes:
cext/mlir-python/CMakeLists.txtdoes not name them. At this LLVM pin they come in through upstream libraries we do need; see "How SPIR-V and ROCDL get in" below.CMAKE_OBJECT_PATH_MAXis lowered forcext/mlir-python. Upstream's binding sources are outside that directory, so their object paths embed the absolute source path, and on the GitHub-hosted runners one went past MSVC's 260-character limit.<details>
<summary>How SPIR-V and ROCDL get in</summary>
Why they are compiled. CMake builds the whole link closure of the libraries we list.
MLIRGPUTransformsis needed forgpu-kernel-outliningand the GPU interface models, andcext/mlir-llvm70links it. At this pin it also containsSPIRVAttachTarget.cpp,ROCDLAttachTarget.cppandXeVMAttachTarget.cpp, and linksMLIRSPIRVTarget,MLIRROCDLTarget,MLIRROCDLDialect,MLIRAMDGPUDialectandMLIRXeVMDialect. The GPU-to-NVVM conversions we register reach the same libraries through their own dependencies.MLIRToLLVMIRTranslationRegistration, whichllvm70-translateincext/mlir-llvm70links, links every LLVM IR translation, SPIR-V and ROCDL included.Why they end up in the CAPI library. The linker keeps only the objects something references, but C API libraries are embedded whole.
gpuPython dialect brings in upstream's_mlirDialectsGPUextension, which embedsMLIRCAPIGPU.MLIRCAPIGPUincludesGPUPasses.cpp, which generates an exported C create and register function for every GPU pass,spirv-attach-targetandrocdl-attach-targetincluded.nm -Dshows about 3 MB of exportedmlir::spirvsymbols and 2.6 MB ofmlir::ROCDL.What dropping them would take. Declaring our own
gpuPython sources, without upstream's_mlirDialectsGPUand_mlirGPUPassesextensions, plus a GPU C API built from upstream'slib/CAPI/Dialect/GPU.cppalone, should keep them out of the CAPI library; this has not been tried. They would still be compiled unless the attach-target passes were in a library of their own, which they are not at this pin.</details>
<details>
<summary>Upstream patterns this follows</summary>
Package assembly follows upstream's
mlir/examples/standalone:MLIRPythonSources.CoreandMLIRPythonSources.Dialects.builtinplus its own dialect, with no_mlirRegisterEverything.cext/mlir-python/CMakeLists.txtdoes the same with 18 dialect groups.cext/mlir-pythonplugs into the LLVM build.Dialect registration differs from the example. The example registers its dialects through a
register_dialects(context)function the user calls. Here everyContextgets them automatically, as with the stock package, through the hook in_mlir_libs/__init__.py: when_mlirRegisterEverythingis absent, it loads_site_initialize_0,_1, ... and calls theirregister_dialectsfor each new context. WhatRegistration.cppregisters follows upstream'sRegisterAllDialects.cppandRegisterAllExtensions.cpp, filtered to these dialects.Building only what is needed is LLVM's
LLVM_DISTRIBUTION_COMPONENTSmechanism, described in BuildingADistribution.rst.</details>
-- Leo's bot