执行摘要
此PR为AMD RDNA 3架构的gfx1102和gfx1103 GPU(如Radeon 780M iGPU)添加支持,修复了因架构宏缺失导致的运行时崩溃。核心改动是用编译器提供的通用宏__GFX11__/__GFX12__替代手动枚举单个架构,避免未来遗漏。
功能与动机
gfx1103(RDNA 3,如Radeon 780M iGPU)未包含在HIP_SUPPORTED_ARCHS列表及编译时架构宏中,导致wvSplitK内核在gfx1103上编译为UNREACHABLE_CODE(assert false),运行时崩溃。
实现拆解
-
CMakeLists.txt:在HIP_SUPPORTED_ARCHS列表中添加gfx1102和gfx1103,确保CMake构建系统能识别并编译这些架构的代码。
-
csrc/rocm/skinny_gemms.cu:移除手动枚举各gfx11xx/gfx12xx的宏定义,改用编译器提供的__GFX11__和__GFX12__宏(这些宏在对应架构下自动定义)。同时,内核条件编译中的__HIP__GFX12__也替换为__GFX12__,保持一致性。
// Before: manual enumeration of each arch
// #if defined(__HIPCC__) && (defined(__gfx1100__) || defined(__gfx1101__) || ...)
// #define __HIP__GFX1X__
// #endif
// After: use compiler-provided macros that cover all family members
#if defined(__GFX11__) || defined(__GFX12__)
#define __HIP__GFX1X__
#endif
// Kernel condition also updated
#if defined(__HIP__MI3XX__) || defined(__GFX12__)
// ... actual FP8 kernel ...
#else
// ... UNREACHABLE_CODE fallback ...
#endif
- csrc/rocm/attention.cu:同样移除手动定义的
__HIP__GFX11__和__HIP__GFX12__宏,在引用处直接使用__GFX11__和__GFX12__宏。
// Remove custom macro definitions
// #if defined(__HIPCC__) && (defined(__gfx1100__) || defined(__gfx1101__) || ...)
// #define __HIP__GFX11__
// #endif
// Use compiler macros directly
#elif defined(__GFX11__)
// ... gfx11 attention path ...
#elif defined(__GFX12__)
// ... gfx12 attention path ...
评论区精华
无实质讨论,仅有一条自动机器人评论和一条approve。
风险与影响
风险:低风险。改动为宏替换和列表扩展,不涉及逻辑变更。但需确保所有使用旧宏__HIP__GFX11__/__HIP__GFX12__的地方已全部替换,避免遗漏。本PR已覆盖skinny_gemms.cu和attention.cu两个主要文件。
影响:
- 正向:支持gfx1102/gfx1103(如Radeon 780M iGPU),扩大AMD ROCm硬件兼容性。
- 无影响:现有gfx1100/1101/1150等架构不受影响,NVIDIA/Intel平台不受影响。
关联脉络
本PR与近期[ROCm]相关的PR(如#39789,XPU平台类似问题)共同体现了vLLM对不同硬件平台的持续适配。采用编译器提供的通用宏是一种更健壮的做法,未来的gfx11xx/gfx12xx变体将自动获得支持,无需再次修改源代码。
参与讨论