执行摘要
修复 MUSA 启动时 torchada 兼容性问题
SGLang 在 MUSA 启动时因 triton.language.extra 缺少 cuda 属性而失败,关联 MooreThreads/torchada#70 提供了上游补丁,本 PR 更新依赖并跳过 CUDA 特定路径。
建议快速合并,属于紧急平台兼容性修复。
审核者 yeahdongcn 要求为新函数添加类似 AMD 注释的注释,作者按要求添加了 # MThreads/MUSA note: 注释。
SGLang 在 MUSA 启动时因 triton.language.extra 缺少 cuda 属性而失败,关联 MooreThreads/torchada#70 提供了上游补丁,本 PR 更新依赖并跳过 CUDA 特定路径。
建议快速合并,属于紧急平台兼容性修复。
审核者 yeahdongcn 要求为新函数添加类似 AMD 注释的注释,作者按要求添加了 # MThreads/MUSA note: 注释。
is_musa_runtime() 函数:在 python/sglang/jit_kernel/utils.py 中添加,通过 hasattr(torch.version, "musa") 检测 MUSA 运行时。is_arch_support_pdl():在同一个文件中,将条件从 is_hip_runtime() 扩展为 is_hip_runtime() or is_musa_runtime(),使 MUSA 平台也禁用 PDL 探测。torchada>=0.1.56 改为 torchada>=0.1.57,确保使用包含 MUSA 补丁的版本。| 文件 | 模块 | 状态 | 重要度 |
|---|---|---|---|
python/sglang/jit_kernel/utils.py |
JIT 内核 | modified | 6.64 |
3rdparty/amd/wheel/sglang/pyproject.toml |
AMD 构建 | modified | 3.3 |
python/pyproject_other.toml |
其他 Python 包 | modified | 3.3 |
sgl-kernel/pyproject_musa.toml |
SGL 内核 | modified | 3.3 |
python/sglang/jit_kernel/utils.py
core-logic
核心逻辑变更:新增 is_musa_runtime() 函数并修改 is_arch_support_pdl() 条件。
# python/sglang/jit_kernel/utils.py
# AMD/ROCm note:
@cache_once
def is_hip_runtime() -> bool:
return bool(torch.version.hip)
# MThreads/MUSA note:
@cache_once
def is_musa_runtime() -> bool:
"""
检测当前是否运行在 MThreads MUSA 平台上。
torch.version.musa 存在且不为 None 时返回 True。
"""
return hasattr(torch.version, "musa") and torch.version.musa is not None
@cache_once
def is_arch_support_pdl() -> bool:
# 同时排除 HIP 和 MUSA 平台,避免 CUDA 特定的 PDL 探测
if is_hip_runtime() or is_musa_runtime():
return False
return get_jit_cuda_arch().major >= 9
3rdparty/amd/wheel/sglang/pyproject.toml
configuration
升级 torchada 依赖版本,确保使用包含 MUSA 补丁的版本。
# 3rdparty/amd/wheel/sglang/pyproject.toml
srt_musa = [
"sglang[runtime_common]",
"torch",
"torch_musa",
"torchada>=0.1.57", # 从 0.1.56 升级,以修复 MUSA 启动时的 AttributeError
"mthreads-ml-py",
"mate>=0.2.0",
"deep-gemm>=0.1.3",
"flash_attn_3>=0.1.4",
"numpy<2.0",
]
审核者 yeahdongcn 要求为新函数添加类似 AMD 的注释。
结论:作者添加了 `# MThreads/MUSA note:` 注释。 · 已解决
风险极低:变更范围有限,核心改动是新增运行时检测函数和条件判断,配置升级只改版本号下限。不涉及 CUDA/NPU 等其他后端。
影响范围限于 MThreads MUSA 平台用户,修复了启动崩溃问题,对其他平台无影响。
参与讨论