Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 7 additions & 13 deletions tests/pytorch/attention/run_attention_with_cp.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,11 @@ def run_dpa_with_cp(
logging.root.setLevel(log_level)
# When is_training is False, gradient outputs are None.
is_training = is_training == "True"
pad_between_seqs = None
if qkv_format == "thd":
# Keep this in sync with generate_input_shapes so DPA gets the explicit
# padding state without a GPU-to-CPU sync.
pad_between_seqs = kernel_backend == "FusedAttention" or fa_pad_between_seqs == "True"

# set up environment variables and config
if deterministic == "True":
Expand Down Expand Up @@ -411,13 +416,7 @@ def run_dpa_with_cp(
cu_seqlens_kv=cu_seqlens_kv,
cu_seqlens_q_padded=cu_seqlens_q_padded,
cu_seqlens_kv_padded=cu_seqlens_kv_padded,
# Test runner sets cu_seqlens_q == cu_seqlens_q_padded for the
# FlashAttention path, i.e. no inter-sequence padding. Declare this
# explicitly so the sync-free auto-detect (which conservatively
# picks True when padded cu_seqlens are present) does not disable FA.
pad_between_seqs=(
(kernel_backend != "FlashAttention") if qkv_format == "thd" else None
),
pad_between_seqs=pad_between_seqs,
fp8_output=fp8_mha,
)
if config.return_max_logit:
Expand Down Expand Up @@ -535,12 +534,7 @@ def run_dpa_with_cp(
cu_seqlens_kv=cu_seqlens_kv,
cu_seqlens_q_padded=cu_seqlens_q_padded,
cu_seqlens_kv_padded=cu_seqlens_kv_padded,
# See note above (non-CP branch): same explicit declaration so
# FlashAttention isn't disabled by the conservative sync-free
# auto-detect when this test path constructs no inter-seq padding.
pad_between_seqs=(
(kernel_backend != "FlashAttention") if qkv_format == "thd" else None
),
pad_between_seqs=pad_between_seqs,
fp8_output=fp8_mha,
)
if config.return_max_logit:
Expand Down
Loading