fix: remove redundant self-assignment out_ = out_ - #3367
Conversation
Squashed to single commit for review. Original PR: #11
Greptile SummaryThe PR guards softmax-offset gradient clearing so it occurs only during training and removes a redundant output self-assignment. It also adds a focused eval-mode regression test. Confidence Score: 3/5The PR is not yet safe to merge because the regression test fails on CUDA systems and the new file fails the mandatory license check. The test still supplies an unsupported softmax type, leaving Files Needing Attention: tests/pytorch/attention/test_softmax_offset_inference.py Important Files Changed
Reviews (2): Last reviewed commit: "[pre-commit.ci] auto fixes from pre-comm..." | Re-trigger Greptile |
| core_attn = DotProductAttention( | ||
| 8, (64, 64), num_gqa_groups=4, softmax_type="softmax_offset" | ||
| ).cuda().eval() |
There was a problem hiding this comment.
Unsupported softmax type breaks test
When this test runs on a CUDA-enabled system, softmax_type="softmax_offset" does not match any supported initialization branch, so softmax_offset is not initialized and the subsequent requires_grad access fails instead of testing eval behavior.
| core_attn = DotProductAttention( | |
| 8, (64, 64), num_gqa_groups=4, softmax_type="softmax_offset" | |
| ).cuda().eval() | |
| core_attn = DotProductAttention( | |
| 8, (64, 64), num_gqa_groups=4, softmax_type="learnable" | |
| ).cuda().eval() |
Knowledge Base Used: Tests and QA
| import pytest | ||
| import torch | ||
| from transformer_engine.pytorch import DotProductAttention |
There was a problem hiding this comment.
The new Python file omits the required NVIDIA copyright and license notices, causing the repository's L0 license checker to reject it.
| import pytest | |
| import torch | |
| from transformer_engine.pytorch import DotProductAttention | |
| # Copyright (c) 2022-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | |
| # | |
| # See LICENSE for license information. | |
| import pytest | |
| import torch | |
| from transformer_engine.pytorch import DotProductAttention |
Knowledge Base Used: Tests and QA
| @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!
for more information, see https://pre-commit.ci
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.
This PR addresses the following issue in
tests/pytorch/attention/run_attention_with_cp.py: remove redundant self-assignment out_ = out_.Changes
tests/pytorch/attention/run_attention_with_cp.py: remove redundant self-assignment out_ = out_.Details
Tests
tests/pytorch/attention/test_redundant_self_assignment.py