[JIT] Inject target architecture flag into JIT compilation - #20103
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the JIT compilation process by providing a consistent mechanism to detect and utilize the target CUDA architecture across both host and device compilation passes. This change is crucial for enabling architecture-specific optimizations and features, such as PDL, to function correctly regardless of the compilation stage, ultimately improving the flexibility and robustness of the JIT kernel system. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a mechanism to inject the target CUDA architecture as a compile-time flag, which is a great improvement for enabling host-side dispatch based on GPU capabilities. The implementation is clean, with a clear fallback from __CUDA_ARCH__ to the new SGL_CUDA_ARCH macro. The refactoring of the PDL guards to use the new SGL_ARCH_HOPPER_OR_GREATER macro is also well done.
I have one point of feedback regarding the definition for Blackwell architecture support, which uses a speculative future CUDA toolkit version. Please see the specific comment for details.
|
Hi @DarkSharpness , could you help take a look at this PR? It's a follow-up to #19794 based on your suggestion. Once this is merged, #19794 can be resolved as well. Thanks! |
|
/tag-and-rerun-ci |
|
/rerun-failed-ci |
|
Hi @BBuf , request merge for PR.
|
Hi @Fridge003 @BBuf could you help merge this PR? It's approved and I have other PRs depending on this one. Thanks! |
|
@xingsy97 Hi can you take a look at this bug? I encountered this on SM120... thanks. |
The compile commands looks strange @b8zhong : We somehow have both Have you ever set |
|
The root cause should be this: @b8zhong sglang/python/sglang/jit_kernel/nvfp4.py Lines 112 to 124 in 20a23e3 These lines override the env var, which lead to error since we only assume one target in this PR. |
|
Good catch on adding the |
|
@b8zhong @DarkSharpness Thanks for report and quick investigation. I'm writing a fix for this. |
|
|
Hi, thanks @DarkSharpness. I did not |
|
Conclusion for the bug reported by @b8zhong
|
Motivation
Follow-up from #19794 (comment by @DarkSharpness):
__CUDA_ARCH__is only available in the device pass, so arch macros can't be used for host-side dispatch. This PR injects-DSGL_CUDA_ARCH=<value>viaload_jit()so that arch-dependent macros work in both host and device passes.Modifications
utils.py: Inject-DSGL_CUDA_ARCH={major*100+minor*10}into JIT cuda cflags based ontorch.cuda.get_device_capability().utils.cuh: AddSGL_TARGET_CUDA_ARCH(prefers__CUDA_ARCH__in device pass, falls back toSGL_CUDA_ARCHin host pass). DefineSGL_ARCH_HOPPER_OR_GREATERandSGL_ARCH_BLACKWELL_OR_GREATER. Refactor PDL guards to use them.Accuracy Tests
Compile-time only change. No kernel logic modified.
Benchmarking and Profiling
No performance impact.
Checklist