[DSv4 Perf] Optimize workspace reuse for eager break, 3.9% E2E TTFT improvement. (#49236)

Signed-off-by: yewentao256 <zhyanwentao@126.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
Wentao Ye
2026-07-31 08:45:58 -07:00
committed by GitHub
co-authored by mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
parent 5233368dac
commit df71917cf1
15 changed files with 354 additions and 30 deletions
+10 -1
View File
@@ -2,7 +2,7 @@
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
from dataclasses import dataclass
from typing import Any, ClassVar, cast
from typing import TYPE_CHECKING, Any, ClassVar, cast
import torch
from torch import nn
@@ -35,6 +35,9 @@ from vllm.v1.kv_cache_interface import (
SlidingWindowMLASpec,
)
if TYPE_CHECKING:
from vllm.models.deepseek_v4.eager_scratch import DeepseekV4EagerScratchPool
def _prefer_two_stage_compressor() -> bool:
# Platforms that favor the triton variant of two-stage compressor split.
@@ -226,6 +229,7 @@ class DeepseekCompressor(nn.Module):
prefix: str = "",
k_cache_prefix="",
use_fp4_cache: bool = False,
eager_scratch_pool: "DeepseekV4EagerScratchPool | None" = None,
):
super().__init__()
self.compress_ratio = compress_ratio
@@ -235,6 +239,7 @@ class DeepseekCompressor(nn.Module):
self.prefix = prefix
self.k_cache_prefix = k_cache_prefix
self.use_fp4_cache = use_fp4_cache
self.eager_scratch_pool = eager_scratch_pool
config = vllm_config.model_config.hf_config
self.rope_head_dim = config.qk_rope_head_dim
@@ -428,6 +433,10 @@ class DeepseekCompressor(nn.Module):
store_full_fp8=store_full_fp8,
fp8_scale=fp8_scale,
)
if not self.overlap and self.eager_scratch_pool is not None:
extra_kwargs["compress_scratch"] = (
self.eager_scratch_pool.compressor_scratch(num_actual)
)
elif self._use_two_stage_fused_compressor:
# head=512 cr>=128 (no overlap): two-pass split compressor on the
# prefill suffix, single-pass on the decode prefix.