test: pin Llama3 TurboAttention GQA layout (PRPUNDIT-20) - #1090
test: pin Llama3 TurboAttention GQA layout (PRPUNDIT-20)#1090jiagaoxiang wants to merge 1 commit into
Conversation
Closes PRPUNDIT-20. inner_attention must see unrepeated KV heads in BSHD; the mirror must still route through wo.
There was a problem hiding this comment.
🟡 Changes recommended
One test hard-codes global head counts despite the implementation explicitly inferring local heads for tensor-parallel sharding, which can cause false failures in valid configurations.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds unit coverage to pin the expected tensor layout and argument forwarding in the Primus LLaMA3 TurboAttention Attention.forward mirror, ensuring GQA KV heads are not expanded externally and that RoPE positions and wo projection routing remain intact.
Changes:
- Adds
tests/unit_tests/backends/torchtitan/test_llama3_turbo_attention.pywith stubs/spies to isolate and validate the mirrorforwardbehavior. - Verifies unrepeated KV head shapes (BSHD),
positionsforwarding intoapply_rotary_emb, and that outputs still pass throughAttention.wo.
File summaries
| File | Description |
|---|---|
| tests/unit_tests/backends/torchtitan/test_llama3_turbo_attention.py | New unit tests to lock in Primus LLaMA3 TurboAttention mirror forward layout and API behavior. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| assert stub.shapes["xq_shape"] == (bs, seqlen, llama3_args.n_heads, head_dim) | ||
| # GQA: kv heads stay at n_kv_heads, i.e. NOT repeated up to n_heads. | ||
| assert stub.shapes["xk_shape"] == (bs, seqlen, llama3_args.n_kv_heads, head_dim) | ||
| assert stub.shapes["xv_shape"] == (bs, seqlen, llama3_args.n_kv_heads, head_dim) |
|
TestIntel PR Steward: Looked at the failed The Docker image itself builds fine (all layers cached, image exported successfully). The job then fails at: i.e. the registry password is empty. That's consistent with GitHub Actions withholding repo secrets from Flagging for a maintainer to address at the workflow/secrets level (e.g. skip registry push for fork PRs, or use Also replied on the Copilot review thread re: the GQA head-count assertion. |
jiagaoxiang
left a comment
There was a problem hiding this comment.
Replying to Copilot's finding on the GQA head-count assertion.
| assert stub.shapes["xq_shape"] == (bs, seqlen, llama3_args.n_heads, head_dim) | ||
| # GQA: kv heads stay at n_kv_heads, i.e. NOT repeated up to n_heads. | ||
| assert stub.shapes["xk_shape"] == (bs, seqlen, llama3_args.n_kv_heads, head_dim) | ||
| assert stub.shapes["xv_shape"] == (bs, seqlen, llama3_args.n_kv_heads, head_dim) |
There was a problem hiding this comment.
TestIntel PR Steward: Thanks — I looked at whether this test can actually see the failure mode you describe.
This test instantiates Attention(llama3_args) directly with no tensor-parallel mesh or sharding applied anywhere in the test (no DeviceMesh, no parallelize_module, no distributed process group). wq/wk/wv are therefore always built with the global n_heads/n_kv_heads from llama3_args, so xq.view(bs, seqlen, -1, head_dim) always resolves to llama3_args.n_heads here — the -1 and the global arg are the same number in this unit test's scope. So the assertions against llama3_args.n_heads/n_kv_heads are correct for what this test actually exercises.
Deriving the expected counts from wq(x)/wk(x)/wv(x) shapes instead would be a defensive nice-to-have (guards against a future test that does add TP sharding), but it doesn't change correctness today, and this PR's scope is pinning the existing GQA-layout behavior for the test gap (PRPUNDIT-20), not adding TP coverage. Leaving the assertions as-is; happy to revisit if a follow-up test adds actual sharded execution.
|
Superseded by same-repo PR #1103 (head |
This PR was created by dougljia via Test Gap Resolver.
Summary
tests/unit_tests/backends/torchtitan/test_llama3_turbo_attention.py.inner_attentionas annn.Moduleand assert unrepeated KV heads in BSHD (norepeat_kv/ BHSD transpose),positionsforwarded to RoPE, and that output still goes throughwo.Closes test gap PRPUNDIT-20.
Test plan
PYTHONPATH=. pytest tests/unit_tests/backends/torchtitan/test_llama3_turbo_attention.py(5 passed, CPU, needs torchtitan)black --check/isort --profile blackon the new file