You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@thunder.jitdeffn(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10):
# do not skip functionalization processa9+=1# do not drop arguments by dcereturna0+a1+a2+a3+a4+a5+a6+a7+a8+a9+a10args= [torch.zeros((), device='cuda') for_inrange(11)]
args[0] =args[1] =torch.zeros((2,), device='cuda')
fn(*args)
Traceback (most recent call last):
File "/opt/pytorch/lightning-thunder/mshinokawa/sandbox/debug.py", line 16, in <module>
fn(*args)
File "/opt/pytorch/lightning-thunder/thunder/__init__.py", line 717, in fn_
cache_entry, inps, pro_to_epi = get_computation_and_inputs(*args, **kwargs)
File "/opt/pytorch/lightning-thunder/thunder/core/langctxs.py", line 136, in _fn
result = fn(*args, **kwargs)
File "/opt/pytorch/lightning-thunder/thunder/__init__.py", line 219, in cache_info_wrapper
res = fn(*args, **kwargs)
File "/opt/pytorch/lightning-thunder/thunder/__init__.py", line 530, in get_computation_and_inputs
functionalize_inplace_ops(
File "/opt/pytorch/lightning-thunder/thunder/core/functionalization.py", line 884, in functionalize_inplace_ops
no_implicit_alias_trace, swap_map_for_aliases = replace_args_with_alias_map(computation_trace, alias_tensor_indices)
File "/opt/pytorch/lightning-thunder/thunder/core/functionalization.py", line 172, in replace_args_with_alias_map
reshaped_arg = prims.reshape.meta(arg, arg_to_replace.shape)
File "/opt/pytorch/lightning-thunder/thunder/core/langctxs.py", line 136, in _fn
result = fn(*args, **kwargs)
File "/opt/pytorch/lightning-thunder/thunder/core/prims.py", line 3167, in reshape_meta
utils.check(
File "/opt/pytorch/lightning-thunder/thunder/core/baseutils.py", line 107, in check
raise exception_type(s())
RuntimeError: Attempting to reshape a.shape=(2,) to shape=(), but a.numel=2 is different from the number of elements in shape, 1
_alias_tensor_of_args_kwargs_dict recognizes that the 0-th and the first arguments are aliases. The prologue trace reorders the arguments into (a0, a10, a1, a2, a3, a4, a5, a6, a7, a8, a9), so the functionalizer tries to resolve the alias between a0 and a10 and reshapes a0 into a10.shape.
The prologue returns the arguments in the order of f"[{idx}]", which is why a10 (=args[10]) is ordered before a1 (=args[1]). Variable names do not matter.
_alias_tensor_of_args_kwargs_dict
recognizes that the 0-th and the first arguments are aliases. The prologue trace reorders the arguments into(a0, a10, a1, a2, a3, a4, a5, a6, a7, a8, a9)
, so the functionalizer tries to resolve the alias betweena0
anda10
and reshapesa0
intoa10.shape
.prologue trace:
The text was updated successfully, but these errors were encountered: