[Attention] Make the sparse MLA prefill workspace size configurable by vMaroon · Pull Request #61023 · vllm-project/vllm · GitHub
Skip to content

[Attention] Make the sparse MLA prefill workspace size configurable - #61023

Merged
robertgshaw2-redhat merged 2 commits into
vllm-project:mainfrom
vMaroon:sparse-mla-prefill-workspace-factor
Oct 12, 2026
Merged

robertgshaw2-redhat merged 2 commits into
vllm-project:mainfrom
vMaroon:sparse-mla-prefill-workspace-factor

Conversation

@vMaroon

@vMaroon vMaroon commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Overview

Adds AttentionConfig.sparse_mla_prefill_workspace_factor. It replaces the fixed 5 * max_model_len FlashMLA sparse prefill workspace and the 40 * max_model_len DSA indexer prefill buffer sized from it. Unset, VllmConfig resolves it to 5 up to a 256K max_model_len and to 2 above. At a 1M max_model_len the fixed reservations hold several GiB per GPU that a long-context deployment can return to the KV cache.

Related: #60874 (right-sizes the DeepSeek-V4.1 copies of these buffers), #42856 (fixed lower factors on SM120 only), #59319 (skips the FlashMLA workspace on the fp8 mixed-batch path).

Claims

  • Up to a 256K max_model_len the default keeps every size identical to main.
  • Above 256K the default is 2: workspace 2 * max_model_len, indexer 16 * max_model_len. --attention-config.sparse_mla_prefill_workspace_factor=5 restores the main sizes.
  • The default resolves once, in VllmConfig.__post_init__. KV cache auto-fit can lower max_model_len after the workspace is reserved, so a factor derived later could switch from 2 to 5 and size a step past the reservation.
  • One knob sizes both buffers. The indexer buffer stays (576 * 2 // 132) * factor rows, so it still fits inside the FlashMLA workspace.
  • Both chunkers keep each request's context in one gather, so a lower factor changes only how many requests share a gather.
  • The floor is 2 (ge=2). Under PCP+DCP the per-rank budget is factor * max_model_len // dcp, and a full-length request's shard can round up past max_model_len // dcp, which split_prefill_chunks asserts against.
  • GLM-5.3 FP8 on H100 at a 1M max_model_len (PCP8, DCP8, TP1): factor 2 raises available KV cache from 9.07 to 18.36 GiB per GPU.

Validation

Default, CPU. On 06a24c3, a real VllmConfig (Qwen/Qwen2.5-0.5B, CPU device) resolves the factor and both buffer sizes as follows:

max_model_len factor workspace indexer
163840 5 5x 40x
262144 5 5x 40x
262145 2 2x 16x
1048576 2 2x 16x

An explicit factor of 3 at 1M is kept, and AttentionConfig(sparse_mla_prefill_workspace_factor=1) raises a validation error. test_indexer_prefill_budget_matches_compressed_workspace reads the resolved factor through create_vllm_config; it needs a GPU, so CI runs it in the v1/attention job. pre-commit (ruff, mypy, validate-config, test tethering) passes on the changed files.

GLM-5.3 on H100, same sizes. We run GLM-5.3 FP8 in production with these exact sizes (workspace 2x, indexer 16x) applied to the same two functions on our vLLM build. The prefill engines are PCP8, DCP8, TP1, --max-model-len 1048576, fp8_ds_mla, block size 64, --gpu-memory-utilization 0.93.

factor 5 factor 2
Available KV cache per GPU 9.07 GiB 18.36 GiB
KV cache tokens per 8-GPU engine 1.40M to 1.42M 2.63M to 2.88M
1M-token code-recall prompt passes, 120.5 to 122.0 s passes, 122.6 s

All 28 production prefill engines have run factor 2 since 2026-10-10 18:08 UTC, and every one booted without OOM.

This branch on GPU: not run. The production numbers come from the same sizes on our build.

Details


Pull Request Checklist
  • I used vLLM's /pr-checklist skill. (Mandatory for agents, optional for humans).

  • AI assistance was used during the creation of this PR.

  • Design Fit: Minimizes impact on core components, reuses existing functionality, and justifies added complexity.

  • Testing and Validation: Validates the change and ensures any added tests are meaningful and reliable, with CI coverage or documented CI resource constraints and validation performed outside CI.

  • Code Quality and Style: Keeps code and comments clear and concise, and updates relevant documentation and examples.

  • Pull Request Contents: Includes a brief summary and relevant links, supports claims with evidence, explains root causes and implementation trade-offs, and follows the contributing guide.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@LucasWilkinson LucasWilkinson left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me, but might be nicer to have the default be lower at large max_model_len (per your findings), i.e. 5 for max_model_len <= 256k else 2

Comment thread tests/v1/attention/test_sparse_mla_backends.py Outdated
@LucasWilkinson LucasWilkinson added the ready ONLY add when PR is ready to merge/full CI is needed label Oct 10, 2026
@github-actions

Copy link
Copy Markdown

✅ @vMaroon, CI is now available for this PR.

  • /ci run starts upstream CI; /amd-ci run starts AMD CI only.
  • Your branch must contain every commit currently on its upstream target branch. Merge or rebase onto the latest target branch, then rerun the command. Append --allow-stale to a run command to test an outdated branch at your own risk.
  • /ci retry retries failed jobs in the CI build for the current PR head. If the current head has no CI build, it starts a new CI build for the current head containing only jobs that failed in the latest earlier CI build for this PR.
  • /amd-ci retry retries failed jobs in AMD CI for the current PR head. Use /amd-ci run when the current head has no AMD CI build.
  • /ci cancel cancels scheduled or running CI builds for this PR branch; /amd-ci cancel does the same for AMD CI only.

@vMaroon
vMaroon force-pushed the sparse-mla-prefill-workspace-factor branch from d418f78 to 06a24c3 Compare October 12, 2026 09:42
@vMaroon

vMaroon commented Oct 12, 2026

Copy link
Copy Markdown
Contributor Author

Done in 06a24c3: the field is unset by default and VllmConfig.__post_init__ resolves it to 5 up to a 256K max_model_len and 2 above. It resolves once at config time because KV cache auto-fit can lower max_model_len after the workspace is reserved, so a factor derived at use could switch from 2 to 5 and size a step past the reservation. Also rebased on main.

@vMaroon

vMaroon commented Oct 12, 2026

Copy link
Copy Markdown
Contributor Author

/ci run

@github-actions

Copy link
Copy Markdown

❌ This PR is 31 commits behind upstream main. Your branch must contain every commit currently on upstream main. No new CI build was started. Merge or rebase onto the latest main, then rerun /ci run. To test this branch at your own risk, use /ci run --allow-stale.

vMaroon and others added 2 commits October 12, 2026 17:50
The FlashMLA sparse prefill workspace (5 x max_model_len) and the DSA
indexer prefill buffer sized from it (40 x max_model_len) hold several
GiB per GPU at a 1M max_model_len. Add
AttentionConfig.sparse_mla_prefill_workspace_factor (default 5, minimum
2) so long-context deployments can return that memory to the KV cache.
The indexer buffer still fits inside the workspace.

Co-authored-by: Claude <noreply@anthropic.com>
Signed-off-by: Maroon Ayoub <mayoub@redhat.com>
…del_len

Leave sparse_mla_prefill_workspace_factor unset by default and resolve it
in VllmConfig: 5 up to a 256K max_model_len, 2 above. Long-context
deployments get the smaller reservation without a flag. It is resolved
once because KV cache auto-fit can lower max_model_len after the
workspace is reserved, and factor * max_model_len must stay within it.

Drop the buffer-size unit test; the indexer buffer fits the workspace by
construction.

Co-authored-by: Claude <noreply@anthropic.com>
Signed-off-by: Maroon Ayoub <mayoub@redhat.com>
@vMaroon
vMaroon force-pushed the sparse-mla-prefill-workspace-factor branch from 06a24c3 to ca4c57b Compare October 12, 2026 14:50
@vMaroon

vMaroon commented Oct 12, 2026

Copy link
Copy Markdown
Contributor Author

/ci run

@github-actions

Copy link
Copy Markdown

✅ Triggered Buildkite CI #94233 for commit ca4c57b78e79.

@vllm-agent

Copy link
Copy Markdown
Collaborator

CI selector (shadow): 29 test steps (61 jobs) instead of 85 (115 jobs)

Shadow mode: this changes nothing about what CI runs. It shows what the evidence-based selector would pick for this PR, next to today's rules. How it works.

Feedback welcome: reply here if it would skip a step this change needs, or runs something unrelated.

steps (jobs) Today's rules Selector Would skip Would add
NVIDIA, CPU and others 85 (115) 29 (61) 66 (83) 10 (29)
AMD mirrors 85 (118) 23 (54) 70 (90) 8 (26)
Selector would run (29)
  • amd-kernels-mi355
  • basic-models-test-other-cpu
  • basic-models-tests-extra-initialization ×14
  • basic-models-tests-initialization
  • basic-models-tests-other
  • cpu-kernel-tests ×2
  • cpu-multimodal-config
  • cpu-params-env-tokenizers-parser
  • e2e-core-1-gpu
  • engine
  • fusion-and-compile-unit-tests-2xb200
  • glm5next-unit-tests
  • kernels-attention-test ×7
  • kernels-b200 ×3
  • kernels-core-operation-test ×3
  • kernels-flashmla-test-h100
  • kernels-root-misc-test-b200
  • kimi-k3-unit-tests-b200
  • kv-offload-large
  • model-executor
  • pytorch-compilation-passes-unit-tests
  • pytorch-compilation-unit-tests
  • quantization ×4
  • v1-attention-b200 ×2
  • v1-attention-h100-mi300 ×2
  • v1-core
  • v1-executor-worker
  • v1-kv-connectors ×4
  • v1-others-cpu
Would skip (today's rules run them) (66)
  • amd-lm-eval-small-models-harness
  • amd-qwen3-next-mtp-async-eplb-accuracy
  • ascend-npu-test
  • async-engine-inputs-utils-worker
  • basic-correctness ×2
  • basic-correctness-cpu-offload
  • basic-correctness-cumem
  • basic-correctness-prefetch-offload
  • basic-correctness-sleep-mode
  • batch-invariance-b200
  • batch-invariance-h100
  • benchmarks-cli-test
  • cpu-language-generation-and-pooling-model-tests ×3
  • cpu-reasoning-renderers
  • cpu-tool-parsers
  • cudagraph
  • e2e-core-large-memory
  • e2e-scheduling-1-gpu
  • e2e-scheduling-accuracy-1-gpu
  • entrypoints-integration-api-server ×4
  • entrypoints-integration-api-server-generate
  • entrypoints-integration-api-server-openai-chat_completion
  • entrypoints-integration-api-server-openai-completion
  • entrypoints-integration-llm
  • entrypoints-integration-multimodal
  • entrypoints-integration-pooling
  • entrypoints-integration-responses-api
  • entrypoints-integration-speech_to_text
  • fusion-e2e-quick-h100
  • fusion-e2e-tp2-ar-rms-dynamo-partition-amd
  • fusion-e2e-tp2-ar-rms-inductor-partition-amd
  • fusion-e2e-tp2-b200
  • fusion-e2e-tp2-quick-h100
  • kernels-fla-ops-test-b200
  • kernels-fusedmoe-layer-test-2-b200s
  • kernels-fusedmoe-layer-test-2-h100s
  • kernels-mhc-test-b200
  • kernels-moe-test ×5
  • language-models-tests-granite-l4-compatibility
  • language-models-tests-hybrid ×2
  • language-models-tests-standard
  • lm-eval-dspark-watermark-2xh100
  • metrics-tracing-2-gpus
  • mooncake-ec-tcp-e2e-2-gpus
  • multi-modal-models-standard-1-qwen2
  • multi-modal-models-standard-2-qwen3-gemma
  • multi-modal-models-standard-3-llava-qwen2-vl
  • multi-modal-models-standard-4-other-whisper
  • multi-modal-processor ×4
  • multi-modal-processor-cpu ×4
  • pytorch-compilation-dynamic-shapes
  • pytorch-compilation-unit-tests-h100
  • pytorch-fullgraph-cudagraph-l4-compatibility
  • pytorch-fullgraph-test
  • regression
  • replayssm-e2e
  • rl-entrypoints-tests
  • spec-decode-mtp-deepseek-mimo
  • spec-decode-mtp-gemma4
  • spec-decode-mtp-qwen3-5
  • spec-decode-speculators
  • v1-kv-offload
  • v1-logits-oracle
  • v1-metrics-lmeval
  • v1-sample
  • v1-spec-decode
Would add (today's rules do not run them) (10)
  • amd-kernels-mi355 (code map)
  • basic-models-tests-extra-initialization ×14 (code map)
  • cpu-kernel-tests ×2 (code map)
  • fusion-and-compile-unit-tests-2xb200 (code map)
  • glm5next-unit-tests (code map)
  • kernels-core-operation-test ×3 (code map)
  • kimi-k3-unit-tests-b200 (code map)
  • kv-offload-large (Python record)
  • model-executor (code map)
  • quantization ×4 (code map)
AMD mirrors: would skip (70)
  • async-engine-inputs-utils-worker
  • basic-correctness ×2
  • basic-correctness-cpu-offload
  • basic-correctness-cumem
  • basic-correctness-prefetch-offload
  • basic-correctness-sleep-mode
  • batch-invariance-h100
  • benchmarks-cli-test
  • cudagraph
  • deepseek-v4-kernel-test-b200
  • e2e-core-large-memory
  • e2e-scheduling-1-gpu
  • e2e-scheduling-accuracy-1-gpu
  • entrypoints-integration-api-server ×4
  • entrypoints-integration-api-server-generate
  • entrypoints-integration-api-server-openai-chat_completion
  • entrypoints-integration-api-server-openai-completion
  • entrypoints-integration-llm
  • entrypoints-integration-multimodal
  • entrypoints-integration-pooling
  • entrypoints-integration-responses-api
  • entrypoints-integration-speech_to_text
  • extract-hidden-states-integration-2-gpus
  • fault-tolerance-e2e-2xh100
  • fusion-and-compile-unit-tests-2xb200
  • fusion-e2e-quick-h100
  • fusion-e2e-tp2-ar-rms-config-sweep-h100
  • fusion-e2e-tp2-b200
  • fusion-e2e-tp2-quick-h100
  • kernels-b200 ×3
  • kernels-fla-ops-test-b200
  • kernels-fp4-moe-test-b200
  • kernels-fusedmoe-layer-test-2-b200s
  • kernels-fusedmoe-layer-test-2-h100s
  • kernels-mhc-test-b200
  • kernels-moe-test ×5
  • kernels-quantization-test ×6
  • language-models-tests-extra-standard ×2
  • language-models-tests-granite-l4-compatibility
  • language-models-tests-hybrid ×2
  • language-models-tests-standard
  • lm-eval-dspark-watermark-2xh100
  • lm-eval-small-models
  • metrics-tracing-2-gpus
  • mooncake-ec-tcp-e2e-2-gpus
  • mrcr-eval-small-models
  • multi-modal-models-standard-1-qwen2
  • multi-modal-models-standard-2-qwen3-gemma
  • multi-modal-models-standard-3-llava-qwen2-vl
  • multi-modal-models-standard-4-other-whisper
  • multi-modal-processor ×4
  • openai-api-correctness
  • pipeline-context-parallelism-4-gpus
  • platform-tests
  • pytorch-compilation-dynamic-shapes
  • pytorch-compilation-unit-tests-h100
  • pytorch-fullgraph-cudagraph-l4-compatibility
  • pytorch-fullgraph-test
  • quantized-moe-test-b200
  • regression
  • rl-entrypoints-tests
  • spec-decode-mtp-deepseek-mimo
  • spec-decode-mtp-gemma4
  • spec-decode-mtp-qwen3-5
  • spec-decode-speculators
  • v1-kv-offload
  • v1-logits-oracle
  • v1-metrics-lmeval
  • v1-sample
  • v1-spec-decode
AMD mirrors: would add (8)
  • basic-models-tests-extra-initialization ×14 (code map)
  • engine-1-gpu (code map)
  • glm5next-unit-tests (code map)
  • kernels-core-operation-test ×3 (code map)
  • kimi-k3-unit-tests-b200 (code map)
  • kv-offload-large (Python record)
  • model-executor (code map)
  • quantization ×4 (code map)

4 changed files · base ffec221276 · head ca4c57b78e · Python record: build 93039 at 1e5d0ea888 · kernel record: table 74f4404 (build 94125), map 74f4404 · not counted: 11 build steps, 5 A100 steps the generator no longer emits, 20 optional steps the selector would also run

@robertgshaw2-redhat
robertgshaw2-redhat merged commit d6aca83 into vllm-project:main Oct 12, 2026
241 checks passed
AndreasKaratzas pushed a commit to AndreasKaratzas/vllm that referenced this pull request Oct 16, 2026
…llm-project#61023)

Signed-off-by: Maroon Ayoub <mayoub@redhat.com>
Co-authored-by: Claude <noreply@anthropic.com>

Signed-off-by: Andreas Karatzas <AndreasKaratzas@users.noreply.github.com>
michael-gpu pushed a commit to practical-inference/vllm-ampere-extended that referenced this pull request Oct 20, 2026
…llm-project#61023)

Signed-off-by: Maroon Ayoub <mayoub@redhat.com>
Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready ONLY add when PR is ready to merge/full CI is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants