Skip to content

Commit df7e50c

Browse files
committed
update release v0.2.3
1 parent 3f58cc3 commit df7e50c

167 files changed

Lines changed: 21558 additions & 3497 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: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
repos:
1616
# Standard hooks
17-
- repo: https://github.com/pre-commit/pre-commit-hooks
17+
- repo: https://github.com/pre-commit/pre-commit-hooks.git
1818
rev: v5.0.0
1919
hooks:
2020
- id: check-added-large-files
@@ -28,14 +28,14 @@ repos:
2828
- id: trailing-whitespace
2929

3030
# Changes tabs to spaces
31-
- repo: https://github.com/Lucas-C/pre-commit-hooks
31+
- repo: https://github.com/Lucas-C/pre-commit-hooks.git
3232
rev: v1.5.5
3333
hooks:
3434
- id: remove-tabs
3535
- id: remove-crlf
3636

3737
# Formatters
38-
- repo: https://github.com/pre-commit/mirrors-clang-format
38+
- repo: https://github.com/pre-commit/mirrors-clang-format.git
3939
rev: v19.1.1
4040
hooks:
4141
- id: clang-format
@@ -49,15 +49,15 @@ repos:
4949
exclude: |
5050
(?x)^(3rdparty/.*)$
5151
52-
- repo: https://github.com/pre-commit/mirrors-mypy
52+
- repo: https://github.com/pre-commit/mirrors-mypy.git
5353
rev: 'v1.17.1' # Use the sha / tag you want to point at
5454
hooks:
5555
- id: mypy
5656
args: ["--config-file", "pyproject.toml"]
5757
files: ^mate/
5858
exclude: ^(wrappers/|3rdparty/|build/)
5959

60-
- repo: https://github.com/astral-sh/ruff-pre-commit
60+
- repo: https://github.com/astral-sh/ruff-pre-commit.git
6161
# Ruff version.
6262
rev: v0.12.8
6363
hooks:

AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ When working with MATE's dependencies and tools, refer to these official documen
9090
- Always read relevant files before modifying code
9191
- For non-trivial tasks, create a plan first
9292
- Validate changes by running tests
93+
- After completing a task, always run `pre-commit run -a` to format/check code and fix any reported issues before handing off
9394
- Prefer minimal, localized changes
9495
- When running as `root` in the container, restore edited tracked files to the
9596
workspace owner/group and keep them user/group writable before handing off.

README.md

Lines changed: 68 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ MATE (**M**USA **A**I **T**ensor **E**ngine) is a centralized library for Genera
55
## Highlights
66

77
- High-performance attention and GEMM operators for MUSA
8-
- Compatibility wrappers for `flash_attn_3`, `sageattention`, `flash_mla`, and `deep_gemm`
8+
- Compatibility wrappers for `flash_attn_3`, `sageattention`, `flash_mla`,
9+
`flash_kda`, and `deep_gemm`
910
- CLI tools for environment checks, configuration inspection, and replay
1011

1112
## Requirements
@@ -16,6 +17,16 @@ MATE (**M**USA **A**I **T**ensor **E**ngine) is a centralized library for Genera
1617
| TorchMUSA | `2.7` or later |
1718
| Architecture | `Pinghu (MP31)` |
1819

20+
## Recommended Workflow
21+
22+
For Moore Threads platforms, the normal integration flow is wrapper-first:
23+
24+
1. Install MATE on top of an existing MUSA-enabled `torch` / `torch_musa` stack
25+
2. Install the wrapper package that matches the Python package surface your framework already expects
26+
3. Keep the upstream import path and high-level API shape as stable as possible
27+
4. Use `mate check`, `mate show-config`, `mate env`, logging, and replay if something fails
28+
5. Use native MATE APIs only when no wrapper matches your workload or the wrapper does not cover the feature you need
29+
1930
## Quick Start
2031

