Repository navigation
Run multi-head latent attention models under continuous batching - #50365
Open
qgallouedec wants to merge 6 commits into
Open
qgallouedec wants to merge 6 commits into
qgallouedec wants to merge 6 commits into
Conversation
1 of 15 tasks
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. Pages changed in this PR: |
This was referenced Nov 4, 2026
The latent attention layers (DeepSeek V2/V3, Kimi K2 and the models built on them) declare their compressed latent and rotary key as cache rows, write and read them through the cache, and rebuild the keys and values of all attended tokens before the attention. The cache hands keys and values through for layers declaring no key row, and only layers caching exactly a key and a value of the same size use the block table. The sparse attention indexers (DeepSeek V3.2, GLM-5, Mistral Large 4 and the models built on them) cache their keys as one more row and select on the packed batch under the engine's mask.
One 576-wide row per token on DeepSeek V3 instead of two: the layout paged MLA kernels read, and one write and one read per layer.
# Conflicts: # src/transformers/models/axk1/modeling_axk1.py # src/transformers/models/axk1/modular_axk1.py # src/transformers/models/axk2/modeling_axk2.py # src/transformers/models/axk2/modular_axk2.py # src/transformers/models/bailing_hybrid/modeling_bailing_hybrid.py # src/transformers/models/bailing_hybrid/modular_bailing_hybrid.py # src/transformers/models/deepseek_v2/modeling_deepseek_v2.py # src/transformers/models/deepseek_v2/modular_deepseek_v2.py # src/transformers/models/deepseek_v3/modeling_deepseek_v3.py # src/transformers/models/deepseek_v3/modular_deepseek_v3.py # src/transformers/models/deepseek_v32/modeling_deepseek_v32.py # src/transformers/models/deepseek_v32/modular_deepseek_v32.py # src/transformers/models/glm4_moe_lite/modeling_glm4_moe_lite.py # src/transformers/models/glm5_next/modeling_glm5_next.py # src/transformers/models/glm5_next/modular_glm5_next.py # src/transformers/models/glm_moe_dsa/modeling_glm_moe_dsa.py # src/transformers/models/glm_moe_dsa/modular_glm_moe_dsa.py # src/transformers/models/hy_v4/modeling_hy_v4.py # src/transformers/models/hy_v4/modular_hy_v4.py # src/transformers/models/kimi_linear/modeling_kimi_linear.py # src/transformers/models/kimi_linear/modular_kimi_linear.py # src/transformers/models/longcat_flash/modeling_longcat_flash.py # src/transformers/models/longcat_flash/modular_longcat_flash.py # src/transformers/models/minicpm3/modeling_minicpm3.py # src/transformers/models/minicpm3/modular_minicpm3.py # src/transformers/models/mistral4/modeling_mistral4.py # src/transformers/models/mistral4/modular_mistral4.py # src/transformers/models/mistral_large4/modeling_mistral_large4.py # src/transformers/models/mistral_large4/modular_mistral_large4.py # src/transformers/models/youtu/modeling_youtu.py
…her latent attention models
Contributor
|
[For maintainers] Suggested jobs to run (before merge) run-slow: axk1, axk2, bailing_hybrid, deepseek_v2, deepseek_v3, deepseek_v32, dots3_note, glm4_moe_lite, glm5_next, glm_moe_dsa, hy_v4, kimi_linear, longcat_flash, minicpm3, mistral4, mistral_large4 |
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.
What does this PR do?
Stacked on #50359. Runs multi-head latent attention models under continuous batching: DeepSeek V2/V3, Kimi K2 and the models built on them, plus the sparse-attention ones (DeepSeek V3.2, GLM-5, Mistral Large 4). DeepSeek V3 fails today on the first forward: the engine caches the expanded keys in a row sized from
head_dim. The layers now declare their compressed latent and rotary key as rows, write and read them themselves, and rebuild keys and values before attention. The DSA indexers cache their keys as one more row and select on the packed batch under the engine's mask.Part of #50352