Skip to content

[MACA] Improve target-aware compilation, SDK integration, and Relax coverage - #41

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

[MACA] Improve target-aware compilation, SDK integration, and Relax coverage#41
Zhao-Shi-jie wants to merge 5 commits into
MetaX-MACA:devfrom
Zhao-Shi-jie:mc_dev

Conversation

@Zhao-Shi-jie

@Zhao-Shi-jie Zhao-Shi-jie commented Jul 10, 2026

Copy link
Copy Markdown

This PR improves MACA backend correctness and integration:

  • Propagate Target.mcpu to mxcc and select generic or WMMA MetaSchedule rules by architecture.
  • Add the standard tvm.contrib.mxcc compatibility entry point.
  • Make MACA Target scope exception-safe with RAII.
  • Honor MACA_PATH when locating the mxcc compiler.
  • Add structural and real-device Relax tests for multinomial sampling with int32 row indices.

Validation:

  • TVM builds successfully with MACA enabled.
  • All 6 targeted MACA tests pass.
  • Verified real mxcc compilation, architecture-specific tuning rules, SDK discovery, Target restoration,
    and Relax sampling execution on a MACA device.

@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 thread python/tvm/contrib/mxcc.py Outdated
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.

mc_dev already contains the upstream fix that explicitly widens GPU multinomial row indices to int64. Add a MACA-specific regression to ensure DispatchSampling preserves int32 input buffers while emitting the required cast.

Compile and execute the generated kernel on a MACA device and check the sampled token IDs, covering both Relax dispatch and backend runtime behavior.
@Zhao-Shi-jie Zhao-Shi-jie changed the title 完善 MACA 后端适配:CMake 校验、架构传递、contrib 入口与 Relax 外部库入口 [MACA] Improve target-aware compilation, SDK integration, and Relax coverage Aug 9, 2026
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