Skip to content

解析沐曦 CUDA 兼容编译器#280

Open
ghangz wants to merge 2 commits into
MetaX-MACA:masterfrom
ghangz:mengz/resolve-maca-cuda-compiler
Open

解析沐曦 CUDA 兼容编译器#280
ghangz wants to merge 2 commits into
MetaX-MACA:masterfrom
ghangz:mengz/resolve-maca-cuda-compiler

Conversation

@ghangz

@ghangz ghangz commented Jun 8, 2026

Copy link
Copy Markdown

该 PR 增加对沐曦 CUDA 兼容编译器位置的解析逻辑,使需要编译扩展或检查工具链的场景能获得更准确的编译器路径。

这个修改面向沐曦 GPU 适配场景中比较容易影响开发、构建或验证稳定性的环节,把原来需要人工排查的问题前移到工具链、运行前检查或基准脚本中处理。实现上保持对现有默认行为的兼容,只在检测到明确配置、输入或环境异常时给出更直接的诊断,避免引入额外运行依赖,也方便维护者独立审阅该分支。

已在沐曦算力环境中完成对应分支验证,验证记录包含真实运行日志、命令输出和失败路径检查,本地归档目录为:E:/Documents/muxi/测试报告/vLLM-metax_real_env_validation_20260608。提交分支:mengz/resolve-maca-cuda-compiler,目标仓库:MetaX-MACA/vLLM-metax

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a helper function get_maca_cuda_compiler in setup.py to dynamically locate the MACA CUDA compiler (cucc or nvcc) using environment variables (CUDA_HOME, CUCC_PATH, and MACA_PATH), and updates the CMake configuration to use this compiler when building in a MACA environment. The reviewer suggests reordering the compiler candidate search priority to check CUCC_PATH and MACA_PATH before CUDA_HOME to prevent incorrectly selecting standard NVIDIA CUDA over the MACA compiler in mixed environments.

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.

Comment thread setup.py Outdated
Comment on lines +88 to +93
if CUDA_HOME:
candidates.append(Path(CUDA_HOME) / "bin" / "nvcc")
if os.getenv("CUCC_PATH"):
candidates.append(Path(os.environ["CUCC_PATH"]) / "bin" / "cucc")
if os.getenv("MACA_PATH"):
candidates.append(Path(os.environ["MACA_PATH"]) / "tools" / "cu-bridge" / "bin" / "cucc")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

在 MACA 编译环境中,CUCC_PATHMACA_PATH 是专门为沐曦编译器设置的环境变量。如果将 CUDA_HOME(通常指向标准的 NVIDIA CUDA 路径)排在最前面,那么在同时存在标准 CUDA 环境(例如 CUDA_HOME 已被默认设置)和 MACA 环境的系统中,代码会优先选择标准的 nvcc,而不是沐曦的 cucc。这会导致编译失败或无法正确使用沐曦的编译器。

建议将 CUCC_PATHMACA_PATH 的优先级提高,排在 CUDA_HOME 之前。

Suggested change
if CUDA_HOME:
candidates.append(Path(CUDA_HOME) / "bin" / "nvcc")
if os.getenv("CUCC_PATH"):
candidates.append(Path(os.environ["CUCC_PATH"]) / "bin" / "cucc")
if os.getenv("MACA_PATH"):
candidates.append(Path(os.environ["MACA_PATH"]) / "tools" / "cu-bridge" / "bin" / "cucc")
if os.getenv("CUCC_PATH"):
candidates.append(Path(os.environ["CUCC_PATH"]) / "bin" / "cucc")
if os.getenv("MACA_PATH"):
candidates.append(Path(os.environ["MACA_PATH"]) / "tools" / "cu-bridge" / "bin" / "cucc")
if CUDA_HOME:
candidates.append(Path(CUDA_HOME) / "bin" / "nvcc")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant