Skip to content

Commit fa657ba

Browse files
committed
update release v0.2.4
1 parent 8440bed commit fa657ba

524 files changed

Lines changed: 1427580 additions & 1245224 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.pre-commit-config.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,12 @@ repos:
6666
# Run the formatter.
6767
- id: ruff-format
6868
types_or: [ python, pyi ]
69+
70+
- repo: local
71+
hooks:
72+
- id: check-api-docs
73+
name: check-api-docs
74+
entry: python scripts/check_api_docs.py
75+
language: system
76+
pass_filenames: false
77+
files: ^(docs/api_manifest\.yaml|docs/source/api_reference\.rst|docs/source/api/.*\.rst|docs/gdn\.md|mate/__init__\.py|mate/(deep_gemm|flashmla|gdn_decode|gdn_prefill|gemm|hash_topk|hyperconnection|kda|mha_interface|moe_fused_gate|sage_attention_interface)\.py|scripts/check_api_docs\.py|tests/test_check_api_docs\.py)$

README.md

Lines changed: 50 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -7,72 +7,90 @@ MATE (**M**USA **A**I **T**ensor **E**ngine) is a centralized library for Genera
77
## Highlights
88

99
- High-performance attention and GEMM operators for MUSA
10+
- Mixed-dtype W4A8 MoE GEMM APIs for ragged and masked MoE paths in `0.2.4`
1011
- Compatibility wrappers for `flash_attn_3`, `sageattention`, `flash_mla`,
11-
`flash_kda`, and `deep_gemm`
12+
`flash_kda`, and `deep-gemm`
1213
- CLI tools for environment checks, configuration inspection, and replay
1314

1415
## Requirements
1516

1617
| Component | Requirement |
1718
| --- | --- |
19+
| Python | `3.10` or later |
1820
| MUSA Toolkit | `4.3.6` or later |
1921
| TorchMUSA | `2.7` or later |
2022
| Architecture | `Pinghu (MP31)` |
2123

24+
The current external delivery source mainly covers `x86_64` and Python `3.10`
25+
/ `3.12` wheels.
26+
2227
## Recommended Workflow
2328

2429
For Moore Threads platforms, the normal integration flow is wrapper-first:
2530

26-
1. Install MATE on top of an existing MUSA-enabled `torch` / `torch_musa` stack
27-
2. Install the wrapper package that matches the Python package surface your framework already expects
28-
3. Keep the upstream import path and high-level API shape as stable as possible
29-
4. Use `mate check`, `mate show-config`, `mate env`, logging, and replay if something fails
30-
5. Use native MATE APIs only when no wrapper matches your workload or the wrapper does not cover the feature you need
31+
1. Start with an existing MUSA-enabled `torch` / `torch_musa` stack
32+
2. If a supported wrapper matches your framework surface, install that wrapper from the MUSA wheel source
33+
3. The wrapper install pulls in the matching `mate` package automatically
34+
4. Install `mate` directly only when no wrapper matches your workload or you need direct MATE APIs
35+
5. Keep the upstream import path and high-level API shape as stable as possible
36+
6. Use `mate check`, `mate show-config`, `mate env`, logging, and replay if something fails
3137

3238
## Quick Start
3339

34-
Use these commands after the MUSA-enabled `torch` / `torch_musa` stack is
35-
installed. Keep dependency resolution disabled for local builds so pip does not
36-
replace that stack with upstream PyPI packages.
40+
### Install from the MUSA Wheel Source
41+
42+
For delivered builds, use the external delivery source after the MUSA-enabled
43+
`torch` / `torch_musa` stack is already installed.
3744

38-
- Use `--no-build-isolation` for source installs.
39-
- Use `--no-isolation` for wheel builds.
40-
- Use `--no-deps` when installing local builds.
45+
```bash
46+
python -m pip install flash_attn_3 \
47+
--index-url https://dl.mthreads.com/repo/api/pypi/pypi/simple
48+
```
4149

42-
### Development Install
50+
This installs the matching `mate` dependency automatically. Install other
51+
wrapper packages such as `flash_mla`, `flash_kda`, `deep-gemm`, or
52+
`sageattention` the same way.
53+
54+
MUSA compatibility wrapper releases use the PEP 440 local version suffix
55+
`+musa`, for example `0.2.4+musa`. Check the installed distribution with
56+
`python -m pip show flash_attn_3`; a version ending in `+musa` identifies the
57+
MATE-backed MUSA wrapper rather than the native implementation. The matching
58+
`mate` dependency keeps its normal version without this wrapper-only suffix.
59+
60+
Install `mate` directly only when you need direct MATE APIs without a wrapper:
4361

4462
```bash
45-
git clone https://github.com/MooreThreads/mate.git --recursive
46-
cd mate
47-
pip install --no-build-isolation --no-deps -e . -v
63+
python -m pip install mate \
64+
--index-url https://dl.mthreads.com/repo/api/pypi/pypi/simple
4865
```
4966

