[Perf][Pooling] Avoid blocking seq_lens GPU-to-CPU copy for pooling in FlashInfer metadata builder (#57214)

Signed-off-by: frankwang28 <frank.wbb@hotmail.com>
Co-authored-by: Misha Goin <mgoin64@gmail.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Vadim Gimpelson <156319763+vadiklyutiy@users.noreply.github.com>
This commit is contained in:
Frank Wang
2026-09-27 16:06:38 +00:00
committed by GitHub
co-authored by Misha Goin mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Vadim Gimpelson
parent 44af287ebe
commit 0376f81530
2 changed files with 97 additions and 3 deletions
+10 -2
View File
@@ -700,6 +700,7 @@ class FlashInferMetadataBuilder(AttentionMetadataBuilder[FlashInferMetadata]):
self.cache_config = vllm_config.cache_config
self.model_config = vllm_config.model_config
self.attention_config = vllm_config.attention_config
self._num_speculative_tokens = vllm_config.num_speculative_tokens
self._workspace_buffer = None
self._prefill_wrapper: (
BatchPrefillWithPagedKVCacheWrapper | BatchDCPPrefillWrapper | None
@@ -1446,8 +1447,15 @@ class FlashInferMetadataBuilder(AttentionMetadataBuilder[FlashInferMetadata]):
# (block_tables, seq_lens) directly.
needs_seq_lens_cpu = self.use_dcp or use_cascade or not all_uses_trtllm
if needs_seq_lens_cpu:
with gpu_sync_allowed():
seq_lens_cpu = common_attn_metadata.seq_lens.cpu()
if (
self._num_speculative_tokens == 0
and common_attn_metadata.seq_lens_cpu_upper_bound is not None
):
# No speculative token accounting, so the upper bound is exact.
seq_lens_cpu = common_attn_metadata.seq_lens_cpu_upper_bound
else:
with gpu_sync_allowed():
seq_lens_cpu = common_attn_metadata.seq_lens.cpu()
else:
seq_lens_cpu = None