Report Clang CUDA compile errors (GH-1325)#1503
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (3)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughThe PR consolidates error checking in build_cuda() so LLVM/Clang CUDA compile errors set and check ChangesUnified CUDA Compilation Error Handling
sequenceDiagram
participant build_cuda
participant wp_compile_cuda
participant wp_cuda_compile_program
alt llvm_cuda enabled
build_cuda->>wp_compile_cuda: compile CUDA source (Clang/LLVM)
wp_compile_cuda-->>build_cuda: err
else llvm_cuda disabled
build_cuda->>wp_cuda_compile_program: compile CUDA source (NVRTC)
wp_cuda_compile_program-->>build_cuda: err
end
build_cuda->>build_cuda: if err != 0 raise Exception("CUDA kernel build failed with error code ...")
🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Greptile SummaryThis PR fixes a silent error-swallowing bug in the Clang/LLVM CUDA compilation path where the return value of
Confidence Score: 5/5Safe to merge — the change is a minimal, targeted fix that captures and checks a previously discarded return value. The fix is small and well-scoped: wp_compile_cuda has restype=ctypes.c_int explicitly set in context.py, so the captured err is always a Python int. Moving the unified if err != 0 check outside the if/else correctly handles both code paths without introducing any new risk. The test follows patterns used extensively across the test suite. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[build_cuda called] --> B{llvm_cuda?}
B -- Yes --> C["err = wp_compile_cuda(...)"]
B -- No --> D["err = wp_cuda_compile_program(...)"]
C --> E{err != 0?}
D --> E
E -- Yes --> F["raise Exception CUDA kernel build failed"]
E -- No --> G[Return / Continue]
Reviews (4): Last reviewed commit: "Report Clang CUDA compile errors (GH-132..." | Re-trigger Greptile |
ce24f51 to
8dfe51c
Compare
|
I think this looks good. @snico432 what prompted wanting to fix this? The Clang compilation path for CUDA is just in a prototype state in case we have a use for it later or need another compiler to compare to. Just curious if you have a specific use for it. |
|
@c0d1f1ed I don't have a specific use case. An engineer from your team came to one of my lectures and gave a presentation about the project and I found it interesting. I'm just trying to learn more about compilers while hopefully making some open-source contributions. |
8dfe51c to
5ad2363
Compare
Signed-off-by: Sebastian Nicolas <snicolas432@gmail.com>
5ad2363 to
cd99b5b
Compare
|
/ok to test cd99b5b |
|
Thanks for the contribution, @snico432! I appreciate that you kept the branch consistently at one commit that was up-to-date with Some minor feedback for future pull requests in the repo:
There is overhead in reviewing pull requests, and our team is pretty small, so we would prefer to spend our time reviewing more substantive pull requests. But everyone has to start somewhere, and your pull request was already in a great shape 😃 |
|
Thanks for the feedback @shi-eric! I'll make those adjustments in future PRs. |
Description
A failed Clang CUDA compilation now raises an exception immediately instead of silently continuing and causing a downstream module-load exception that doesn't indicate the root cause. Closes #1325.
Checklist
Test plan
Added
test_invalid_native_func_compile_errorinwarp/tests/cuda/test_clang_cuda.py.Ran:
Result: test collected and skipped locally because I don't have a CUDA device available.
Bug fix
Repro from #1325:
NVRTC (uv run repro.py nvrtc):
Clang CUDA (uv run repro.py clang):
Summary by CodeRabbit
Bug Fixes
Tests
Documentation