fix: remove redundant self-assignment out_ = out_ - #3367
Conversation
Greptile SummaryThis PR prevents the context-parallel attention test helper from clearing an absent softmax-offset gradient during inference and removes a redundant assignment.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Important Files Changed
Reviews (7): Last reviewed commit: "Merge branch 'main' into codequality/run..." | Re-trigger Greptile |
| @pytest.mark.skipif(not torch.cuda.is_available(), reason="CUDA not available") | ||
| def test_softmax_offset_grad_none_in_eval(): |
There was a problem hiding this comment.
Regression test omitted from CI
The QA jobs enumerate test files explicitly, but none includes this new test, so CI silently skips the intended inference regression coverage.
Knowledge Base Used: Tests and QA
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!
cyanguwa
left a comment
There was a problem hiding this comment.
The changes in run_attention_with_cp.py looks good, but the test test_softmax_offset_inference.py is probably unnecessary. The regular CI should test out the changes if any of them breaks anything. Thanks.
cb09267 to
3b8c96b
Compare
|
@greptile-apps thanks for the review. I have addressed the blocking feedback in this PR:
The branch has been amended to a single signed-off commit (3b8c96b) and force-pushed. Local pytest was not feasible because |
|
Good progress on addressing the feedback. A few things to note on the current state:
The docstring correctly identifies the bug: assert not core_attn.softmax_offset.requires_grad # will fail: requires_grad is still TrueThis test will likely fail as written. The assertion should check what the docstring describes: That directly validates the original crash condition and accurately documents what the fix prevents. The Minor scope note: the PR description only mentions removing Tip: You can customize Greptile's behavior for this repo with |
e58b6a7 to
f3f7e6d
Compare
…eroing in eval mode - Remove the no-op `out_ = out_` self-assignment in run_attention_with_cp.py. - Gate the `softmax_offset.grad.zero_()` call on `is_training` so eval mode no longer crashes. - Add regression test verifying softmax_offset.grad stays None in eval mode. - Register the new test in qa/L0_pytorch_unittest/test.sh. Signed-off-by: andrewwhitecdw <andrewwhitecdw@users.noreply.github.com>
4b1811a to
52191b5
Compare
|
@greptile-apps Thanks for the follow-up. I fixed the assertion in |
|
The fixes look correct. A few quick notes:
Overall the PR is clean. The three changes (dead assignment removal, guard for inference mode, regression tests) are well-scoped and the test accurately reflects the failure mode. LGTM. |
…undant-self-assignment-out-out
This PR fixes two issues in the context-parallel attention helper and adds regression coverage.
Changes
tests/pytorch/attention/run_attention_with_cp.py:out_ = out_in the THD forward-only branch.softmax_offset.grad.zero_()onis_trainingso eval mode no longer crashes whensoftmax_offset.gradisNone.tests/pytorch/attention/test_softmax_offset_inference.py:softmax_offset.gradstaysNonein eval mode.qa/L0_pytorch_unittest/test.sh:Details
Tests
tests/pytorch/attention/test_softmax_offset_inference.py::test_softmax_offset_grad_none_in_evalqa/L0_pytorch_unittest/test.shpython -m py_compilepassed; full pytest was not feasible because Transformer Engine is not installed in this environment.Contributor guidelines