-
Notifications
You must be signed in to change notification settings - Fork 24.7k
Description
🐛 Describe the bug
while torch.compile a function which contains nested function, throw "NestedUserFunctionVariable() has no type"
caused by "validate_args_and_maybe_create_graph_inputs" trying to access "a.python_type()".
Error logs
V0723 08:39:33.809000 139640270866432 torch/_dynamo/convert_frame.py:652] [0/0] torchdynamo start compiling f /software/users/jianma/qnpu/pt/src/minimal.py:813, stack (elided 5 frames):
V0723 08:39:33.809000 139640270866432 torch/_dynamo/convert_frame.py:652] [0/0] File "/software/users/jianma/qnpu/pt/src/minimal.py", line 1054, in
V0723 08:39:33.809000 139640270866432 torch/_dynamo/convert_frame.py:652] [0/0] eval(f"{sys.argv[1]}({sys.argv[2:]})")
V0723 08:39:33.809000 139640270866432 torch/_dynamo/convert_frame.py:652] [0/0] File "", line 1, in
V0723 08:39:33.809000 139640270866432 torch/_dynamo/convert_frame.py:652] [0/0] File "/software/users/jianma/qnpu/pt/src/minimal.py", line 821, in nest_func
V0723 08:39:33.809000 139640270866432 torch/_dynamo/convert_frame.py:652] [0/0] out = f(x)
V0723 08:39:33.809000 139640270866432 torch/_dynamo/convert_frame.py:652] [0/0] File "/software/users/jianma/venv/lib/python3.10/site-packages/torch/_dynamo/eval_frame.py", line 451, in _fn
V0723 08:39:33.809000 139640270866432 torch/_dynamo/convert_frame.py:652] [0/0] return fn(*args, **kwargs)
V0723 08:39:33.809000 139640270866432 torch/_dynamo/convert_frame.py:652] [0/0]
I0723 08:39:33.811000 139640270866432 torch/_dynamo/logging.py:55] [0/0] Step 1: torchdynamo start tracing f /software/users/jianma/qnpu/pt/src/minimal.py:813
V0723 08:39:33.811000 139640270866432 torch/fx/experimental/symbolic_shapes.py:1980] [0/0] create_env
V0723 08:39:33.815000 139640270866432 torch/_dynamo/symbolic_convert.py:704] [0/0] [__trace_source] TRACE starts_line /software/users/jianma/qnpu/pt/src/minimal.py:813 in f (nest_func.f)
V0723 08:39:33.815000 139640270866432 torch/_dynamo/symbolic_convert.py:704] [0/0] [__trace_source] def f(x):
V0723 08:39:33.834000 139640270866432 torch/_dynamo/symbolic_convert.py:704] [0/0] [__trace_source] TRACE starts_line /software/users/jianma/qnpu/pt/src/minimal.py:814 in f (nest_func.f)
V0723 08:39:33.834000 139640270866432 torch/_dynamo/symbolic_convert.py:704] [0/0] [__trace_source] x = x.sin().sin()
V0723 08:39:33.834000 139640270866432 torch/_dynamo/symbolic_convert.py:730] [0/0] TRACE LOAD_FAST x []
V0723 08:39:33.834000 139640270866432 torch/_dynamo/symbolic_convert.py:730] [0/0] TRACE LOAD_ATTR sin [LazyVariableTracker()]
V0723 08:39:33.835000 139640270866432 torch/dynamo/output_graph.py:1959] [0/0] create_graph_input L_x L['x']
V0723 08:39:33.836000 139640270866432 torch/_dynamo/variables/builder.py:1873] [0/0] wrap_to_fake L['x'] (2,) StatefulSymbolicContext(dynamic_sizes=[<DimDynamic.STATIC: 2>], constraint_sizes=[None], view_base_context=None, tensor_source=LocalSource(local_name='x', cell_or_freevar=False), shape_env_to_source_to_symbol_cache={}) <class 'torch.Tensor'>
V0723 08:39:33.837000 139640270866432 torch/_dynamo/symbolic_convert.py:730] [0/0] TRACE CALL_FUNCTION 0 [GetAttrVariable()]
V0723 08:39:33.839000 139640270866432 torch/_dynamo/symbolic_convert.py:730] [0/0] TRACE LOAD_ATTR sin [TensorVariable()]
V0723 08:39:33.839000 139640270866432 torch/_dynamo/symbolic_convert.py:730] [0/0] TRACE CALL_FUNCTION 0 [GetAttrVariable()]
V0723 08:39:33.840000 139640270866432 torch/_dynamo/symbolic_convert.py:730] [0/0] TRACE STORE_FAST x [TensorVariable()]
V0723 08:39:33.840000 139640270866432 torch/_dynamo/symbolic_convert.py:704] [0/0] [__trace_source] TRACE starts_line /software/users/jianma/qnpu/pt/src/minimal.py:815 in f (nest_func.f)
V0723 08:39:33.840000 139640270866432 torch/_dynamo/symbolic_convert.py:704] [0/0] [__trace_source] x = CheckpointFunction.apply(f1(), False, x)
V0723 08:39:33.840000 139640270866432 torch/_dynamo/symbolic_convert.py:730] [0/0] TRACE LOAD_DEREF CheckpointFunction []
V0723 08:39:33.840000 139640270866432 torch/_dynamo/symbolic_convert.py:730] [0/0] TRACE LOAD_ATTR apply [LazyVariableTracker()]
V0723 08:39:33.841000 139640270866432 torch/_dynamo/symbolic_convert.py:730] [0/0] TRACE LOAD_DEREF f1 [GetAttrVariable()]
V0723 08:39:33.841000 139640270866432 torch/_dynamo/symbolic_convert.py:730] [0/0] TRACE CALL_FUNCTION 0 [GetAttrVariable(), LazyVariableTracker()]
V0723 08:39:33.845000 139640270866432 torch/_dynamo/symbolic_convert.py:2321] [0/0] INLINING <code object f1 at 0x7f0088678450, file "/software/users/jianma/qnpu/pt/src/minimal.py", line 808>, inlined according trace_rules.lookup
V0723 08:39:33.845000 139640270866432 torch/_dynamo/symbolic_convert.py:704] [0/0] [__trace_source] TRACE starts_line /software/users/jianma/qnpu/pt/src/minimal.py:808 in f1 (nest_func.f1) (inline depth: 1)
V0723 08:39:33.845000 139640270866432 torch/_dynamo/symbolic_convert.py:704] [0/0] [__trace_source] def f1():
V0723 08:39:33.846000 139640270866432 torch/_dynamo/symbolic_convert.py:704] [0/0] [__trace_source] TRACE starts_line /software/users/jianma/qnpu/pt/src/minimal.py:809 in f1 (nest_func.f1.nest) (inline depth: 1)
V0723 08:39:33.846000 139640270866432 torch/_dynamo/symbolic_convert.py:704] [0/0] [__trace_source] def nest(x):
V0723 08:39:33.846000 139640270866432 torch/_dynamo/symbolic_convert.py:730] [0/0] TRACE LOAD_CONST <code object nest at 0x7f00886783a0, file "/software/users/jianma/qnpu/pt/src/minimal.py", line 809> []
V0723 08:39:33.846000 139640270866432 torch/_dynamo/symbolic_convert.py:730] [0/0] TRACE LOAD_CONST nest_func..f1..nest [ConstantVariable()]
V0723 08:39:33.846000 139640270866432 torch/_dynamo/symbolic_convert.py:730] [0/0] TRACE MAKE_FUNCTION 0 [ConstantVariable(), ConstantVariable()]
V0723 08:39:33.846000 139640270866432 torch/_dynamo/symbolic_convert.py:730] [0/0] TRACE STORE_FAST nest [NestedUserFunctionVariable()]
V0723 08:39:33.846000 139640270866432 torch/_dynamo/symbolic_convert.py:704] [0/0] [__trace_source] TRACE starts_line /software/users/jianma/qnpu/pt/src/minimal.py:811 in f1 (nest_func.f1) (inline depth: 1)
V0723 08:39:33.846000 139640270866432 torch/_dynamo/symbolic_convert.py:704] [0/0] [__trace_source] return nest
V0723 08:39:33.846000 139640270866432 torch/_dynamo/symbolic_convert.py:730] [0/0] TRACE LOAD_FAST nest []
V0723 08:39:33.846000 139640270866432 torch/_dynamo/symbolic_convert.py:730] [0/0] TRACE RETURN_VALUE None [NestedUserFunctionVariable()]
V0723 08:39:33.846000 139640270866432 torch/_dynamo/symbolic_convert.py:2366] [0/0] DONE INLINING <code object f1 at 0x7f0088678450, file "/software/users/jianma/qnpu/pt/src/minimal.py", line 808>
V0723 08:39:33.846000 139640270866432 torch/_dynamo/symbolic_convert.py:730] [0/0] TRACE LOAD_CONST False [GetAttrVariable(), NestedUserFunctionVariable()]
V0723 08:39:33.846000 139640270866432 torch/_dynamo/symbolic_convert.py:730] [0/0] TRACE LOAD_FAST x [GetAttrVariable(), NestedUserFunctionVariable(), ConstantVariable()]
V0723 08:39:33.847000 139640270866432 torch/_dynamo/symbolic_convert.py:730] [0/0] TRACE CALL_FUNCTION 3 [GetAttrVariable(), NestedUserFunctionVariable(), ConstantVariable(), TensorVariable()]
V0723 08:39:33.847000 139640270866432 torch/_dynamo/output_graph.py:1959] [0/0] create_graph_input function_ctx (none)
NestedUserFunctionVariable() has no type
from user code:
File "/software/users/jianma/qnpu/pt/src/minimal.py", line 815, in f
x = CheckpointFunction.apply(f1(), False, x)
You can suppress this exception and fall back to eager by setting:
import torch._dynamo
torch._dynamo.config.suppress_errors = True
Minified repro
from torch.utils.checkpoint import CheckpointFunction
def f1():
def nest(x):
return x.sin()
return nest
def f(x):
x = x.sin().sin()
x = CheckpointFunction.apply(f1(), False, x)
out = x.sin().sin()
return out
f = torch.compile(f, backend="eager")
x = torch.ones(2, requires_grad=True)
out = f(x)
print(out
Versions
Collecting environment information...
PyTorch version: 2.3.1a0+git2e6e8ac
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A
OS: Ubuntu 22.04 LTS (x86_64)
GCC version: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Clang version: 14.0.5 (ssh://gerrit.habana-labs.com:29418/tpc_llvm10 5c14ad98599a55bb4e469f99400fa7623e83c4a0)
CMake version: version 3.22.1
Libc version: glibc-2.35
Python version: 3.10.12 (main, Mar 22 2024, 16:50:05) [GCC 11.4.0] (64-bit runtime)
Python platform: Linux-5.15.0-113-generic-x86_64-with-glibc2.35
Is CUDA available: False
CUDA runtime version: No CUDA
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True
CPU:
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Address sizes: 43 bits physical, 48 bits virtual
Byte Order: Little Endian
CPU(s): 12
On-line CPU(s) list: 0-11
Vendor ID: GenuineIntel
Model name: Intel(R) Xeon(R) Gold 6132 CPU @ 2.60GHz
CPU family: 6
Model: 85
Thread(s) per core: 1
Core(s) per socket: 6
Socket(s): 2
Stepping: 0
BogoMIPS: 5187.81
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon nopl xtopology tsc_reliable nonstop_tsc cpuid tsc_known_freq pni pclmulqdq vmx ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 invpcid avx512f avx512dq rdseed adx smap clflushopt clwb avx512cd avx512bw avx512vl xsaveopt xsavec xsaves arat pku ospke md_clear flush_l1d arch_capabilities
Virtualization: VT-x
Hypervisor vendor: VMware
Virtualization type: full
L1d cache: 384 KiB (12 instances)
L1i cache: 384 KiB (12 instances)
L2 cache: 12 MiB (12 instances)
L3 cache: 38.5 MiB (2 instances)
NUMA node(s): 1
NUMA node0 CPU(s): 0-11
Vulnerability Gather data sampling: Unknown: Dependent on hypervisor status
Vulnerability Itlb multihit: KVM: Mitigation: VMX disabled
Vulnerability L1tf: Mitigation; PTE Inversion; VMX flush not necessary, SMT disabled
Vulnerability Mds: Mitigation; Clear CPU buffers; SMT Host state unknown
Vulnerability Meltdown: Mitigation; PTI
Vulnerability Mmio stale data: Mitigation; Clear CPU buffers; SMT Host state unknown
Vulnerability Retbleed: Mitigation; IBRS
Vulnerability Spec rstack overflow: Not affected
Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl and seccomp
Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2: Mitigation; IBRS; IBPB conditional; STIBP disabled; RSB filling; PBRSB-eIBRS Not affected; BHI Syscall hardening, KVM SW loop
Vulnerability Srbds: Not affected
Vulnerability Tsx async abort: Not affected
Versions of relevant libraries:
[pip3] habana-torch-dataloader==1.18.0.5
[pip3] habana-torch-plugin==1.18.0.5
[pip3] numpy==1.26.4
[pip3] torch==2.3.1a0+git2e6e8ac
[pip3] torch_tb_profiler==0.4.0
[pip3] torchaudio==2.3.0+952ea74
[pip3] torchdata==0.7.1+5e6f7b7
[pip3] torchtext==0.18.0a0+9bed85d
[pip3] torchvision==0.18.1a0+fe70bc8
[conda] Could not collect
cc @ezyang @chauhang @penguinwu @voznesenskym @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @chenyang78 @kadeng @amjames @anijain2305