Skip to content

fix(moore): select MCCL bfloat16 architecture - #69

Open
voltjia wants to merge 1 commit into
masterfrom
fix/moore-mccl-bf16-architecture
Open

fix(moore): select MCCL bfloat16 architecture#69
voltjia wants to merge 1 commit into
masterfrom
fix/moore-mccl-bf16-architecture

Conversation

@voltjia

@voltjia voltjia commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Moore MCCL exposes mcclBfloat16 only when MARCH_TYPE describes a capable target architecture. InfiniCCL previously passed neither MARCH_TYPE nor an offload architecture to mcc, so BF16 collectives returned infinicclNotSupported even on S5000 hardware where MCCL supports them.

This PR adds an explicit and auto-detected MUSA architecture configuration, passes the matching compiler flags, and keeps mixed-architecture builds fail-closed.

Changes

  • Architecture selection
    • Add MUSA_ARCHITECTURES, accepting forms such as 31, mp_31, and 3.1.
    • Prefer the explicit cache value, then TORCH_MUSA_ARCH_LIST, then native detection through musaGetDeviceProperties.
    • Fail with an actionable message when native detection is unavailable, such as during cross-compilation.
  • MCCL capability mapping
    • Pass one --offload-arch=mp_* flag per configured target.
    • Define MARCH_TYPE from the least capable target because mccl.h exposes one global data-type table; this prevents a mixed fat binary from advertising BF16 on an unsupported target.
    • Apply the same architecture contract to the shared library and every Moore example target.
  • Tests
    • Add CMake-script coverage for normalization, multiple compiler flags, fail-closed MARCH_TYPE, and invalid input.

Platform and Backend Affected

Platform

  • CPU
  • NVIDIA GPU
  • Iluvatar GPU
  • MetaX GPU
  • Moore Threads GPU
  • Cambricon MLU
  • HYGON DCU

Backend

  • OpenMPI
  • MPICH
  • NCCL
  • MCCL

Performance Impact

  • No performance impact
  • Performance improved
  • Performance regression possible

N/A. This changes build-time target selection and enables an existing MCCL data type.

Known Issues & Future Work

  • Native architecture detection requires a visible MUSA device. Cross-builds must set MUSA_ARCHITECTURES or TORCH_MUSA_ARCH_LIST explicitly.

Test Results

Test Involved Platform

  • CPU
  • NVIDIA GPU
  • Iluvatar GPU
  • MetaX GPU
  • Moore Threads GPU
  • Cambricon MLU
  • HYGON DCU

Test Involved Backend

  • OpenMPI
  • MPICH
  • NCCL
  • MCCL

Validated on Moore Threads S5000 with MUSA 4.3.6:

Explicit fat target 31;22:
  MUSA_ARCHITECTURES=31;22
  MARCH_TYPE=220
  compile flags: --offload-arch=mp_31 --offload-arch=mp_22 -DMARCH_TYPE=220
  InfiniCCL build: PASS
  CTest: 2/2 passed

Native detection:
  MUSA_ARCHITECTURES=31
  MARCH_TYPE=310
  compile flags: --offload-arch=mp_31 -DMARCH_TYPE=310
  InfiniCCL build: PASS
  BUILD_EXAMPLES=ON full build: PASS
  example compile flags: --offload-arch=mp_31 -DMARCH_TYPE=310
  CTest: 2/2 passed

Two-device BF16 AllReduce:
  input ranks: 1.0, 2.0
  output on both ranks: 3.0
  result: PASS

This commit was also combined with the open AllGather/Send/Recv stack at e8ccc0cb for InfiniLM validation. Qwen3-32B TP4 and Baichuan2-7B TP2 paged FlashAttention graph inference both passed after BF16 AllReduce became available.


Checklist

Title, Branch, and Commits

  • PR title follows Conventional Commits.
  • Branch name follows the repository convention.
  • Each commit message follows Conventional Commits.
  • This is a single squashable commit.
  • The branch is based cleanly on current master with no merge commit.
  • No fixup, squash, or work-in-progress commits remain.

Scope and Design

  • Changes are minimal and Moore-specific.
  • No dead code, debug output, or unowned TODO remains.
  • No unrelated formatting churn was introduced.
  • The new build option is documented in its CMake cache description and errors.

General Code Hygiene

  • Comments are limited to the non-obvious fail-closed fat-binary rule.
  • Every modified or added file ends with one newline.
  • git diff --check passes.
  • Comments and error messages are English, complete sentences.

C++ Specific

N/A. No repository C++ source file is modified; the native detector is generated by CMake during configuration.

Python Specific

N/A. No Python file is modified.

Testing

  • The Moore/MCCL library, CMake tests, and a two-device BF16 AllReduce were built and run successfully.

Build, CI, and Tooling

  • Existing Moore and MCCL detection remains unchanged; architecture detection runs only when WITH_MOORE=ON.
  • The branch is ready for repository CI.

Documentation

  • The user-visible cache option and cross-build requirement are documented inline.
  • No breaking change is introduced.

Security and Safety

  • No secret, internal URL, customer data, or personal hardware identifier is committed.
  • No third-party source code is added.
  • No pointer arithmetic, memory access, or bounds-sensitive runtime code is changed.

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