[Multimodal] Avoid extra d2d for encoder cudagraph with fused input norm (#56711)

Signed-off-by: Isotr0py <Isotr0py@outlook.com>
This commit is contained in:
Isotr0py
2026-09-28 21:04:01 +08:00
committed by GitHub
parent 7ba3df63cb
commit 522101f6ed
4 changed files with 29 additions and 6 deletions
@@ -58,6 +58,13 @@ def flash_attn_maxseqlen_wrapper(
max_seqlen = max_seqlen.item()
q, k, v = (einops.rearrange(x, "b s ... -> (b s) ...") for x in [q, k, v])
if current_platform.is_cuda() and torch.cuda.is_current_stream_capturing():
# workaround for encoder CUDA-graph replay paddings with NaNs edge case
kwargs["out"] = torch.zeros(
q.shape[0], q.shape[1], v.shape[-1], dtype=q.dtype, device=q.device
)
output = flash_attn_varlen_func(
q,
k,