Repository navigation
feat: add MACA backend support - #1
Merged
Merged
Conversation
- align clang-format configuration with InfiniTrain - format existing MACA backend sources - add GitHub Actions format checking - support .maca files in the formatting script
chen2021673
force-pushed
the
feat/maca-backend
branch
from
August 27, 2026 02:55
ee4911d to
e77e8e4
Compare
kilinchange
reviewed
Aug 27, 2026
Collaborator
Author
- run upstream PrivateUse1 suites through BUILD_TEST - reject incompatible CUDA builds and remove the local allocator test - register BF16 autocast and fix pthread detection - correct elementwise launches, embedding indexing, linear reductions, and layer norm gradients - remove redundant tensor initialization and strengthen dtype and shape checks
chen2021673
force-pushed
the
feat/maca-backend
branch
from
August 31, 2026 07:37
e77e8e4 to
9a24628
Compare
- scope ballot and shuffle operations to 32-lane logical warps - use matching CUB reduction storage for logical warp groups - remove invalid host/device attributes from the infinity constant
Use tiled FP32 multiplication with fixed-order FP64 accumulation in linear backward input.
chen2021673
force-pushed
the
feat/maca-backend
branch
from
September 3, 2026 05:20
201c877 to
8b0f394
Compare
zhoujf1
approved these changes
Sep 7, 2026
Hoist kernel, runtime, and MCCL registrations to file scope, remove the centralized MACA kernel registrar, and rely on the whole-archive executable link interface to retain registration-only objects.
chen2021673
force-pushed
the
feat/maca-backend
branch
from
September 18, 2026 08:00
20f56bd to
07c06bc
Compare
Collaborator
Author
|
精度测试(threshold-fp32 1e-5),将 MACA 结果与 CUDA(g3025)运行结果比较: 性能测试: |
This reverts commit 8b0f394.
chen2021673
force-pushed
the
feat/maca-backend
branch
from
September 18, 2026 09:17
07c06bc to
44ba401
Compare
kilinchange
reviewed
Sep 21, 2026
- regroup MACA headers with internal implementation headers last
Restore default async mempool high-watermark reset and query support, and track synchronous mcMalloc allocations used by the multithread workaround.
Merge the pinned InfiniTrain model test groups with MACA-specific overrides and use a Python standard-library adapter for the upstream JSON queries. Separate generic backend documentation from the MACA guide, add a Chinese README with language links, and build all unit tests before selecting the MACA CTest label.
Pin the submodule to release commit c90338ceb2dc528816bf78c422f1f5483f2be1ae and document the version in both READMEs. Scope common test source paths to InfiniTrain, follow its communication namespace change, and add the packed SwiGLU forward/backward kernels required by LLaMA and Mixtral. Validated with a full Release build, all 9 MACA test suites, 256 passed CPU tests with 18 skipped, 794 JSON query comparisons, and isolated model-runner smoke tests.
- Preserve all upstream test groups and ordering when applying overrides - Add Qwen3 dataset, checkpoint, and LoRA paths - Seed glog ELF header checks to bypass unsupported mxcc PIE probes - Move bilingual MACA guides into backends/maca - Ignore build directories matching build*
Match upstream a10bbc0 by accumulating the cross-entropy mean in FP64. Add INFINI_MACA_GEMM_FP64_ACCUM for developer runs with FP64 GEMM computation and FP32 output, keeping the default FP32 path. Select the mode at runtime and keep its implementation in the existing linear kernel. Update the manual build, automated test, and static-check directory instructions. Validation: staged clang-format and whitespace checks pass; existing Linear/Matmul forward and backward tests pass on C550 in both modes (12 tests each), and the cross-entropy precision regressions pass.
Collaborator
Author
|
Baseline: InfiniTrain-Test/infinitrain/logs/g3025/20261020/test_qwen3-multiprocess-cases_61e313d 精度误差前面已说明,在预期范围内。详情见 https://gxtctab8no8.feishu.cn/wiki/ISA8w1lXciTqVokxFNhc2ecznOg |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.








背景
InfiniTrain 已提供基于
PrivateUse1的后端扩展接口,但厂商相关的编译器、SDK、运行时、算子和通信实现不适合继续放在框架核心仓库中。本 PR 初始化 InfiniTrain-Backends,建立独立于 InfiniTrain 核心仓库的 accelerator backend 扩展机制,并以 MACA 作为首个 provider 完成验证。
整体目标是形成如下扩展关系:
作为后续国产加速器接入的统一组织方式。
整体架构
仓库按照 provider 进行隔离:
每个厂商后端独立维护在:
其中包含该后端自身的构建配置、Backend 注册以及具体实现。
InfiniTrain 通过 submodule 固定一个明确版本,Backend 仓库依赖 InfiniTrain 提供的
PrivateUse1接口,而不是反向修改框架核心代码。这样可以保证:
Backend 接入逻辑
构建时通过:
选择当前使用的 Backend。
一个 build tree 只对应一个 provider。
Backend 的接入主要分为两个阶段。
构建阶段
部分厂商 Backend 不只是链接额外的 runtime library,而是需要使用自己的编译器工具链。
CMake 的 compiler 必须在第一次
project()之前确定,因此顶层工程会先加载:完成 provider 相关的编译环境配置,再进入 InfiniTrain 的正常构建流程。
因此 Backend 不只是 InfiniTrain 构建完成后附加的一组库,而是整个构建过程的一部分。
运行时注册阶段
每个 provider 对外提供统一的 Backend 注册入口。
MACA 当前通过:
infini_train::maca::RegisterBackend();将自身能力注册到 InfiniTrain 的
PrivateUse1Backend。注册完成后,上层模型和训练逻辑仍然使用 InfiniTrain 原有抽象:
上层代码只需要感知
device = maca,而不需要直接依赖 MACA SDK 或 MACA 特有接口。MACA Backend
本 PR 将 MACA 支持迁移到新的 Backend 架构下,并适配 InfiniTrain 当前的
PrivateUse1接口。MACA Backend 负责承接厂商相关能力,并通过统一注册机制暴露给 InfiniTrain。
整体逻辑为:
核心目标是在 InfiniTrain 中不增加 MACA 专用执行分支,而是通过统一 Backend 接口完成硬件能力接入,从而保持框架逻辑与硬件实现解耦。
测试与开发方式
测试基于 InfiniTrain 的
PrivateUse1公共测试体系。Backend 仓库主要负责将指定 provider 注册到测试程序中,而 Tensor、Autograd 等通用行为继续由 InfiniTrain 的 shared tests 进行验证。
这样不同 Backend 可以复用同一套接口语义和测试标准,减少厂商后端重复维护测试逻辑。
开发场景下,默认使用仓库中固定版本的 InfiniTrain submodule;同时支持通过
INFINITRAIN_SOURCE_DIR指向本地 InfiniTrain 工作区,方便框架接口与 Backend 联调。当前约束
当前设计下:
PrivateUse1provider;本 PR 以 MACA 验证上述 Backend 架构,为后续其他 accelerator provider 接入提供统一的目录结构、构建流程和运行时注册模式。