50-
### Build a Wheel
67+
Use exactly one package index per install step. Do not mix the MUSA wheel
68+
source with a public PyPI mirror in the same `pip install` invocation.
69+
70+
### Build from Source
5171

5272
```bash
5373
git clone https://github.com/MooreThreads/mate.git --recursive
5474
cd mate
55-
python -m build --wheel --no-isolation
56-
python -m pip install --no-deps dist/mate-*.whl
75+
python -m pip install --no-build-isolation --no-deps -e . -v
5776
```
5877

59-
### Optional: Pre-Build AOT Kernels
78+
For a local wheel instead of an editable install:
6079

6180
```bash
62-
MATE_MUSA_ARCH_LIST=3.1 python -m mate.aot
6381
python -m build --wheel --no-isolation
82+
python -m pip install --no-deps dist/mate-*.whl
6483
```
6584

66-
Customize AOT coverage when needed:
85+
See [`docs/source/install.rst`](docs/source/install.rst) for the full
86+
wheel-source workflow, wrapper package commands, `PIP_INDEX_URL`, `pip config`,
87+
`pip index versions`, direct wheel URLs, and local AOT build options.
6788

68-
```bash
69-
python -m mate.aot --attention-aot-level 0 --add-gemm true --add-moe false
70-
```
89+
### Choose a Wrapper
7190

72-
### Install a Wrapper
73-
74-
After MATE is installed, install the wrapper that matches your framework's
75-
expected Python package surface.
91+
Install the wrapper that matches your framework's expected Python package
92+
surface. Each delivered wrapper install pulls in the matching `mate`
93+
dependency automatically.
7694

7795
| Wrapper directory | Package | Import path | Typical use |
7896
| --- | --- | --- | --- |
@@ -82,24 +100,8 @@ expected Python package surface.
82100
| `wrappers/DeepGEMM` | `deep-gemm` | `deep_gemm` | DeepGEMM style integration |
83101
| `wrappers/SageAttention` | `sageattention` | `sageattention` | SageAttention style integration |
84102

85-
Generic editable install pattern:
86-
87-
```bash
88-
cd wrappers/flash-attention
89-
pip install --no-build-isolation -e .
90-
```
91-
92-
Generic wheel install pattern:
93-
94-
```bash
95-
cd wrappers/flash-attention
96-
python -m build --wheel
97-
pip install dist/flash_attn_3-*.whl
98-
```
99-
100-
Repeat the same workflow for `wrappers/FlashMLA`, `wrappers/FlashKDA`,
101-
`wrappers/DeepGEMM`, or `wrappers/SageAttention` when those package surfaces
102-
match your framework.
103+
For wrapper install commands, use the same external index or follow the local
104+
build workflow in [`docs/source/install.rst`](docs/source/install.rst).
103105

104106
### Verify and Diagnose
105107

@@ -153,20 +155,6 @@ complete environment variable reference.
153155

154156
MATE includes a guarded MUSA allocator that can replace the default `torch_musa` allocator during debugging to help localize out-of-bounds reads and writes across MUSA workloads. Start with `mate guard-run --mode tail -- python your_script.py`, or enable it in tests with `pytest --guard-alloc`. The detailed workflow, pytest defaults, and limitations are documented in [docs/guard_allocator.md](docs/guard_allocator.md).
155157

156-
## Wrappers
157-
158-
MATE uses the packages under `wrappers/` as a compatibility layer for CUDA-oriented software stacks on MUSA. These wrappers preserve familiar package names and high-level APIs while routing execution to MATE operators and kernels on MUSA, which helps existing integrations migrate with smaller code changes.
159-
160-
For the guided wrapper-first documentation path, start with [docs/source/overview.rst](docs/source/overview.rst) and [docs/source/wrapper_tutorials.rst](docs/source/wrapper_tutorials.rst) for the wrapper quickstart flow.
161-
162-
| Wrapper | Package | Import Path | Purpose | Documentation |
163-
| --- | --- | --- | --- | --- |
164-
| `wrappers/flash-attention` | `flash_attn_3` | `flash_attn_interface` | FlashAttention-3-compatible APIs on top of MATE attention operators on MUSA | [wrapper README](wrappers/flash-attention/README.md), [compatibility summary](docs/source/wrappers/flash_attention_forward_compatibility.md) |
165-
| `wrappers/SageAttention` | `sageattention` | `sageattention` | SageAttention-compatible dense quantized attention wrapper on top of MATE on MUSA | [wrapper README](wrappers/SageAttention/README.md) |
166-
| `wrappers/FlashMLA` | `flash_mla` | `flash_mla` | FlashMLA-compatible MLA dense/sparse decode and sparse prefill APIs on top of MATE MLA operators on MUSA | [wrapper README](wrappers/FlashMLA/README.md) |
167-
| `wrappers/FlashKDA` | `flash_kda` | `flash_kda` | FlashKDA-compatible KDA forward APIs on top of MATE KDA operators on MUSA | [wrapper README](wrappers/FlashKDA/README.md) |
168-
| `wrappers/DeepGEMM` | `deep-gemm` | `deep_gemm` | DeepGEMM-compatible APIs on top of MATE GEMM operators on MUSA | [wrapper README](wrappers/DeepGEMM/README.md) |
169-
170158
## Repository Layout
171159

