attn: MLA attention resource (split from #257) - #321
Open
vasilevklart wants to merge 3 commits into
Open
vasilevklart wants to merge 3 commits into
vasilevklart wants to merge 3 commits into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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), andAttentionStep.context_only.The speculative-decoding parts (
KVSpec.plan_after,KVManager.correct_len,SPEC_ACCEPTANCE) stay in #257.flashinfer_mla.pyandflashmla.pymatch #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
flashinferbefore deciding to fall back.Tests:
test/modular/test_mla_kv_layout.py,test_context_only_attention.py, andtest_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.