2132
Use these commands after the MUSA-enabled `torch` / `torch_musa` stack is
@@ -56,6 +67,48 @@ Customize AOT coverage when needed:
5667
python -m mate.aot --attention-aot-level 0 --add-gemm true --add-moe false
5768
```
5869

70+
### Install a Wrapper
71+
72+
After MATE is installed, install the wrapper that matches your framework's
73+
expected Python package surface.
74+
75+
| Wrapper directory | Package | Import path | Typical use |
76+
| --- | --- | --- | --- |
77+
| `wrappers/flash-attention` | `flash_attn_3` | `flash_attn_interface` | FlashAttention-3 style integration |
78+
| `wrappers/FlashMLA` | `flash_mla` | `flash_mla` | FlashMLA style integration |
79+
| `wrappers/FlashKDA` | `flash_kda` | `flash_kda` | FlashKDA style integration |
80+
| `wrappers/DeepGEMM` | `deep-gemm` | `deep_gemm` | DeepGEMM style integration |
81+
| `wrappers/SageAttention` | `sageattention` | `sageattention` | SageAttention style integration |
82+
83+
Generic editable install pattern:
84+
85+
```bash
86+
cd wrappers/flash-attention
87+
pip install --no-build-isolation -e .
88+
```
89+
90+
Generic wheel install pattern:
91+
92+
```bash
93+
cd wrappers/flash-attention
94+
python -m build --wheel
95+
pip install dist/flash_attn_3-*.whl
96+
```
97+
98+
Repeat the same workflow for `wrappers/FlashMLA`, `wrappers/FlashKDA`,
99+
`wrappers/DeepGEMM`, or `wrappers/SageAttention` when those package surfaces
100+
match your framework.
101+
102+
### Verify and Diagnose
103+
104+
Start with these commands after installation:
105+
106+
```bash
107+
mate check
108+
mate show-config
109+
mate env
110+
```
111+
59112
### Notes
60113

61114
- If the checkout was cloned without `--recursive`, run `git submodule update --init --recursive`.
@@ -75,6 +128,7 @@ MATE provides a command-line interface for configuration, debugging, diagnostics
75128
| `mate check` | Validate the runtime environment |
76129
| `mate show-config` | Display installation and runtime configuration |
77130
| `mate env` | Show relevant environment variables |
131+
| `mate guard-run -- COMMAND` | Run a workload with the guarded MUSA allocator installed at startup |
78132
| `mate replay --dir PATH` | Replay API calls from Level 10 dumps |
79133
| `mate list-dumps PATH` | List recorded dump directories |
80134

@@ -84,6 +138,7 @@ Example:
84138
mate check
85139
mate show-config
86140
mate env
141+
mate guard-run -- python your_script.py
87142
mate replay --dir mate_dumps/
88143
mate list-dumps mate_dumps/
89144
```
@@ -92,15 +147,22 @@ See [docs/mate_cli.md](docs/mate_cli.md) for full CLI documentation.
92147
See [docs/environment_variables.md](docs/environment_variables.md) for the
93148
complete environment variable reference.
94149

150+
## Memory Debug / Guard Allocator
151+
152+
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).
153+
95154
## Wrappers
96155

97156
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.
98157

158+
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.
159+
99160
| Wrapper | Package | Import Path | Purpose | Documentation |
100161
| --- | --- | --- | --- | --- |
101-
| `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/flash_attention.md) |
162+
| `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) |
102163
| `wrappers/SageAttention` | `sageattention` | `sageattention` | SageAttention-compatible dense quantized attention wrapper on top of MATE on MUSA | [wrapper README](wrappers/SageAttention/README.md) |
103164
| `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) |
165+
| `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) |
104166
| `wrappers/DeepGEMM` | `deep-gemm` | `deep_gemm` | DeepGEMM-compatible APIs on top of MATE GEMM operators on MUSA | [wrapper README](wrappers/DeepGEMM/README.md) |
105167

106168
## Repository Layout
@@ -118,19 +180,21 @@ MATE uses the packages under `wrappers/` as a compatibility layer for CUDA-orien
118180
After installing `mate`, build the Sphinx docs with:
119181

120182
```bash
121-
pip install sphinx furo
183+
pip install sphinx furo myst-parser
122184
cd docs
123185
make html
124186
```
125187

126188
## Quick Links
127189

128190
- CLI documentation: [docs/mate_cli.md](docs/mate_cli.md)
191+
- Guard allocator debugging: [docs/guard_allocator.md](docs/guard_allocator.md)
129192
- Environment variables: [docs/environment_variables.md](docs/environment_variables.md)
130-
- FlashAttention-3 compatibility summary: [docs/flash_attention.md](docs/flash_attention.md)
193+
- FlashAttention-3 compatibility summary: [docs/source/wrappers/flash_attention_forward_compatibility.md](docs/source/wrappers/flash_attention_forward_compatibility.md)
131194
- FlashAttention-3 wrapper: [wrappers/flash-attention/README.md](wrappers/flash-attention/README.md)
132195
- SageAttention wrapper: [wrappers/SageAttention/README.md](wrappers/SageAttention/README.md)
133196
- FlashMLA wrapper: [wrappers/FlashMLA/README.md](wrappers/FlashMLA/README.md)
197+
- FlashKDA wrapper: [wrappers/FlashKDA/README.md](wrappers/FlashKDA/README.md)
134198
- DeepGEMM wrapper: [wrappers/DeepGEMM/README.md](wrappers/DeepGEMM/README.md)
135199

136200
## Acknowledgement

0 commit comments

Comments
 (0)