[AMD] fix: hip rotary fallback avoiding CUDA JIT#18811
Conversation
Summary of ChangesHello @alphabetc1, 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 addresses a critical issue in ROCm environments where the 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
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
|
|
/rerun-stage stage-a-test-1-amd |
|
✅ Triggered |
There was a problem hiding this comment.
Code Review
This pull request addresses a critical runtime error for ROCm-only environments within the RotaryEmbedding layer. The issue stemmed from the default dispatch mechanism falling back to a CUDA-specific JIT compilation path on HIP devices, leading to a crash. The fix is to introduce a forward_hip method that explicitly calls the generic forward_native implementation. This correctly bypasses the problematic CUDA path. The change is well-targeted, clean, and includes a helpful comment explaining the reasoning. I approve this fix.
|
/tag-and-rerun-ci |
|
/rerun-failed-ci 1 |
|
/rerun-failed-ci 1 |
|
fixed by #18920 |
Motivation
to fix #18812
ROCm CI fails in
test/registered/test_srt_backend.pyduring runtime initialization.On HIP,
RotaryEmbeddingdispatches toforward_cudaviaMultiPlatformOp.RotaryEmbeddingfallback is selected on HIP and, after #17934, importssglang.jit_kernel.pos_enc, which JIT-compiles withcuda_files.In ROCm-only environments, this triggers CUDA toolchain discovery and fails with:
RuntimeError: Could not find CUDA installation. Please set CUDA_HOME environment variable.see: https://github.com/sgl-project/sglang/actions/runs/22000523146/job/63571754356?pr=18602
Root Cause
Regression introduced by
7d4ae057e([Kernel] Add JIT rotary_embedding_kernel),which switched HIP/CUDA fallback import from prebuilt
sgl_kernel.rotary_embeddingto JIT
sglang.jit_kernel.pos_enc.Fix
Override
RotaryEmbedding.forward_hip()to callforward_native()directly,bypassing the CUDA JIT fallback path on HIP.
Modifications
Accuracy Tests
Benchmarking and Profiling
Checklist
Review Process
/tag-run-ci-label,/rerun-failed-ci,/tag-and-rerun-ci