fix(attention test): give the mask tests the axis rules the cp gate reads - #5134
Open
gulsumgudukbay wants to merge 1 commit into
Open
fix(attention test): give the mask tests the axis rules the cp gate reads#5134gulsumgudukbay wants to merge 1 commit into
gulsumgudukbay wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates several unit tests in tests/unit/attention_test.py to support Ulysses context sharding and logical axis rules. Specifically, it adds ulysses_context_sharding and activation_q_length axis rules to the test configurations, and wraps the AttentionOp initialization and mask generation within the nn_partitioning.axis_rules context manager. I have no feedback to provide as there are no review comments to evaluate.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…eads These three tests build a 2- or 4-device context mesh and assert that the mask is derived from the load-balanced `segment_positions`. That path is guarded by `_load_balanced_context_parallel()`, which sizes cp by resolving `activation_q_length` against the *ambient* flax rules - deliberately, so eval under `logical_axis_rules_for_eval` cannot claim an order the loader never applied. The tests never enter an `axis_rules` context, so the logical name resolves to `P(None)`, cp_size comes out as 1, load balancing is skipped and the op returns a plain index-order causal mask. Declare the `activation_q_length` rule and wrap the op in it, as the rest of the suite does. Also set `ulysses_context_sharding`, which the cp-size computation reads once the query axis actually resolves. Only a host with 2+ visible devices runs these (they skip otherwise), so CI has not been executing them.
gulsumgudukbay
force-pushed
the
fix-attention-mask-tests-axis-rules
branch
from
September 4, 2026 04:25
57c8908 to
54f6f52
Compare
gulsumgudukbay
marked this pull request as ready for review
September 4, 2026 04:43
gulsumgudukbay
requested review from
A9isha,
NuojCheng,
RissyRan,
SurbhiJainUSC,
abhinavclemson,
aireenmei,
bvandermoon,
darisoy,
dipannita08,
gagika,
gobbleturk,
hengtaoguo,
huytransformer,
igorts-git,
jiangjy1982,
khatwanimohit,
richjames0,
shralex,
shuningjin,
vipannalla and
xibinliu
as code owners
September 4, 2026 04:43
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Three mask tests build a 2- or 4-device context mesh and assert the mask is derived from the load-balanced
segment_positions. That path is guarded by_load_balanced_context_parallel(), which sizes cp by resolvingactivation_q_lengthagainst the ambient flax rules - deliberately, so that eval running underlogical_axis_rules_for_evalcannot claim a DUAL_CHUNK_SWAP order the input pipeline never applied.The tests never enter an
axis_rulescontext, so the logical name resolves toP(None),cp_sizecomes out as 1, load balancing is skipped, and the op returns a plain index-order causal mask while the tests still expect the position-aware one. This makes theactivation_q_lengthrule ambient around the op, the way the rest of the suite does, and setsulysses_context_sharding, which the cp-size computation reads once the query axis actually resolves.In the two
LoadBalancedMaskTestcases only that one rule is made ambient rather than the whole stub config: those configs also declaresegment_ids_batch -> context, which was inert while nothing made it ambient, and cannot hold here becausegenerate_attention_maskwould shard their batch-1 segment ids across the 4-way context mesh.These tests skip unless 2+ devices are visible, and they are auto-marked
cpu_onlyso the 4-GPUgpu-unitjob deselects them - which is why CI has not been executing them at all.Tests
Reproduce the failure on
mainand the fix on this branch with:Verified on 4x AMD Instinct MI355X (ROCm 10, jax 0.11.1): the three tests fail on
main(plain causal mask,then an
IndivisibleErroronce the rule resolves) and pass on this branch. The fulltests/unit/attention_test.pyfile also passes there (72 passed, 82 skipped, 11 subtests passed).
Checklist
gemini-reviewlabel.