172160
| Path | Purpose |
@@ -180,15 +168,11 @@ For the guided wrapper-first documentation path, start with [docs/source/overvie
180168
## Quick Links
181169

182170
- Official documentation: [https://mate-docs.mthreads.com/latest/](https://mate-docs.mthreads.com/latest/)
171+
- Wrapper quickstarts: [docs/source/wrapper_tutorials.rst](docs/source/wrapper_tutorials.rst)
183172
- CLI documentation: [docs/mate_cli.md](docs/mate_cli.md)
184173
- Guard allocator debugging: [docs/guard_allocator.md](docs/guard_allocator.md)
185174
- Environment variables: [docs/environment_variables.md](docs/environment_variables.md)
186175
- FlashAttention-3 compatibility summary: [docs/source/wrappers/flash_attention_forward_compatibility.md](docs/source/wrappers/flash_attention_forward_compatibility.md)
187-
- FlashAttention-3 wrapper: [wrappers/flash-attention/README.md](wrappers/flash-attention/README.md)
188-
- SageAttention wrapper: [wrappers/SageAttention/README.md](wrappers/SageAttention/README.md)
189-
- FlashMLA wrapper: [wrappers/FlashMLA/README.md](wrappers/FlashMLA/README.md)
190-
- FlashKDA wrapper: [wrappers/FlashKDA/README.md](wrappers/FlashKDA/README.md)
191-
- DeepGEMM wrapper: [wrappers/DeepGEMM/README.md](wrappers/DeepGEMM/README.md)
192176

193177
## Acknowledgement
194178

benchmarks/bench_flash_attn.py

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
from mate import flash_attn_varlen_func, flash_attn_with_kvcache
88
from mate.mha_interface import get_scheduler_metadata
99

10-
# MATE_BENCH_FMHA_DTYPE = torch.bfloat16
11-
MATE_BENCH_FMHA_DTYPE = torch.float8_e4m3fn
10+
MATE_BENCH_FMHA_DTYPE = torch.bfloat16
11+
# MATE_BENCH_FMHA_DTYPE = torch.float8_e4m3fn
1212
MATE_BENCH_FMHA_DEVICE = "musa"
1313

1414
MATE_BENCH_FMHA_ENABLE_TRACE = False
@@ -18,15 +18,15 @@
1818
def gen_bench_config() -> List[dict]:
1919
cases = [
2020
{
21-
"name": "prefill",
21+
"name": "Prefill",
2222
"batch_size": 56,
23-
"seqlen_q": [4096] * 56,
24-
"seqlen_kv": [4096] * 56,
23+
"seqlen_q": [1024 * 4] * 56,
24+
"seqlen_kv": [1024 * 4] * 56,
2525
"head_q": 64,
2626
"head_kv": 4,
2727
"headdim_qk": 128,
2828
"headdim_vo": 128,
29-
"is_packgqa": True,
29+
"is_packgqa": False,
3030
"is_causal": False,
3131
"window_size": (None, None),
3232
"page_size": None,
@@ -38,29 +38,6 @@ def gen_bench_config() -> List[dict]:
3838
"seqused_q": None,
3939
"seqused_kv": None,
4040
},
41-
{
42-
"name": "decode",
43-
"batch_size": 56,
44-
"seqlen_q": [1] * 56,
45-
"seqlen_kv": [4096] * 56,
46-
"head_q": 64,
47-
"head_kv": 4,
48-
"headdim_qk": 128,
49-
"headdim_vo": 128,
50-
"is_packgqa": True,
51-
"is_causal": True,
52-
"window_size": (None, None),
53-
"page_size": 128
54-
if MATE_BENCH_FMHA_DTYPE in [torch.float8_e4m3fn, torch.float8_e5m2]
55-
else 64,
56-
"num_splits": 0,
57-
"backend": "mutlass",
58-
"dtype": MATE_BENCH_FMHA_DTYPE,
59-
"device": MATE_BENCH_FMHA_DEVICE,
60-
"force_flash_attn_with_kvcache": False,
61-
"seqused_q": None,
62-
"seqused_kv": None,
63-
},
6441
]
6542

6643
return cases
@@ -150,6 +127,7 @@ def run_bench(
150127
pack_gqa=cfg.is_packgqa,
151128
mp_margin=0,
152129
)
130+
print(metadata.view(4, -1))
153131

154132
def fn():
155133
if cfg.is_paged_kv or force_flash_attn_with_kvcache:

0 commit comments

Comments
 (0)