MXFlashAttn
MXFlashAttn 1.5.0 provides a FlashAttention-compatible Python API and an observable paged-decode integration for MetaX C500 / MXMACA.
The package combines:
- validated dense, varlen, and KV-cache forward entry points;
- explicit validation, dispatch information, and opt-in reference fallback;
- an M1 Split-KV decode path for C500 paged KV cache;
- an exact-profile MMA Split-KV path for calibrated FP16 decode shapes;
- vLLM EngineCore registration and per-dispatch evidence.
Native C500 extensions are compiled inside the target MetaX/MACA environment. The PyPI artifact supplies the Python API, integration layer, profile handling, and registration entry point.
Install
python -m pip install mxflashattn==1.5.0
Base requirements:
- Python 3.10+
- PyTorch 2.4+
- PyYAML 6.x
For the vLLM 0.17 dependency contract:
python -m pip install "mxflashattn[vllm]==1.5.0"
MetaX deployments normally provide their own compatible PyTorch, vLLM, and MXMACA wheels. vLLM 0.17.0 and 0.28.0 were validated on separate C500 software stacks; they are not interchangeable environments.
Python API
import os
import torch
from mxflashattn import flash_attn_func, get_last_dispatch_info
# Explicitly enable the correctness/reference path when no native provider exists.
os.environ["MXFLASHATTN_ALLOW_FALLBACK"] = "1"
q = torch.randn(1, 32, 8, 64, dtype=torch.float16)
k = torch.randn(1, 128, 2, 64, dtype=q.dtype)
v = torch.randn_like(k)
out = flash_attn_func(q, k, v, causal=True)
print(out.shape)
print(get_last_dispatch_info())
The reference path is intended for API checks and correctness comparison. It
is not a C500 performance backend. Without
MXFLASHATTN_ALLOW_FALLBACK=1, a missing native provider raises an explicit
error instead of silently selecting a slow path.
Public entry points:
from mxflashattn import (
flash_attn_func,
flash_attn_varlen_func,
flash_attn_with_kvcache,
get_last_dispatch_info,
)
C500 Native Setup
Build native extensions in an environment matching the target MetaX PyTorch and MACA installation:
git clone https://github.com/leo1852098393-blip/MXFlashAttn.git
cd MXFlashAttn
python -m pip install --no-build-isolation -e .
export MACA_PATH=/opt/maca
bash csrc_native/build_m1.sh
Then enable the guarded M1 route and collect dispatch evidence:
export MXFA_M1_DECODE=1
export MXFLASHATTN_DISPATCH_SAMPLE=1
python integrations/vllm/smoke_generate.py \
--model /path/to/Qwen3-4B \
--suite --prompt-count 4 --max-tokens 16 \
--candidate --output artifacts/m1-smoke.json
A performance result is attributed to MXFlashAttn only when the associated
dispatch.jsonl contains a successful m1_split_decode or
mma_split_decode event.
Verified Scope
| Area | v1.5.0 status |
|---|---|
| M1 decode | FP16 / BF16, head dimensions 64 / 128, GQA ratios 2 / 4 / 8 |
| vLLM 0.17.0 | Real Qwen3-4B/8B generation, M1 dispatch, fallback, and long-decode measurements |
| vLLM 0.28.0 | EngineCore plugin registration, real M1 dispatch, and a Qwen3-8B shape matrix |
| MMA decode | FP16 single-token decode, exact calibrated profiles only |
| Prefill | MetaX vendor production path; chunked prefill remains a correctness reference |
| Backward | Explicit MetaX provider integration; no in-house backward kernel |
In four vLLM 0.17.0 long-decode workloads, M1 delivered 2.67-3.54x the
throughput of the project's historical v7 path and reached 79.2%-86.5% of
MetaX vendor throughput. In one exact Qwen3-4B operator shape, MMA median
latency was 43.520 us versus 46.592 us for vendor over 100 rounds.
In the reported vLLM 0.28.0 Qwen3-8B matrix, long-KV samples at batch 16 or larger remained 28%-46% below MetaX vendor. No general M1-over-vendor crossover is claimed.
These results are bound to their recorded device, software stack, model, shape, and baseline. The MMA comparison is operator-level, not an end-to-end request-speedup claim.
Runtime Boundaries
- Prefill and unprofiled decode shapes retain the MetaX vendor path.
- M1 requires its documented dtype, layout, head-dimension, and GQA contract.
- MMA requires an exact profile match, including KV heads, page size, binary variant, and shared-object identity.
- Short or low-concurrency requests may not benefit from M1.
- FP8 KV cache, multi-card execution, SGLang, GQ=7, and general TTFT gains are not v1.5.0 support claims.
- Unsupported API options fail explicitly or follow a documented fallback.
Development and Audit
The project's own kernel implementations under csrc_native/ were written by
AI coding agents. The project owner set the project goals, verification rules,
and release boundary, and made the final accept-or-reject decisions for code
changes and public claims.
Favorable measurements do not automatically become performance claims. The
short-KV +15.2% difference was the same order as repeated-run variance; the
long-KV +22.7% result was a single observation and does not establish a
general crossover. Neither is used for a general performance claim.
Documentation
License
Apache License 2.0. MXMACA runtime, MetaX vendor packages, vLLM, model weights, and datasets remain subject to their respective licenses.
Metadata
Release files for mxflashattn 1.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mxflashattn-1.5.0.tar.gz | 1.0 MB | Without provenance | Details for mxflashattn-1.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mxflashattn-1.5.0-py3-none-any.whl | Python 3 | none | any | Details for mxflashattn-1.5.0-py3-none-any.whl |
Total release size: 1.1 MB
Release files / mxflashattn-1.5.0.tar.gz
| Download URL | mxflashattn-1.5.0.tar.gz |
|---|---|
| Size | 1.0 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fa47f524030c19ec2b79a9bade5545327f20286ac7f65008a1a9976b972f1987
|
|
BLAKE2b-256 checksum How to use checksums |
ba9b67e71077236d71577cca760b367a6496f2ef437ac12de6a8377a520ed450
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.5
|
Release files / mxflashattn-1.5.0-py3-none-any.whl
| Download URL | mxflashattn-1.5.0-py3-none-any.whl |
|---|---|
| Size | 77.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
26a9fbddf95f2aba3200a722a626a3e57ca5f962a98e56f7f22021770f4eff7d
|
|
BLAKE2b-256 checksum How to use checksums |
1bd0d562174916ce914665d83e4ff28d33f898598b8bf448671976e8c0715d6e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.5
|
Security for mxflashattn 1.5.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.