Skip to content

增加算子库构建计划结构化输出#35

Open
ghangz wants to merge 2 commits into
MetaX-MACA:mainfrom
ghangz:mengz/mcoplib-build-plan-json
Open

增加算子库构建计划结构化输出#35
ghangz wants to merge 2 commits into
MetaX-MACA:mainfrom
ghangz:mengz/mcoplib-build-plan-json

Conversation

@ghangz

@ghangz ghangz commented Jun 10, 2026

Copy link
Copy Markdown

这次改动补上了算子库构建计划结构化输出,主要是为了解决算子库构建和诊断流程里相关信息不够集中、人工整理成本较高的问题,让日常排查、验证和结果归档更直接。

实现上补充了对应工具或脚本逻辑,补上了对应测试,同时尽量保持现有用法不变,避免影响已有流程。

这一分支已经在沐曦算力环境完成实际验证,相关检查均已通过,现提交合入。

@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 introduces a new script tools/build_plan.py to generate and output an mcoplib build plan as JSON, along with corresponding unit tests in unit_test/test_build_plan.py. The review feedback recommends adding missing submodule flags (BUILD_VLLM_SUBMODULE and BUILD_SGLANG_SUBMODULE) to the build plan, handling potential IndexError exceptions when parsing an empty Version.txt file, and expanding the unit tests to cover these edge cases.

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 tools/build_plan.py
Comment on lines +13 to +20
SUBMODULE_FLAGS = [
"BUILD_LMDEPLOY_SUBMODULE",
"BUILD_DEFAULT_OP_SUBMODULE",
"BUILD_MOE_SUBMODULE",
"BUILD_SGL_KERNEL_SUBMODULE",
"BUILD_SGL_GROUPED_GEMM_SUBMODULE",
"BUILD_SGL_MOE_W4A16_SUBMODULE",
]

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

CMakeLists.txt 中,BUILD_VLLM_SUBMODULEBUILD_SGLANG_SUBMODULE 是两个非常关键的子模块构建选项(分别在第 135 行和第 136 行定义)。然而,它们在 SUBMODULE_FLAGS 列表中被遗漏了。

建议将它们加入到 SUBMODULE_FLAGS 中,以确保构建计划输出的完整性。

Suggested change
SUBMODULE_FLAGS = [
"BUILD_LMDEPLOY_SUBMODULE",
"BUILD_DEFAULT_OP_SUBMODULE",
"BUILD_MOE_SUBMODULE",
"BUILD_SGL_KERNEL_SUBMODULE",
"BUILD_SGL_GROUPED_GEMM_SUBMODULE",
"BUILD_SGL_MOE_W4A16_SUBMODULE",
]
SUBMODULE_FLAGS = [
"BUILD_VLLM_SUBMODULE",
"BUILD_SGLANG_SUBMODULE",
"BUILD_LMDEPLOY_SUBMODULE",
"BUILD_DEFAULT_OP_SUBMODULE",
"BUILD_MOE_SUBMODULE",
"BUILD_SGL_KERNEL_SUBMODULE",
"BUILD_SGL_GROUPED_GEMM_SUBMODULE",
"BUILD_SGL_MOE_W4A16_SUBMODULE",
]

Comment thread tools/build_plan.py Outdated
version_file = Path(maca_path) / "Version.txt"
if not version_file.is_file():
return None
return version_file.read_text(encoding="utf-8").splitlines()[0].split(":")[-1].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

如果 Version.txt 文件存在但内容为空,splitlines() 将返回一个空列表,此时直接访问 [0] 会抛出 IndexError 异常。

建议在读取行后先检查列表是否为空,以提高代码的健壮性。

Suggested change
return version_file.read_text(encoding="utf-8").splitlines()[0].split(":")[-1].strip()
lines = version_file.read_text(encoding="utf-8").splitlines()
return lines[0].split(":")[-1].strip() if lines else None

Comment on lines +14 to +17
def test_read_maca_version(self):
with tempfile.TemporaryDirectory() as tmp:
Path(tmp, "Version.txt").write_text("Version:3.5.3.20\n", encoding="utf-8")
self.assertEqual(read_maca_version(tmp), "3.5.3.20")

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

建议为 read_maca_version 增加针对空文件以及无冒号格式等边界情况的单元测试,以确保版本解析逻辑在各种异常输入下都能正确、安全地运行。

Suggested change
def test_read_maca_version(self):
with tempfile.TemporaryDirectory() as tmp:
Path(tmp, "Version.txt").write_text("Version:3.5.3.20\n", encoding="utf-8")
self.assertEqual(read_maca_version(tmp), "3.5.3.20")
def test_read_maca_version(self):
with tempfile.TemporaryDirectory() as tmp:
# 测试正常情况
Path(tmp, "Version.txt").write_text("Version:3.5.3.20\\n", encoding="utf-8")
self.assertEqual(read_maca_version(tmp), "3.5.3.20")
# 测试空文件情况
Path(tmp, "Version.txt").write_text("", encoding="utf-8")
self.assertIsNone(read_maca_version(tmp))
# 测试无冒号情况
Path(tmp, "Version.txt").write_text("Version3.5.3.20\\n", encoding="utf-8")
self.assertEqual(read_maca_version(tmp), "Version3.5.3.20")

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