-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[NVIDIA] Relax the requirement for providing both query_seq_lengths
and key_value_seq_lengths
#23415
Conversation
Also, @sbodenstein for review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a regression test for #23349, please?
jax/_src/nn/functions.py
Outdated
kv_indices = jnp.arange(0, S)[None, None, :] | ||
q_mask = q_indices < q_seqlen[:, None, None] | ||
kv_mask = kv_indices < kv_seqlen[:, None, None] | ||
q_mask = jnp.array(True, dtype=jnp.bool_) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you do jnp.bool_(True)
or just True
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed.
tests/nn_test.py
Outdated
@@ -122,7 +122,6 @@ def testDotProductAttentionMask(self, mask_mode): | |||
|
|||
is_causal = 'causal' in mask_mode | |||
if 'padding' in mask_mode: | |||
q_seqlen = jnp.array([T // 2, T // 4], dtype=jnp.int32) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this change necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
12d93a4
to
2d2cbbc
Compare
LGTM |
This PR addresses an issue where the original
nn.dot_product_attention
required bothquery_seq_lengths
andkey_value_seq_lengths
. With this update, users can now provide only one of these lengths, thereby relaxing the previous requirement.This is motivated by this issue.
cc. @superbobry