Skip to content

完善 MACA 后端适配:CMake 校验、架构传递、contrib 入口与 Relax 外部库入口#41

Open
Zhao-Shi-jie wants to merge 4 commits into
MetaX-MACA:devfrom
Zhao-Shi-jie:mc_dev
Open

完善 MACA 后端适配:CMake 校验、架构传递、contrib 入口与 Relax 外部库入口#41
Zhao-Shi-jie wants to merge 4 commits into
MetaX-MACA:devfrom
Zhao-Shi-jie:mc_dev

Conversation

@Zhao-Shi-jie

Copy link
Copy Markdown

11fab38 [FIX][MACA] Avoid configure-time tvm-ffi mutation

将 MACA CMake 配置阶段对 3rdparty/tvm-ffi 和 DLPack 的自动写入改为只读校验。启用 USE_MACA 时会检查 kDLMACA/kDLMACAHost 是否已经存在,缺失时给出明确错误,避免 configure 阶段污染 submodule,也让第三方源码 patch 的来源更清晰。

41fb496 [FIX][MACA] Propagate arch and gate WMMA rules

贯通 MACA target mcpumxcc 编译命令,确保生成 -offload-arch=xcoreXXXX,并修正 xcore compute version 解析。同时 MetaSchedule 不再对所有 MACA target 无条件使用 maca-wmma,而是按显式能力列表选择规则;当前仅 xcore1000 走 WMMA,xcore700/xcore800 走普通 MACA schedule。

a1df82a [FIX][MACA] Add mxcc contrib wrapper

新增 tvm.contrib.mxcc 兼容入口,复用 tvm.support.mxcc 的实现,解决 from tvm.contrib import mxcc 导入失败的问题。这样下游代码和 contrib 风格测试可以继续使用统一的 contrib 路径。

b11271b [FIX][MACA] Add Relax contrib entrypoint

新增 Relax MACA 外部库 offload 的稳定入口 tvm.relax.backend.contrib.maca,提供 supported_libraries()is_available()partition_for_maca()。在 mcBLAS/mcDNN/mcFFT codegen 与 runtime 尚未接入前,接口会明确返回不可用或抛出 NotImplementedError,避免模块缺失或隐式失败。

@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 refactors and improves MACA support in TVM. Key changes include replacing CMake-time submodule mutation with explicit source-level checks, adding MACA architecture normalization and compute version parsing, restricting WMMA support in meta-schedule space generation to MACA targets that explicitly support it (e.g., xcore1000), and adding placeholder Relax entry points for MACA external libraries. One piece of feedback suggests removing a redundant function redefinition in python/tvm/contrib/mxcc.py to simplify the code and preserve the original docstring.

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 on lines +19 to +25
from tvm.support import mxcc as _mxcc
from tvm.support.mxcc import * # pylint: disable=wildcard-import,unused-wildcard-import


def get_maca_arch(maca_path="/opt/maca"):
"""Return the MACA architecture using the support module callback."""
return _mxcc.get_maca_arch(maca_path)

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

python/tvm/contrib/mxcc.py 中重新定义 get_maca_arch 是多余的,因为 from tvm.support.mxcc import * 已经导入并导出了具有完全相同签名和行为的 get_maca_arch。此外,tvm.support.mxcc 中的原始函数包含更详细的 docstring,而这里的重定义会覆盖并丢失这些详细的文档信息。

建议移除多余的 _mxcc 导入和 get_maca_arch 函数重定义,直接使用通配符导入即可简化该文件。

Suggested change
from tvm.support import mxcc as _mxcc
from tvm.support.mxcc import * # pylint: disable=wildcard-import,unused-wildcard-import
def get_maca_arch(maca_path="/opt/maca"):
"""Return the MACA architecture using the support module callback."""
return _mxcc.get_maca_arch(maca_path)
from tvm.support.mxcc import * # pylint: disable=wildcard-import,unused-wildcard-import

@Five-HZ

Five-HZ commented Jul 15, 2026

Copy link
Copy Markdown
Member

Thanks for your contribution, we have received this PR. Please change title and description to use English. And we will approve to run checks, please fix them first when checks failed.

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.

2 participants