This page describes how to install MATE or a supported wrapper package from
the MUSA Python wheel source, or how to build MATE from source on top of an
existing MUSA-enabled torch / torch_musa stack.
- Check requirements.
- Choose a package source.
- Install a delivered package or build from source.
- Validate installation.
- Build a wrapper from source if needed.
- Optionally pre-build AOT kernels.
MATE currently requires the following runtime baseline:
| Component | Requirement |
|---|---|
| Python | 3.10 or later |
| MUSA Toolkit | 4.3.6 or later |
| TorchMUSA | 2.7 or later |
| Architecture | Pinghu (MP31) |
The table above shows the repository-wide baseline. Some feature paths need
newer toolchains. The current external delivery source mainly covers
x86_64 and Python 3.10 / 3.12 wheels. When a wrapper or API page
lists a stricter requirement, follow that page. For example, FlashKDA
currently builds on MUSA SDK / MTCC 5.1.0+, and FlashAttention Local +
attention_chunk requires MUSA SDK 5.1.0+.
Before continuing, make sure the MUSA-enabled torch / torch_musa stack
is already installed and working in your environment.
For delivered packages, use the external MUSA wheel source.
- Index:
https://dl.mthreads.com/repo/api/pypi/pypi/simple - Wheel root:
https://dl.mthreads.com/repo/repository/public-release-pypi/
Choose one configuration method:
- Temporary shell or CI
export PIP_INDEX_URL=https://dl.mthreads.com/repo/api/pypi/pypi/simple- Persistent pip config
python -m pip config set global.index-url \ https://dl.mthreads.com/repo/api/pypi/pypi/simple- One-off install
python -m pip install <package> \ --index-url https://dl.mthreads.com/repo/api/pypi/pypi/simple
Important
Use one package index per install step. Do not mix the MUSA wheel source with a public PyPI mirror in the same
pip installcommand.
Optional:
- Direct wheel URL
Use this when you need one exact wheel. The URL format is
<package>/<version>/<wheel-file>underpublic-release-pypi.python -m pip install \ https://dl.mthreads.com/repo/repository/public-release-pypi/<package>/<version>/<wheel-file>
Keep one
index-urlconfigured for dependency resolution, or add--no-depsif dependencies are already installed.- Check available versions
python -m pip index versions mate \ --index-url https://dl.mthreads.com/repo/api/pypi/pypi/simple
If
pip index versionsis unavailable, upgradepipfirst.
Choose one installation path:
- Delivered wrapper install: recommended when your framework already expects
flash_attn_3,flash_mla,flash_kda,deep-gemm, orsageattention. Each delivered wrapper installs the matchingmatedependency automatically. - Direct MATE install: use this when you need direct
mateAPIs without a wrapper. - Build from source: use this when you are developing MATE locally or need a local build artifact.
Supported delivered wrapper packages are flash_attn_3, flash_mla,
flash_kda, deep-gemm, and sageattention.
Before reinstalling a delivered package set, uninstall the packages you plan to replace:
python -m pip uninstall -y \
mate flash_mla flash_kda deep-gemm sageattention flash_attn_3Install the wrapper package that matches your framework surface. pip
installs the matching mate dependency automatically.
python -m pip install flash_attn_3 \
--index-url https://dl.mthreads.com/repo/api/pypi/pypi/simpleReplace flash_attn_3 with flash_mla, flash_kda, deep-gemm, or
sageattention when those package surfaces match your framework.
Delivered MUSA wrapper versions use the PEP 440 local version suffix
+musa, for example 0.2.4+musa. Check the installed distribution to
distinguish the MATE-backed MUSA wrapper from the native implementation:
python -m pip show flash_attn_3The Version field should end in +musa. Replace flash_attn_3 with
the wrapper package you installed when checking another wrapper. The matching
mate dependency keeps its normal version; +musa is a wrapper-only
identifier and does not encode the MUSA Toolkit version.
Install mate directly when no wrapper matches your workload or when you
want direct MATE Python APIs without a wrapper package.
python -m pip install mate \
--index-url https://dl.mthreads.com/repo/api/pypi/pypi/simpleClone the repository with submodules:
git clone https://github.com/MooreThreads/mate.git --recursive
cd mateNote
If the repository was cloned without --recursive, run
git submodule update --init --recursive in the repository root before
building.
For local builds, keep dependency resolution disabled so pip does not
replace the MUSA PyTorch stack with upstream PyPI packages.
- Use
--no-build-isolationfor source installs. - Use
--no-isolationfor local wheel builds. - Use
--no-depswhen installing local builds.
Choose one local install mode:
- Use an editable install when you are iterating on the local checkout.
- Build and install a local wheel when you need a built artifact.
Use an editable install when you are iterating on the local checkout:
python -m pip install --no-build-isolation --no-deps -e . -vUse a local wheel when you want a built artifact instead of an editable install:
python -m build --wheel --no-isolation
python -m pip install --no-deps dist/mate-*.whlAfter installing MATE directly or through a wrapper package, validate the MATE runtime first.
python - <<'PY'
import mate
print("mate import ok")
PYpython -m mate --help
mate check
mate show-config
mate envIf the mate executable entrypoint is not available in your environment,
use python -m mate ... for supported subcommands.
If you installed a wrapper package in Step 3, follow that wrapper page for the wrapper import path and package-specific validation snippet.
Skip this step if you installed a delivered wrapper package in Step 3.
Use this path only when you are developing a wrapper locally from the
repository checkout. Install local mate from the Step 3 source-build path
first. The commands below are for local editable installs or local wheel
installs, not the delivered wheel source.
- Install local
matefirst. - Use
--no-depsfor local wrapper installs.
| Wrapper directory | Package name | Import path | Typical use |
|---|---|---|---|
wrappers/flash-attention |
flash_attn_3 |
flash_attn_interface |
FlashAttention-3 style integration |
wrappers/FlashMLA |
flash_mla |
flash_mla |
FlashMLA style integration |
wrappers/FlashKDA |
flash_kda |
flash_kda |
FlashKDA style integration |
wrappers/DeepGEMM |
deep-gemm |
deep_gemm |
DeepGEMM style integration |
wrappers/SageAttention |
sageattention |
sageattention |
SageAttention style integration |
Editable install pattern:
cd /path/to/mate
python -m pip install --no-build-isolation --no-deps -e . -v
cd wrappers/flash-attention
python -m pip install --no-build-isolation --no-deps -e .Wheel install pattern:
cd /path/to/mate
python -m pip install --no-build-isolation --no-deps -e . -v
cd wrappers/flash-attention
python -m build --wheel
python -m pip install --no-deps dist/flash_attn_3-*.whlRepeat the same workflow for wrappers/FlashMLA, wrappers/FlashKDA,
wrappers/DeepGEMM, or wrappers/SageAttention when those package
surfaces match your framework.
If you want to pre-build AOT kernels before producing a wheel, run:
MATE_MUSA_ARCH_LIST=3.1 python -m mate.aot
python -m build --wheel --no-isolationCustomize AOT coverage when needed:
python -m mate.aot --attention-aot-level 0 --add-gemm true --add-moe false- Continue with :doc:`wrapper_tutorials` for wrapper-specific quickstarts.
- Continue with :doc:`diagnostics` if validation or runtime behavior fails.
- Continue with :doc:`api_reference` when no wrapper matches your workload.