-
Notifications
You must be signed in to change notification settings - Fork 806
[JAX]: SBHD reorder skip uses original shape instead of swapped tensor #3373
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -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) | ||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Re-publishing my comment as it might have become stale as part of an earlier review due to recent commits pushed by @andrewwhitecdw I do not think this is needed as the original tests in TestReorderCausalLoadBalancing test() above do run SBHD. With your change to correctly get the seq_lens we should be good.
Suggested change
|
||||
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.
Good catch !
This change makes sense to me. I would like to think that the
mainbranch basically just skips in the next line due to this incorrect statement (as it would be incorrectly taking the batch value as the seq value) - this explains why our CI never caught this as a failure!I'd expect those incorrectly skipping tests to not be skipped with this change (and pass)
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.
I did some digging to figure how many and which tests might be skipping and this is the list. A cursory look at TE's CI from release 2.18 does show that these tests were indeed being skipped.
I'd expect these to not be skipped and passed after @andrewwhitecdw 's changes