Fix(sgl-kernel/rocm): enable RDNA3.5 (gfx1151) and cap TopK LDS - #28518
Fix(sgl-kernel/rocm): enable RDNA3.5 (gfx1151) and cap TopK LDS#28518Arkar-Hema wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request improves ROCm support by handling rocminfo failures gracefully via a PyTorch fallback, allowing explicit AMDGPU_TARGET overrides during compilation on hosts with active GPUs, and capping dynamic shared memory for gfx1151. The review feedback suggests wrapping the rocminfo parsing in a try-except block to prevent unhandled ValueError exceptions, and whitelisting only large LDS targets (like gfx950) to default all other architectures to the safe 48KB limit and avoid runtime crashes.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Build sgl-kernel for explicit AMDGPU_TARGET (e.g. gfx1151) and size the TopK dynamic shared memory to 48KB for 64KB-LDS archs (gfx942 + RDNA3.5) instead of 128KB, which only fits gfx950. Also fallback to torch mem_get_info when rocminfo reports no memory on ROCm. Tested on gfx1151 (Strix Halo)
c2f84f7 to
5ca7634
Compare
Motivation
Closes the RDNA gap behind #27519. AMD RDNA3.5 GPUs (gfx1151 — Strix Halo "Ryzen AI MAX") could not build or run
sgl-kernelon ROCm, even though the kernels themselves are compatible.#27535 already improved this by honoring an explicit
AMDGPU_TARGETso the build no longer hard aborts at thegfx942/gfx950whitelist. That is the right first step, but it only opens the gate subtly — it's an opt-in escape hatch ("continue with an unsupported arch") that does not make RDNA actually runnable: the build still emits a TopK kernel sized for CDNA shared memory, which crashes at launch on RDNA. This PR completes the enablement.What this PR changes
1.
sgl-kernel/setup_rocm.py— honor explicitAMDGPU_TARGET+ correct the TopK LDS budgetAMDGPU_TARGET-wins behavior (consistent with / superseding fix(sgl-kernel/rocm): honor explicit AMDGPU_TARGET over auto-detection #27535) so RDNA targets build without removing the upstream whitelist guard.2.
python/sglang/srt/utils/common.py— robust AMD memory detectionget_amdgpu_memory_capacity()shells out torocminfo; on some ROCm stacks (observed with TheRock on Strix Halo)rocminforeturns no parseable pool size or segfaults, which raised and prevented server startup. Added a fallback to torch'smem_get_info()(the helper already used elsewhere in this file) whenrocminfoyields nothing.Why #27535 alone is not enough (the subtle part)
With only #27535,
AMDGPU_TARGET=gfx1151 python setup_rocm.pybuilds and the wheel imports — so it looks supported — but the first call into the TopK kernel fails:This is
hipFuncSetAttribute(hipFuncAttributeMaxDynamicSharedMemorySize, 131072)being rejected because 128KB > the 64KB LDS limit on RDNA. Normal dense / standard-MoE serving never reaches this kernel, so a smoke test passes and the regression stays hidden; it only surfaces on the DeepSeek-V3.2 sparse-attention TopK path (fast_topk_v2,topk=2048) anddeepseek_v4_topk.Testing
Hardware: AMD Ryzen AI MAX+ 395 / Radeon 8060S (gfx1151, RDNA3.5), PyTorch 2.10+rocm7.13.
Device LDS confirmed:
torch.cuda.get_device_properties(0).shared_memory_per_block == 65536(64KB).Validated three configurations on the same hardware:
AMDGPU_TARGET=gfx1151)SGL_TOPK_DYNAMIC_SMEM_BYTESfast_topk_v2, topk=2048)131072(128KB)set_up_kernel_once failed: invalid argument49152(48KB)from sgl_kernel import fast_topk_v2; fast_topk_v2(score, lengths, 2048)); with this PR's 48KB cap the identical call succeeds.sglang.launch_serverwithQwen/Qwen2.5-0.5B-Instruct(triton attention backend) starts and serves correct/v1/chat/completionsresponses on gfx1151.CI States
Latest PR Test (Base): ❌ Run #27680257272
Latest PR Test (Extra): ❌ Run #27680257105