[PD] Fix block scale registration for mixed full/SWA KV dtypes (#41924)

This commit is contained in:
Eric Zhang
2026-10-01 14:25:04 +08:00
committed by GitHub
parent 77b64e353f
commit 947fee9384
2 changed files with 65 additions and 13 deletions
+10 -13
View File
@@ -1389,19 +1389,16 @@ def setup_state_kv_args(
# so they inherit the index payload of the KV they describe.
# Only the concrete SWAKVPool owns a full sub-pool; other
# BaseSWAKVPool implementations describe their state per entry.
if isinstance(token_to_kv_pool, SWAKVPool) and isinstance(
token_to_kv_pool.full_kv_pool, MHATokenToKVPoolMXFP8
):
append_state_component(
kv_args,
StateType.BLOCK_SCALE,
*token_to_kv_pool.get_kv_scale_buf_infos(),
)
append_state_component(
kv_args,
StateType.BLOCK_SCALE_SWA,
*token_to_kv_pool.get_swa_kv_scale_buf_infos(),
)
if isinstance(token_to_kv_pool, SWAKVPool):
# Global and SWA caches may use different dtypes.
for pool, state_type in (
(token_to_kv_pool.full_kv_pool, StateType.BLOCK_SCALE),
(token_to_kv_pool.swa_kv_pool, StateType.BLOCK_SCALE_SWA),
):
if isinstance(pool, MHATokenToKVPoolMXFP8):
append_state_component(
kv_args, state_type, *pool.get_kv_scale_buf_infos()
)
# unified_kv: the SWA ring lives in the unified buffers (no separate
# swa_kv_pool) and is addressed per-row, so ship it as SWA_RING.
if getattr(token_to_kv_pool, "_unified_kv", False) and hasattr(