[DeepSeek V3.2] [Bugfix] slice indexer and padding fa3 when can not run cuda graph (#17076)

This commit is contained in:
Yongfei Xu
2026-02-03 01:32:20 +08:00
committed by GitHub
parent 980d2936cd
commit 677f3c49da
4 changed files with 58 additions and 7 deletions
@@ -86,6 +86,11 @@ class BaseIndexerMetadata(ABC):
Return: seq lens for each batch.
"""
def get_nsa_extend_len_cpu(self) -> List[int]:
"""
Return: extend seq lens for each batch.
"""
def get_token_to_batch_idx(self) -> torch.Tensor:
"""
Return: batch idx for each token.
@@ -390,6 +395,9 @@ class Indexer(MultiPlatformOp):
assert len(weights.shape) == 3
weights = weights.squeeze(2)
# When attn_tp_size > 1 or in the MAX_LEN padding mode, padding may exist in the hidden states,
# and it is necessary to extract the actual q length.
q_offset = sum(metadata.get_nsa_extend_len_cpu())
if _is_hip:
from aiter.ops.triton.pa_mqa_logits import deepgemm_fp8_paged_mqa_logits
@@ -416,9 +424,9 @@ class Indexer(MultiPlatformOp):
)
else:
logits = deep_gemm.fp8_paged_mqa_logits(
q_fp8,
q_fp8[:q_offset],
kv_cache_fp8,
weights,
weights[:q_offset],
seqlens_32,
block_tables,
schedule_metadata,
@@ -428,6 +436,16 @@ class Indexer(MultiPlatformOp):
# NOTE(dark): logits should be cleaned in topk_transform
topk_result = metadata.topk_transform(logits, self.index_topk)
# Restore possible padding exist in the hidden states.
if not _is_hip and q_offset < q_fp8.shape[0]:
pad_len = q_fp8.shape[0] - q_offset
padding = torch.full(
(pad_len, topk_result.shape[1]),
-1,
dtype=topk_result.dtype,
device=topk_result.device,
)
topk_result = torch.cat([topk_result, padding], dim=0)
return topk_result
def _should_chunk_mqa_logits(