[None][fix] Generate CUTLASS kernel instantiations without installing cutlass_library#16215
[None][fix] Generate CUTLASS kernel instantiations without installing cutlass_library#16215lucifer1004 wants to merge 1 commit into
Conversation
… cutlass_library The kernel-instantiation setup step ran 'setup_library.py develop --user', writing an egg-link and easy-install.pth entries into the invoking user's ~/.local site-packages. That location is shared across every checkout the user builds, so successive builds of different checkouts silently repoint each other's cutlass_library; and when the interpreter runs with user site disabled (PYTHONNOUSERSITE=1 — the default posture of externally managed conda/pixi/uv environments — or a virtualenv), the install lands somewhere the very same interpreter refuses to import from, and generate_kernels.py fails with ModuleNotFoundError. Simply dropping --user is not viable either: a non-root build against an unwritable system python would then fail. cutlass_library is a pure-python package that imports straight from the CUTLASS source tree, and this generation step is its only consumer, so no install is needed at all: run generate_kernels.py with PYTHONPATH pointing at the in-tree package. This works identically for root container builds, non-root bare-metal builds, virtualenvs, and externally managed environments, and stops mutating global user state from a configure step. Co-authored-by: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: Zihua Wu <13583761+lucifer1004@users.noreply.github.com>
📝 WalkthroughWalkthroughCUTLASS kernel generation no longer installs the Python package during CMake configuration. The generation command now sets ChangesCUTLASS kernel generation
Estimated code review effort: 1 (Trivial) | ~5 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
cpp/tensorrt_llm/kernels/cutlass_kernels/CMakeLists.txt (1)
46-46: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win
cmake -E env "PYTHONPATH=..."replaces, not prepends, the existingPYTHONPATH.This sets
PYTHONPATHto only the CUTLASS source-tree dir, discarding anyPYTHONPATHthe invoking environment already had. If the generation step (or a transitive import incutlass_library) relies on other entries, those are dropped. Consider preserving them, e.g.--modify PYTHONPATH=path_list_prepend:${cutlass_source_dir}/python(CMake ≥ 3.22) or expanding$ENV{PYTHONPATH}.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@cpp/tensorrt_llm/kernels/cutlass_kernels/CMakeLists.txt` at line 46, Preserve the caller’s existing PYTHONPATH in the CMake command invoking the CUTLASS generation step. Update the environment setup around the relevant custom command to prepend ${cutlass_source_dir}/python using CMake’s path-list modification support, or explicitly retain $ENV{PYTHONPATH} for compatibility with older CMake versions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@cpp/tensorrt_llm/kernels/cutlass_kernels/CMakeLists.txt`:
- Line 46: Preserve the caller’s existing PYTHONPATH in the CMake command
invoking the CUTLASS generation step. Update the environment setup around the
relevant custom command to prepend ${cutlass_source_dir}/python using CMake’s
path-list modification support, or explicitly retain $ENV{PYTHONPATH} for
compatibility with older CMake versions.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: dc07a87c-963e-4dfb-8f8d-736597b7ce87
📒 Files selected for processing (1)
cpp/tensorrt_llm/kernels/cutlass_kernels/CMakeLists.txt
The cutlass_kernels CMake step made
cutlass_libraryimportable for the kernel-instantiation generator by runningsetup_library.py develop --userat configure time. Under externally managed Python environments (conda/pixi/uv, which commonly setPYTHONNOUSERSITE=1) this is self-defeating — the install writes to the user site that the interpreter then refuses to read, and the generator fails withModuleNotFoundError: cutlass_library. It also mutates the user's home site-packages (~/.localeasy-install path entries) as a side effect of building one checkout, leaking state into every other Python environment of that user.This change drops the develop-install entirely and runs the generator with
PYTHONPATHpointing at the vendored CUTLASS python directory. Same generation output, no installation, no mutation outside the build tree.🤖 Generated with Claude Code
Summary by CodeRabbit