Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
3ab4725
Add support in lower level JAX API for returning max logit and softma…
KshitijLakhani Jun 10, 2026
84f180a
Add support for returning reduced per head max logit. Plumb max logit…
KshitijLakhani Jun 10, 2026
8f565cf
Add max logit to JAX fused attn FFI and set it in the workspace
KshitijLakhani Jun 10, 2026
31ede58
Add first pass tests for max logit and softmax aux tensor outputs in …
KshitijLakhani Jun 10, 2026
dde413b
Reject aux returns with score_mod
KshitijLakhani Jul 8, 2026
9da2226
Handle SM120 max-logit layout
KshitijLakhani Jul 8, 2026
38ce6e3
Drop softmax aux return
KshitijLakhani Jul 8, 2026
3198726
Modify static args in fused attn tests for jax
KshitijLakhani Jul 20, 2026
e56b971
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 22, 2026
cbe18ac
nit: Inline the choice of what is to be returned and remove redundant…
KshitijLakhani Aug 14, 2026
7f9977e
Expose JAX max logit
KshitijLakhani Aug 19, 2026
de929ba
Support CP max logit
KshitijLakhani Aug 19, 2026
78c8828
Expand JAX max logit tests
KshitijLakhani Aug 21, 2026
e36a4a0
Remove JAX max logit integration tests
KshitijLakhani Aug 21, 2026
9b537ba
Broaden JAX CP max logit tests
KshitijLakhani Aug 21, 2026
bb7ce9b
Reduce JAX max logit across DP
KshitijLakhani Aug 24, 2026
c093329
Simplify JAX max logit return
KshitijLakhani Aug 24, 2026
0f7bb0b
Document JAX max logit reductions
KshitijLakhani Aug 24, 2026
90a3eaf
Refine JAX max logit tests
KshitijLakhani Aug 24, 2026
704957a
Rename JAX max logit buffer
KshitijLakhani Aug 24, 2026
2e71bc8
Check JAX attention tensor pack capacity
KshitijLakhani Aug 24, 2026
d7bf4cf
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 24, 2026
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
90 changes: 89 additions & 1 deletion tests/jax/test_distributed_fused_attn.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,12 @@ def test_softcap_score_mod_with_aux_params_backward(
),
]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you run L1 CI on this PR? I don't see a CI run

@KshitijLakhani KshitijLakhani Aug 24, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had run the test suite locally only. Launched CI right now. Thanks for the reminder !

DISTRIBUTED_CONTEXT_SELF_ATTN_MAX_LOGIT_CP_MODES = [
pytest.param(CPStrategy.ALL_GATHER, False, id="AG"),
pytest.param(CPStrategy.RING, False, id="RING-NO_SCAN"),
pytest.param(CPStrategy.RING, True, id="RING-SCAN"),
]


class TestDistributedContextParallelSelfAttn:
# TODO(KshitijLakhani): parametrize num_segments_per_seq for all CP tests
Expand All @@ -419,6 +425,8 @@ def impl_test_context_parallel_attn(
window_size=None,
stripe_size=None,
num_segments_per_seq=None,
return_max_logit=False,
check_forward_output=True,
):
if qkv_layout.is_thd():
if not load_balanced and (
Expand Down Expand Up @@ -513,9 +521,89 @@ def check_has_backend_for_mask(mask_type):
if num_head % kv_groups != 0 or (num_head // kv_groups) % tp_size != 0:
pytest.skip(f"Skipping {kv_groups=} not multiple of {data_shape=} or {tp_size=}")

runner.test_backward()
if return_max_logit:
runner.test_forward(
return_max_logit=True,
check_output=check_forward_output,
)
else:
runner.test_backward()
del os.environ["NVTE_FUSED_RING_ATTENTION_USE_SCAN"]

@pytest_parametrize_wrapper(
"device_count,mesh_shape,mesh_axes,mesh_resource",
generate_context_parallel_configs_for_attn(),
)
@pytest.mark.parametrize("data_shape", DISTRIBUTED_CONTEXT_SELF_ATTN_DATA_SHAPES[:1])
@pytest.mark.parametrize("kv_groups", [1, 8])
@pytest.mark.parametrize("dtype", [pytest.param(jnp.bfloat16, id="BF16")])
@pytest.mark.parametrize(
"qkv_layout, attn_mask_type",
DISTRIBUTED_CONTEXT_SELF_ATTN_LAYOUTS_MASKS,
)
@pytest.mark.parametrize(
"cp_strategy, use_scan_ring",
DISTRIBUTED_CONTEXT_SELF_ATTN_MAX_LOGIT_CP_MODES,
)
@pytest.mark.parametrize(
"window_size",
[
pytest.param((-1, -1), id="NO_SWA"),
pytest.param((20, 0), id="SWA"),
],
)
def test_context_parallel_return_max_logit(
self,
device_count,
mesh_shape,
mesh_axes,
mesh_resource,
data_shape,
kv_groups,
dtype,
qkv_layout,
attn_mask_type,
cp_strategy,
window_size,
use_scan_ring,
):
"""Check CP fused attention returns global per-head max_logit."""
is_thd = qkv_layout.is_thd()
supports_swa = is_thd and (
cp_strategy == CPStrategy.ALL_GATHER
or (cp_strategy == CPStrategy.RING and not use_scan_ring)
)
if window_size != (-1, -1) and not supports_swa:
pytest.skip("CP SWA requires THD All-Gather or unrolled THD Ring.")
# TODO: Evaluate cuDNN Max mismatches observed for striped multi-segment THD Ring GQA.
if is_thd and cp_strategy == CPStrategy.RING and kv_groups > 1:
pytest.skip("THD Ring GQA Max mismatches require further evaluation.")

stripe_size = 64 if is_thd and cp_strategy == CPStrategy.ALL_GATHER else None
if is_thd and cp_strategy == CPStrategy.RING:
stripe_size = 1
num_segments_per_seq = 5 if is_thd else None
check_forward_output = not (is_thd and cp_strategy == CPStrategy.RING)
self.impl_test_context_parallel_attn(
device_count,
mesh_shape,
mesh_axes,
mesh_resource,
data_shape,
kv_groups,
attn_mask_type,
dtype,
qkv_layout,
True,
cp_strategy,
use_scan_ring=use_scan_ring,
window_size=window_size,
stripe_size=stripe_size,
num_segments_per_seq=num_segments_per_seq,
return_max_logit=True,
check_forward_output=check_forward_output,
)

@pytest_parametrize_wrapper(
"device_count,mesh_shape,mesh_axes,mesh_resource",
generate_context_parallel_configs_for_attn(),
Expand Down
Loading
Loading