Return the updated inp from seteitem_ - #2397
Merged
Merged
Conversation
crcrpar
force-pushed
the
return-setitem_-output
branch
from
August 6, 2025 05:00
71a3b20 to
fd2234e
Compare
Collaborator
|
I added this which is the source of the bug, and it should also be removed with this PR. |
The following trace
```
def higher_order_autograd_function_apply_brtuu(any5, t_0, t_1):
# <eval_with_key>.83:5: _set_grad_enabled = torch._C._set_grad_enabled(False); _set_grad_enabled = None
ltorch._set_grad_enabled_with_warning(False)
# <eval_with_key>.83:6: output = torch.zeros(4096, 32, 128, device = device(type='cuda', index=0), dtype = torch.bfloat16)
t2 = ltorch.zeros(4096, 32, 128, device=devices.Device("cuda:0"), dtype=torch.bfloat16) # t2: "cuda:0 bf16[4096, 32, 128] self._requires_grad=False"
# t2 = ltorch.full((4096, 32, 128), 0, device=devices.Device("cuda:0"), dtype=torch.bfloat16) # t2: "cuda:0 bf16[4096, 32, 128] self._requires_grad=False"
# t2 = prims.full((4096, 32, 128), 0, device=devices.Device("cuda:0"), dtype=dtypes.bfloat16) # t2: "cuda:0 bf16[4096, 32, 128] self._requires_grad=False"
# <eval_with_key>.83:8: _set_grad_enabled_1 = torch._C._set_grad_enabled(True); _set_grad_enabled_1 = None
(t0,) = prims.update_aliases((t2,))
t4 = ltorch.setitem_(t0, t_1, t_0) # t4: "cuda:0 bf16[4096, 32, 128] self._requires_grad=False"
# t3 = ltorch.setitem(t0, t_1, t_0) # t3: "cuda:0 bf16[4096, 32, 128] self._requires_grad=False"
# t3 = prims.copy_with_setitem(t0, t_1, t_0) # t3: "cuda:0 bf16[4096, 32, 128] self._requires_grad=False"
# t4 = prims.copy_(t3, t0, grad_enabled=False) # t4: "cuda:0 bf16[4096, 32, 128] self._requires_grad=False"
ltorch._set_grad_enabled_with_warning(True)
return (t4, [t_1])
```
seems to return `None` inside
https://github.com/Lightning-AI/lightning-thunder/blob/a7952e29bae925581d3bf7069d64386f4d888e00/thunder/core/jit_ext.py#L998-L1007
of `_general_jit_torch_ops_higher_order_autograd_function_apply` and the
cause seems to be that `ltorch.setitem_` has been a void function.
Signed-off-by: Masaki Kozuki <mkozuki@nvidia.com>
crcrpar
force-pushed
the
return-setitem_-output
branch
from
August 12, 2025 07:28
fd2234e to
38d6bde
Compare
t-vi
approved these changes
Aug 14, 2025
t-vi
left a comment
Collaborator
There was a problem hiding this comment.
Thank you @crcrpar @beverlylytle
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.
What does this PR do?
Fixes the bug I see when running "qihoo360/360Zhinao-7B-Base" model using
benchmark_peft.py:The following trace
seems to return
Noneinsidelightning-thunder/thunder/core/jit_ext.py
Lines 998 to 1007 in a7952e2
_general_jit_torch_ops_higher_order_autograd_function_applyand the cause seems to be thatltorch.setitem_has been a void function.