Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion thunder/core/jit_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,15 @@ def _generate_random_str_id() -> str:
length = 5
return "".join(secrets.choice(string.ascii_lowercase) for _ in range(length))

args_tensor_mask = unwrap(fwd_kwargs["args_tensor_mask"])
# NOTE: `args_tensor_mask` was removed in PyTorch PR #166788.
# https://github.com/pytorch/pytorch/pull/166788/
# For backwards compatibility with older PyTorch versions, we check if it exists.
# When not present, we assume all fwd_args are tensors.
Copy link

Copilot AI Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment states "When not present, we assume all fwd_args are tensors" but the implementation actually checks each argument to determine if it's a TensorProxy. The comment should be updated to accurately reflect what the code does: "When not present, we infer the tensor mask by checking if each argument is a TensorProxy".

Suggested change
# When not present, we assume all fwd_args are tensors.
# When not present, we infer the tensor mask by checking if each argument is a TensorProxy.

Copilot uses AI. Check for mistakes.
if "args_tensor_mask" in fwd_kwargs:
args_tensor_mask = unwrap(fwd_kwargs["args_tensor_mask"])
else:
# For new PyTorch versions without args_tensor_mask, treat all args as potential tensors
args_tensor_mask = tuple(isinstance(unwrap(arg), TensorProxy) for arg in fwd_args)
# TODO(crcrpar): Think about making use of `non_differentiable_idx`
# note that this key is quite new: https://github.com/pytorch/pytorch/pull/134087
# non_differentiable_idx = fwd_kwargs.get("non_differentiable_idx")
Expand Down
Loading