Skip to content

attn: MLA attention resource (split from #257) - #321

Open
vasilevklart wants to merge 3 commits into
mstar-project:mainfrom
vasilevklart:users/kirill/mla-resource
Open

vasilevklart wants to merge 3 commits into
mstar-project:mainfrom
vasilevklart:users/kirill/mla-resource

Conversation

@vasilevklart

Copy link
Copy Markdown
Collaborator

The MLA attention resource from #257, split out so GLM-5.2 (#272) and GLM-5.3 (#263) can build on it without waiting for Kimi K3. Adds KVLayout.MLA (one [ckv | kpe] latent per token), AttnBackend.FLASHINFER_MLA (FlashInfer's Hopper MLA kernel, torch fallback for other latent shapes), opt-in FlashMLA decode (MSTAR_MLA_DECODE_BACKEND), and AttentionStep.context_only.

The speculative-decoding parts (KVSpec.plan_after, KVManager.correct_len, SPEC_ACCEPTANCE) stay in #257. flashinfer_mla.py and flashmla.py match #257 except for one moved import, so #257 can rebase onto this and drop them.

Two fixes on top: the CPU offload pool hard-coded the NHD page shape, so offloading an MLA cache failed; and the torch fallback imported flashinfer before deciding to fall back.

Tests: test/modular/test_mla_kv_layout.py, test_context_only_attention.py, and test_kv_offload.py (round trip now on both layouts). CPU suite matches main. GPU tests (test_gpu_mla_attention.py, test_gpu_flashmla.py) are carried over from #257.

merceod and others added 3 commits September 23, 2026 23:44
KVLayout.MLA cache, AttnBackend.FLASHINFER_MLA with a torch fallback,
opt-in FlashMLA decode, AttentionStep.context_only. The spec-decode
parts (KVSpec.plan_after, correct_len) stay in mstar-project#257.
The pinned mirror hard-coded the NHD page shape, so offloading an MLA
cache failed on the copy.
Import flashinfer only once the kernel path is taken, so the CPU and
odd-shape fallback runs where flashinfer is not installed.

This branch has not been deployed

No deployments
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.

2 participants