Skip to content
Open
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
19 changes: 18 additions & 1 deletion tests/jax/test_fused_attn.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def make_mask(
segment_pos_q,
segment_pos_kv,
window_size,
dtype=jnp.bool,
dtype=jnp.bool_,

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.

We seem to have a few other call sites of jnp.bool? If it's deprecated, could we fix those ones as well? Thanks.

I think we can get away with the test as well.

segment_ids_q=segment_ids_q,
segment_ids_kv=segment_ids_kv,
)
Expand All @@ -236,6 +236,23 @@ def make_mask(
return mask


def test_make_mask_bottom_right_swa_dtype():
"""Regression test: make_mask bottom-right branch should use jnp.bool_, not jnp.bool."""
batch, seqlen = 2, 16
segment_ids = jnp.ones((batch, seqlen), dtype=jnp.int32)
segment_pos = jnp.broadcast_to(jnp.arange(seqlen, dtype=jnp.int32), (batch, seqlen))
window_size = (4, 0)
mask = make_mask(
segment_ids,
segment_ids,
segment_pos,
segment_pos,
AttnMaskType.PADDING_CAUSAL_BOTTOM_RIGHT_MASK,
window_size,
)
assert mask.dtype == jnp.bool_

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Assertion misses deprecated alias

This assertion checks only the final mask dtype, which is boolean after the logical mask operations whether make_swa_mask receives jnp.bool or jnp.bool_; restoring the deprecated argument therefore leaves this regression test passing.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!



@jax.jit
def get_seqlens_and_offsets(segment_ids):
batch, max_seqlen = segment_ids.shape
Expand Down