diff --git a/tests/jax/test_distributed_fused_attn.py b/tests/jax/test_distributed_fused_attn.py index 9678195942..207504bf20 100644 --- a/tests/jax/test_distributed_fused_attn.py +++ b/tests/jax/test_distributed_fused_attn.py @@ -835,7 +835,7 @@ def test(self, cp_size, shape, qkv_format, reorder_strategy, stripe_size): seq_dim = 0 if reorder_strategy == ReorderStrategy.Striped: - seq_lens = shape[seq_dim] + seq_lens = tensor.shape[seq_dim] if seq_lens < (cp_size * stripe_size): pytest.skip(f"{seq_lens=} must be larger than {cp_size*stripe_size=}") @@ -848,3 +848,17 @@ def test(self, cp_size, shape, qkv_format, reorder_strategy, stripe_size): inversed = inverse(reordered, reorder_strategy, cp_size, seq_dim, stripe_size) assert jnp.array_equal(inversed, ref) + + @pytest.mark.parametrize("stripe_size", [1, 4]) + def test_sbhd_striped_uses_swapped_seq_dim(self, stripe_size, monkeypatch): + """Regression test: SBHD Striped skip must use the swapped sequence dim.""" + cp_size = 2 + shape = (1, 16, 1, 1) # original [batch, seq, heads, dim] + + # If the skip logic reads the original unswapped batch dim (1), it would skip + # because 1 < cp_size * stripe_size. With the fix it reads the swapped seq + # dim (16), so the parametrized test should run to completion. + monkeypatch.setattr( + pytest, "skip", lambda reason: pytest.fail(f"unexpected pytest.skip: {reason}") + ) + self.test(cp_size, shape, QKVFormat.SBHD, ReorderStrategy.Striped, stripe_size)