[Bugfix][KV Offload] Scale UniformTypeKVCacheSpecs groups by DCP - #50883
Conversation
5353ac9 to
08f985f
Compare
|
This pull request has merge conflicts that must be resolved before it can be |
|
This pull request has merge conflicts that must be resolved before it can be |
|
This pull request has merge conflicts that must be resolved before it can be |
d572f3e to
02b320d
Compare
|
This pull request has merge conflicts that must be resolved before it can be |
| * ( | ||
| parallel_config.decode_context_parallel_size | ||
| if isinstance(group.kv_cache_spec, AttentionSpec) | ||
| if is_kv_cache_spec_dcp_sharded(group.kv_cache_spec) |
There was a problem hiding this comment.
the whole tokens_per_block calculation is now doable with tokens_per_block=resolve_dcp_kv_block_size(group.kv_cache_spec, parallel_config.decode_context_parallel_size).
isinstance(spec, AttentionSpec) so that Mamba groups stay unscaled. UniformTypeKVCacheSpecs is a container rather than an AttentionSpec subclass, so DSA models, whose indexer and MLA layers merge into one uniform group, stopped being scaled as well: build_offloading_config reports tokens_per_block=block_size while resolve_kv_cache_block_sizes still returns block_size * dcp for a single group, and enabling CPU offload under DCP dies on the divisibility assert. Key the scaling off a helper that unwraps the container, so Mamba stays unscaled and every attention group keeps its DCP span. Co-authored-by: Claude <noreply@anthropic.com> Signed-off-by: Mikhail Kostryukov <mike@triptrack.net>
…cache spec Signed-off-by: Lucas Wilkinson <lwilkinson@neuralmagic.com>
isinstance(spec, AttentionSpec) so that Mamba groups stay unscaled. UniformTypeKVCacheSpecs is a container rather than an AttentionSpec subclass, so DSA models, whose indexer and MLA layers merge into one uniform group, stopped being scaled as well: build_offloading_config reports tokens_per_block=block_size while resolve_kv_cache_block_sizes still returns block_size * dcp for a single group, and enabling CPU offload under DCP dies on the divisibility assert. Key the scaling off a helper that unwraps the container, so Mamba stays unscaled and every attention group keeps its DCP span. Co-authored-by: Claude <noreply@anthropic.com> Signed-off-by: Mikhail Kostryukov <mike@triptrack.net>
…cache spec Signed-off-by: Lucas Wilkinson <lwilkinson@neuralmagic.com>
build_offloading_config() decides DCP scaling with isinstance(spec, AttentionSpec) so that Mamba groups stay unscaled. UniformTypeKVCacheSpecs is a container rather than an AttentionSpec subclass, so DSA models, whose indexer and MLA layers merge into one uniform group, are not scaled either: the connector reports tokens_per_block=block_size while resolve_kv_cache_block_sizes() returns block_size * dcp for the same group, and enabling CPU offload under DCP dies on the divisibility assert. resolve_kv_cache_block_sizes() already answers this question with resolve_dcp_kv_block_size(), which unwraps the container. Use that helper on the offloading side too, so both sides agree by construction and Mamba groups keep their unscaled per-rank span. Co-authored-by: Claude <noreply@anthropic.com> Signed-off-by: Mikhail Kostryukov <mike@triptrack.net>
02b320d to
6567ad1
Compare
|
@cjackal You are right, and half of this PR is now redundant: What is left is the connector side: Aside: AI assistance was used for this work. |
|
/ci run |
|
❌ @drakosha, A reviewer with write access must run |
|
/ci run |
|
✅ @drakosha, CI is now available for this PR.
|
|
✅ Triggered Buildkite CI #86859 for commit |
…m-project#50883) Signed-off-by: Mikhail Kostryukov <mike@triptrack.net> Co-authored-by: Claude <noreply@anthropic.com>
…m-project#50883) Signed-off-by: Mikhail Kostryukov <mike@triptrack.net> Co-authored-by: Claude <noreply@anthropic.com>
Purpose
#49964 gated the DCP scaling of a group's token span on
isinstance(group.kv_cache_spec, AttentionSpec)so that Mamba groups stay unscaled.UniformTypeKVCacheSpecsis a container rather than anAttentionSpecsubclass, so DSA models — whose indexer and MLA layers merge into a single uniform group — lost the DCP factor too:build_offloading_configreportstokens_per_block = block_size(64),resolve_kv_cache_block_sizesstill returnsblock_size * dcp(128) for a single group,so enabling CPU offload under DCP dies at startup:
Reported by @Leoyzen on GLM-5.2, TP8/DCP2,
fp8_ds_mla, MTP,OffloadingConnector: #46514 (comment)The scaling is now keyed off a helper that unwraps the container, so Mamba groups stay unscaled and every attention group keeps its DCP span. Same call site is fixed in
resolve_kv_cache_block_sizesfor multi-group configs.Related: #50823 fixes the other half of the same container-not-unwrapped family (block table width).
Test
Three tests, one per call site plus the hybrid case, next to the Mamba tests from #49964:
offloading_connector/test_config.py::test_dcp_scales_uniform_type_attention_group_blocksoffloading_connector/test_config.py::test_dcp_scales_uniform_type_group_alongside_mambacore/test_kv_cache_utils.py::test_resolve_block_sizes_scales_uniform_type_group_by_dcpVerified fail→pass in a container built from the current nightly (
0.26.1rc1.dev255+g5e35a6f4f); each test fails on unpatchedmainwith the reported assert (tokens_per_block=16 not divisible by tokens_per_hash=32) or a wrong span, and the two suites pass with the fix:Config-level change, no effect on model output; no eval run.
AI assistance (Claude) was used for this work; all changes reviewed.