Skip to content

Add SGLang MACA check-env reporting - #3

Open
ghangz wants to merge 3 commits into
MetaX-MACA:mainfrom
ghangz:mengz/report-maca-check-env
Open

Add SGLang MACA check-env reporting#3
ghangz wants to merge 3 commits into
MetaX-MACA:mainfrom
ghangz:mengz/report-maca-check-env

Conversation

@ghangz

@ghangz ghangz commented Jun 25, 2026

Copy link
Copy Markdown

Summary

  • This change extends SGLang check-env output with MACA-specific diagnostics so reviewers and operators can capture compiler, runtime, and path information before running heavier inference tests.
  • The implementation is scoped to diagnostics and runtime setup paths used by MetaX MACA validation, so existing non-MACA behavior remains compatible.
  • Main files: python/sglang/check_env.py, test/registered/unit/test_check_env_maca.py

Validation

  • Verified on Gitee.AI MetaX GPU resources in the SGLang/PyTorch MACA validation batch.
  • Branch validation command: python -m pytest test/registered/unit/test_check_env_maca.py
  • Pull request text is ASCII-only to avoid encoding issues on web forms and API clients.

Review notes

  • Source branch: ghangz:mengz/report-maca-check-env
  • Target branch: MetaX-MACA/sglang:main
  • Maintainers can modify this branch if follow-up adjustments are needed.

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

Copy link
Copy Markdown

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 adds support for MetaX MACA GPU environment checking by introducing the MACAEnv class and corresponding unit tests. The review feedback suggests removing redundant package definitions that mutate global state, adding timeouts to subprocess executions to prevent hanging, and replacing hardcoded values in the test suite with standard constants.

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 python/sglang/check_env.py Outdated
Comment on lines +233 to +244
class MACAEnv(BaseEnv):
"""Environment checker for MetaX MACA GPU."""

EXTRA_PACKAGE_LIST = [
"vllm",
"triton",
]

def __init__(self):
super().__init__()
self.package_list.extend(MACAEnv.EXTRA_PACKAGE_LIST)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

PACKAGE_LIST(第 35 行和第 54 行)中已经包含了 "triton""vllm"。因此,这里的 EXTRA_PACKAGE_LIST 是多余的。此外,BaseEnv.__init__self.package_list = PACKAGE_LIST 是对全局列表的引用,直接调用 self.package_list.extend(...) 会在原地修改全局的 PACKAGE_LIST,导致重复元素和潜在的副作用。建议直接移除 EXTRA_PACKAGE_LIST__init__ 方法。

Suggested change
class MACAEnv(BaseEnv):
"""Environment checker for MetaX MACA GPU."""
EXTRA_PACKAGE_LIST = [
"vllm",
"triton",
]
def __init__(self):
super().__init__()
self.package_list.extend(MACAEnv.EXTRA_PACKAGE_LIST)
class MACAEnv(BaseEnv):
"""Environment checker for MetaX MACA GPU."""

Comment on lines +290 to +293
cucc_output = (
subprocess.check_output(
[cucc, "--version"], stderr=subprocess.STDOUT
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

为了防止在工具链或驱动出现异常(例如 GPU 卡死、锁死)时导致 check_env 脚本无限期挂起,建议为 subprocess.check_output 调用添加 timeout 参数(例如 timeout=10)。

Suggested change
cucc_output = (
subprocess.check_output(
[cucc, "--version"], stderr=subprocess.STDOUT
)
cucc_output = (
subprocess.check_output(
[cucc, "--version"],
stderr=subprocess.STDOUT,
timeout=10,
)

Comment on lines +309 to +313
output = subprocess.check_output(
[mx_smi, "--show-version"],
stderr=subprocess.STDOUT,
text=True,
).strip()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

同样地,建议为 mx-smisubprocess.check_output 调用添加 timeout=10 参数,以防止在驱动或工具链挂起时导致脚本卡死。

Suggested change
output = subprocess.check_output(
[mx_smi, "--show-version"],
stderr=subprocess.STDOUT,
text=True,
).strip()
output = subprocess.check_output(
[mx_smi, "--show-version"],
stderr=subprocess.STDOUT,
text=True,
timeout=10,
).strip()

Comment on lines +325 to +331
result = subprocess.run(
[mx_smi, *args],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True,
check=True,
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

建议为 subprocess.run 添加 timeout=10 参数,防止获取拓扑信息时因 GPU 响应超时而导致脚本挂起。

Suggested change
result = subprocess.run(
[mx_smi, *args],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True,
check=True,
)
result = subprocess.run(
[mx_smi, *args],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True,
check=True,
timeout=10,
)

Comment on lines +70 to +73
mock_check_output.assert_called_once_with(
[os.path.join("/opt/cucc", "bin", "cucc"), "--version"],
stderr=-2,
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

避免硬编码 stderr=-2,建议使用 self.check_env.subprocess.STDOUT。同时,如果我们在 check_env.py 中为 subprocess.check_output 增加了 timeout=10 参数,测试中的断言也需要同步加上 timeout=10

Suggested change
mock_check_output.assert_called_once_with(
[os.path.join("/opt/cucc", "bin", "cucc"), "--version"],
stderr=-2,
)
mock_check_output.assert_called_once_with(
[os.path.join("/opt/cucc", "bin", "cucc"), "--version"],
stderr=self.check_env.subprocess.STDOUT,
timeout=10,
)

@ghangz ghangz changed the title 在 check_env 中报告 MACA 工具链信息 ???????? MACA ????? Jun 26, 2026
@ghangz ghangz changed the title ???????? MACA ????? 在环境检查中补充 MACA 工具链信息 Jun 26, 2026
@ghangz ghangz changed the title 在环境检查中补充 MACA 工具链信息 Add SGLang MACA check-env reporting Jul 1, 2026
- Report MACA toolchain in check_env
- Refine MACA environment checks
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