pytorch - 💡(How to fix) Fix [aot_autograd] RuntimeError: Cannot call numel() on tensor with symbolic sizes/strides in _convolution_double_backward when using torch.compile(dynamic=True) with torch.func.grad over ConvTranspose2d [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
pytorch/pytorch#181175Fetched 2026-04-23 07:22:09
View on GitHub
Comments
0
Participants
1
Timeline
67
Reactions
0
Participants
Timeline (top)
mentioned ×30subscribed ×30labeled ×7

Error Message

Error logs

/home/.venv/lib/python3.10/site-packages/torch/autograd/graph.py:869: UserWarning: Error detected in ConvolutionBackwardBackward0. Traceback of forward call that caused the error: Previous calculation was induced by ConvolutionBackward0. Traceback of forward call that induced the previous calculation: Traceback (most recent call last): Exception raised from throw_cannot_call_with_symbolic at /pytorch/c10/core/TensorImpl.cpp:289 (most recent call first): frame #0: c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) + 0x9d (0x7c87b137305d in /home/.venv/lib/python3.10/site-packages/torch/lib/libc10.so)

Fix Action

Fix / Workaround

Previous calculation was induced by ConvolutionBackward0. Traceback of forward call that induced the previous calculation: File "/home/.venv/lib/python3.10/site-packages/torch/_functorch/apis.py", line 433, in wrapper return eager_transforms.grad_impl(func, argnums, has_aux, args, kwargs) File "/home/.venv/lib/python3.10/site-packages/torch/_functorch/eager_transforms.py", line 1506, in grad_impl results = grad_and_value_impl(func, argnums, has_aux, args, kwargs) File "/home/.venv/lib/python3.10/site-packages/torch/_functorch/vmap.py", line 56, in fn return f(*args, **kwargs) File "/home/.venv/lib/python3.10/site-packages/torch/_functorch/eager_transforms.py", line 1457, in grad_and_value_impl output = func(*args, **kwargs) File "/home/bugs/crash_3c0ff967_reporting.py", line 44, in _fn_grad_106941 t3759182 = _m_t3759182(t3759174) (Triggered internally at /pytorch/torch/csrc/autograd/python_anomaly_mode.cpp:129.) return Variable._execution_engine.run_backward( # Calls into the C++ engine to run the backward pass Traceback (most recent call last): File "/home/bugs/crash_3c0ff967_reporting.py", line 55, in <module> _fgrad_dynamic = torch.compile(_torch_func.grad(_fn_grad_106941), dynamic=True)(t3759172) File "/home/.venv/lib/python3.10/site-packages/torch/_dynamo/eval_frame.py", line 1038, in compile_wrapper raise e.remove_dynamo_frames() from None # see TORCHDYNAMO_VERBOSE=1 File "/home/.venv/lib/python3.10/site-packages/torch/_dynamo/eval_frame.py", line 1024, in compile_wrapper return fn(*args, **kwargs) File "/home/.venv/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 2316, in call result = self._torchdynamo_orig_backend( File "/home/.venv/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 2052, in call result = self._inner_convert( File "/home/.venv/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 729, in call result = _compile( File "/home/.venv/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 1827, in _compile guarded_code, tracer_output = compile_inner(code, one_graph, hooks) File "/home/.venv/lib/python3.10/site-packages/torch/_utils_internal.py", line 96, in wrapper_function return function(*args, **kwargs) File "/home/.venv/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 1500, in compile_inner return _compile_inner(code, one_graph, hooks) File "/home/.venv/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 1534, in _compile_inner dynamo_output = compile_frame( File "/home/.venv/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 1408, in compile_frame bytecode, tracer_output = transform_code_object(code, transform) File "/home/.venv/lib/python3.10/site-packages/torch/_dynamo/bytecode_transformation.py", line 1608, in transform_code_object tracer_output = transformations(instructions, code_options) File "/home/.venv/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 1380, in transform tracer_output = trace_frame( File "/home/.venv/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 341, in _fn return fn(*args, **kwargs) File "/home/.venv/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 863, in trace_frame run_tracer() File "/home/.venv/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 844, in run_tracer tracer.run() File "/home/.venv/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 1794, in run while self.step(): File "/home/.venv/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 1459, in step self.dispatch_table[inst.opcode](self, inst) File "/home/.venv/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 5570, in RETURN_VALUE self._return(inst) File "/home/.venv/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 5552, in _return all_stack_locals_metadata = self.output.compile_subgraph( File "/home/.venv/lib/python3.10/site-packages/torch/_dynamo/output_graph.py", line 1889, in compile_subgraph self.compile_and_call_fx_graph(tx, pass2.graph_output_vars(), root) File "/home/.venv/lib/python3.10/site-packages/torch/_dynamo/output_graph.py", line 2460, in compile_and_call_fx_graph compiled_fn = self.call_user_compiler(gm, self.example_inputs()) File "/home/.venv/lib/python3.10/site-packages/torch/_dynamo/output_graph.py", line 2613, in call_user_compiler return self._call_user_compiler(gm, example_inputs) File "/home/.venv/lib/python3.10/site-packages/torch/_dynamo/output_graph.py", line 2689, in _call_user_compiler raise BackendCompilerFailed( File "/home/.venv/lib/python3.10/site-packages/torch/_dynamo/output_graph.py", line 2664, in call_user_compiler compiled_fn = compiler_fn(gm, example_inputs) File "/home/.venv/lib/python3.10/site-packages/torch/dynamo/repro/after_dynamo.py", line 156, in call compiled_gm = compiler_fn(gm, example_inputs) File "/home/.venv/lib/python3.10/site-packages/torch/init.py", line 2461, in call return compile_fx(model, inputs, config_patches=self.config) File "/home/.venv/lib/python3.10/site-packages/torch/_inductor/compile_fx.py", line 2578, in compile_fx return _maybe_wrap_and_compile_fx_main( File "/home/.venv/lib/python3.10/site-packages/torch/_inductor/compile_fx.py", line 2655, in _maybe_wrap_and_compile_fx_main return _compile_fx_main( File "/home/.venv/lib/python3.10/site-packages/torch/_inductor/compile_fx.py", line 2850, in _compile_fx_main return aot_autograd( File "/home/.venv/lib/python3.10/site-packages/torch/_dynamo/backends/common.py", line 124, in call cg = aot_module_simplified(gm, example_inputs, **self.kwargs) File "/home/.venv/lib/python3.10/site-packages/torch/_functorch/aot_autograd.py", line 1160, in aot_module_simplified aot_graph_capture = aot_stage1_graph_capture(aot_state, functional_call) File "/home/.venv/lib/python3.10/site-packages/torch/_functorch/_aot_autograd/graph_compile.py", line 223, in aot_stage1_graph_capture ) = aot_dispatch_autograd_graph( File "/home/.venv/lib/python3.10/site-packages/torch/_functorch/_aot_autograd/graph_capture.py", line 482, in aot_dispatch_autograd_graph fx_g = _create_graph( File "/home/.venv/lib/python3.10/site-packages/torch/_functorch/_aot_autograd/graph_capture.py", line 96, in _create_graph fx_g = make_fx( File "/home/.venv/lib/python3.10/site-packages/torch/fx/experimental/proxy_tensor.py", line 2824, in wrapped return make_fx_tracer.trace(f, *args) File "/home/.venv/lib/python3.10/site-packages/torch/fx/experimental/proxy_tensor.py", line 2725, in trace return self._trace_inner(f, *args) File "/home/.venv/lib/python3.10/site-packages/torch/fx/experimental/proxy_tensor.py", line 2686, in _trace_inner t = dispatch_trace( File "/home/.venv/lib/python3.10/site-packages/torch/_compile.py", line 54, in inner return disable_fn(*args, **kwargs) File "/home/.venv/lib/python3.10/site-packages/torch/_dynamo/eval_frame.py", line 1263, in _fn return fn(*args, **kwargs) File "/home/.venv/lib/python3.10/site-packages/torch/fx/experimental/proxy_tensor.py", line 1533, in dispatch_trace graph = tracer.trace(root, concrete_args) # type: ignore[arg-type] File "/home/.venv/lib/python3.10/site-packages/torch/_dynamo/eval_frame.py", line 1263, in _fn return fn(*args, **kwargs) File "/home/.venv/lib/python3.10/site-packages/torch/fx/_symbolic_trace.py", line 890, in trace (self.create_arg(fn(*args)),), File "/home/.venv/lib/python3.10/site-packages/torch/fx/_symbolic_trace.py", line 735, in flatten_fn tree_out = root_fn(*tree_args) File "/home/.venv/lib/python3.10/site-packages/torch/fx/experimental/proxy_tensor.py", line 1603, in wrapped out = f(*tensors) # type:ignore[call-arg] File "/home/.venv/lib/python3.10/site-packages/torch/_functorch/_aot_autograd/graph_capture.py", line 79, in inner_f out, out_descs = call_and_expect_output_descs(f, args) File "/home/.venv/lib/python3.10/site-packages/torch/_functorch/_aot_autograd/utils.py", line 785, in call_and_expect_output_descs outs_pair = fn(*args) File "/home/.venv/lib/python3.10/site-packages/torch/_functorch/_aot_autograd/graph_capture_wrappers.py", line 1215, in inner_fn outs, outs_descs = call_and_expect_output_descs(fn, args) File "/home/.venv/lib/python3.10/site-packages/torch/_functorch/_aot_autograd/utils.py", line 785, in call_and_expect_output_descs outs_pair = fn(*args) File "/home/.venv/lib/python3.10/site-packages/torch/_functorch/_aot_autograd/graph_capture_wrappers.py", line 1157, in joint_helper return _functionalized_f_helper(primals, tangents) File "/home/.venv/lib/python3.10/site-packages/torch/_functorch/_aot_autograd/graph_capture_wrappers.py", line 892, in _functionalized_f_helper f_outs, f_outs_descs = call_and_expect_output_descs(fn, f_args) File "/home/.venv/lib/python3.10/site-packages/torch/_functorch/_aot_autograd/utils.py", line 785, in call_and_expect_output_descs outs_pair = fn(*args) File "/home/.venv/lib/python3.10/site-packages/torch/_functorch/_aot_autograd/graph_capture_wrappers.py", line 495, in joint_helper return inner_fn_with_anomaly(primals, tangents) File "/home/.venv/lib/python3.10/site-packages/torch/_functorch/_aot_autograd/graph_capture_wrappers.py", line 487, in inner_fn_with_anomaly return inner_fn(primals, tangents) File "/home/.venv/lib/python3.10/site-packages/torch/_functorch/_aot_autograd/graph_capture_wrappers.py", line 451, in inner_fn backward_out = torch.autograd.grad( File "/home/.venv/lib/python3.10/site-packages/torch/autograd/init.py", line 481, in grad return handle_torch_function( File "/home/.venv/lib/python3.10/site-packages/torch/overrides.py", line 1741, in handle_torch_function result = mode.torch_function(public_api, types, args, kwargs) File "/home/.venv/lib/python3.10/site-packages/torch/fx/experimental/proxy_tensor.py", line 1654, in torch_function return func(*args, kwargs) File "/home/.venv/lib/python3.10/site-packages/torch/autograd/init.py", line 532, in grad result = _engine_run_backward( File "/home/.venv/lib/python3.10/site-packages/torch/autograd/graph.py", line 869, in _engine_run_backward return Variable._execution_engine.run_backward( # Calls into the C++ engine to run the backward pass torch._dynamo.exc.BackendCompilerFailed: backend='inductor' raised: RuntimeError: Cannot call numel() on tensor with symbolic sizes/strides Exception raised from throw_cannot_call_with_symbolic at /pytorch/c10/core/TensorImpl.cpp:289 (most recent call first): frame #0: c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) + 0x9d (0x7c87b137305d in /home/.venv/lib/python3.10/site-packages/torch/lib/libc10.so) frame #1: c10::TensorImpl::throw_cannot_call_with_symbolic(char const) const + 0x8b (0x7c87b1305f73 in /home/.venv/lib/python3.10/site-packages/torch/lib/libc10.so) frame #2: c10::TensorImpl::numel_custom() const + 0x9c (0x7c87b134c3cc in /home/.venv/lib/python3.10/site-packages/torch/lib/libc10.so) frame #3: at::native::_convolution_double_backward(std::optionalat::Tensor const&, std::optionalat::Tensor const&, std::optionalat::Tensor const&, at::Tensor const&, at::Tensor const&, at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool, c10::ArrayRef<long>, long, std::array<bool, 3ul>) + 0x1d06 (0x7c871ba10936 in /home/.venv/lib/python3.10/site-packages/torch/lib/libtorch_cpu.so) frame #4: <unknown function> + 0x3395e64 (0x7c871cf95e64 in /home/.venv/lib/python3.10/site-packages/torch/lib/libtorch_cpu.so) frame #5: <unknown function> + 0x76a9ca (0x7c872fb6a9ca in /home/.venv/lib/python3.10/site-packages/torch/lib/libtorch_python.so) frame #6: <unknown function> + 0x1c54bc1 (0x7c871b854bc1 in /home/.venv/lib/python3.10/site-packages/torch/lib/libtorch_cpu.so) frame #7: <unknown function> + 0x76a9ca (0x7c872fb6a9ca in /home/.venv/lib/python3.10/site-packages/torch/lib/libtorch_python.so) frame #8: <unknown function> + 0x2f0ad3a (0x7c871cb0ad3a in /home/.venv/lib/python3.10/site-packages/torch/lib/libtorch_cpu.so) frame #9: at::_ops::_convolution_double_backward::call(std::optionalat::Tensor const&, std::optionalat::Tensor const&, std::optionalat::Tensor const&, at::Tensor const&, at::Tensor const&, at::Tensor const&, c10::ArrayRefc10::SymInt, c10::ArrayRefc10::SymInt, c10::ArrayRefc10::SymInt, bool, c10::ArrayRefc10::SymInt, c10::SymInt, std::array<bool, 3ul>) + 0x723 (0x7c871cacf6d3 in /home/.venv/lib/python3.10/site-packages/torch/lib/libtorch_cpu.so) frame #10: <unknown function> + 0x514cd40 (0x7c871ed4cd40 in /home/.venv/lib/python3.10/site-packages/torch/lib/libtorch_cpu.so) frame #11: torch::autograd::generated::ConvolutionBackwardBackward0::apply(std::vector<at::Tensor, std::allocatorat::Tensor >&&) + 0x1b5 (0x7c871ed4d445 in /home/.venv/lib/python3.10/site-packages/torch/lib/libtorch_cpu.so) frame #12: <unknown function> + 0x5e52eeb (0x7c871fa52eeb in /home/.venv/lib/python3.10/site-packages/torch/lib/libtorch_cpu.so) frame #13: torch::autograd::Engine::evaluate_function(std::shared_ptrtorch::autograd::GraphTask&, torch::autograd::Node, torch::autograd::InputBuffer&, std::shared_ptrtorch::autograd::ReadyQueue const&) + 0x956 (0x7c871fa4c1f6 in /home/.venv/lib/python3.10/site-packages/torch/lib/libtorch_cpu.so) frame #14: torch::autograd::Engine::thread_main(std::shared_ptrtorch::autograd::GraphTask const&) + 0x5c9 (0x7c871fa4d689 in /home/.venv/lib/python3.10/site-packages/torch/lib/libtorch_cpu.so) frame #15: torch::autograd::Engine::execute_with_graph_task(std::shared_ptrtorch::autograd::GraphTask const&, std::shared_ptrtorch::autograd::Node, torch::autograd::InputBuffer&&) + 0x423 (0x7c871fa482d3 in /home/.venv/lib/python3.10/site-packages/torch/lib/libtorch_cpu.so) frame #16: <unknown function> + 0x813375 (0x7c872fc13375 in /home/.venv/lib/python3.10/site-packages/torch/lib/libtorch_python.so) frame #17: torch::autograd::Engine::execute(std::vector<torch::autograd::Edge, std::allocatortorch::autograd::Edge > const&, std::vector<at::Tensor, std::allocatorat::Tensor > const&, bool, bool, bool, std::vector<torch::autograd::Edge, std::allocatortorch::autograd::Edge > const&) + 0x755 (0x7c871fa4b0d5 in /home/.venv/lib/python3.10/site-packages/torch/lib/libtorch_cpu.so) frame #18: <unknown function> + 0x813306 (0x7c872fc13306 in /home/.venv/lib/python3.10/site-packages/torch/lib/libtorch_python.so) frame #19: <unknown function> + 0x813712 (0x7c872fc13712 in /home/.venv/lib/python3.10/site-packages/torch/lib/libtorch_python.so) <omitting python frames>

CPU: Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Address sizes: 52 bits physical, 57 bits virtual Byte Order: Little Endian CPU(s): 384 On-line CPU(s) list: 0-383 Vendor ID: AuthenticAMD Model name: AMD EPYC 9684X 96-Core Processor CPU family: 25 Model: 17 Thread(s) per core: 2 Core(s) per socket: 96 Socket(s): 2 Stepping: 2 BogoMIPS: 5099.98 Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good amd_lbr_v2 nopl nonstop_tsc cpuid extd_apicid aperfmperf rapl pni pclmulqdq monitor ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpb cat_l3 cdp_l3 hw_pstate ssbd mba perfmon_v2 ibrs ibpb stibp ibrs_enhanced vmmcall fsgsbase bmi1 avx2 smep bmi2 erms invpcid cqm rdt_a avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local user_shstk avx512_bf16 clzero irperf xsaveerptr rdpru wbnoinvd amd_ppin cppc amd_ibpb_ret arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload vgif x2avic v_spec_ctrl vnmi avx512vbmi umip pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg avx512_vpopcntdq la57 rdpid overflow_recov succor smca fsrm flush_l1d debug_swap ibpb_exit_to_user Virtualization: AMD-V L1d cache: 6 MiB (192 instances) L1i cache: 6 MiB (192 instances) L2 cache: 192 MiB (192 instances) L3 cache: 2.3 GiB (24 instances) NUMA node(s): 2 NUMA node0 CPU(s): 0-95,192-287 NUMA node1 CPU(s): 96-191,288-383 Vulnerability Gather data sampling: Not affected Vulnerability Itlb multihit: Not affected Vulnerability L1tf: Not affected Vulnerability Mds: Not affected Vulnerability Meltdown: Not affected Vulnerability Mmio stale data: Not affected Vulnerability Reg file data sampling: Not affected Vulnerability Retbleed: Not affected Vulnerability Spec rstack overflow: Mitigation; Safe RET Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization Vulnerability Spectre v2: Mitigation; Enhanced / Automatic IBRS; IBPB conditional; STIBP always-on; RSB filling; PBRSB-eIBRS Not affected; BHI Not affected Vulnerability Srbds: Not affected Vulnerability Tsx async abort: Not affected Vulnerability Vmscape: Mitigation; IBPB before exit to userspace

Code Example

import torch
import torch.nn as nn
import torch.func as _torch_func

_m_t3759174 = nn.BatchNorm2d(5).eval()
_m_t3759182 = nn.ConvTranspose2d(5, 2, 3)
_m_t3759183 = nn.MaxPool2d(2)

torch.manual_seed(0)
t3759172 = torch.randn([3, 5, 14, 15])

def fn(x):
    x = _m_t3759174(x)
    x = _m_t3759182(x)
    x = _m_t3759183(x)
    return torch.softmax(x, dim=0).mean()

# All of these work fine:
_torch_func.grad(fn)(t3759172)                          # eager grad
torch.compile(_torch_func.grad(fn))(t3759172)           # static compile
torch.compile(fn, dynamic=True)(t3759172)               # dynamic, no grad

# This crashes:
torch.compile(_torch_func.grad(fn), dynamic=True)(t3759172)
RAW_BUFFERClick to expand / collapse

🐛 Describe the bug

When composing torch.func.grad with torch.compile(dynamic=True) over a function containing nn.ConvTranspose2d, the inductor backend crashes during AOT autograd graph capture with RuntimeError: Cannot call numel() on tensor with symbolic sizes/strides. The same function works correctly under eager execution, static compilation (dynamic=False), and torch.func.grad without torch.compile.

import torch
import torch.nn as nn
import torch.func as _torch_func

_m_t3759174 = nn.BatchNorm2d(5).eval()
_m_t3759182 = nn.ConvTranspose2d(5, 2, 3)
_m_t3759183 = nn.MaxPool2d(2)

torch.manual_seed(0)
t3759172 = torch.randn([3, 5, 14, 15])

def fn(x):
    x = _m_t3759174(x)
    x = _m_t3759182(x)
    x = _m_t3759183(x)
    return torch.softmax(x, dim=0).mean()

# All of these work fine:
_torch_func.grad(fn)(t3759172)                          # eager grad
torch.compile(_torch_func.grad(fn))(t3759172)           # static compile
torch.compile(fn, dynamic=True)(t3759172)               # dynamic, no grad

# This crashes:
torch.compile(_torch_func.grad(fn), dynamic=True)(t3759172)

Error logs

/home/.venv/lib/python3.10/site-packages/torch/autograd/graph.py:869: UserWarning: Error detected in ConvolutionBackwardBackward0. Traceback of forward call that caused the error: File "/home/.venv/lib/python3.10/site-packages/torch/_functorch/apis.py", line 433, in wrapper return eager_transforms.grad_impl(func, argnums, has_aux, args, kwargs) File "/home/.venv/lib/python3.10/site-packages/torch/_functorch/eager_transforms.py", line 1506, in grad_impl results = grad_and_value_impl(func, argnums, has_aux, args, kwargs) File "/home/.venv/lib/python3.10/site-packages/torch/_functorch/vmap.py", line 56, in fn return f(*args, **kwargs) File "/home/.venv/lib/python3.10/site-packages/torch/_functorch/eager_transforms.py", line 1483, in grad_and_value_impl flat_grad_input = _autograd_grad( (Triggered internally at /pytorch/torch/csrc/autograd/python_anomaly_mode.cpp:122.) return Variable._execution_engine.run_backward( # Calls into the C++ engine to run the backward pass /home/.venv/lib/python3.10/site-packages/torch/autograd/graph.py:869: UserWarning:

Previous calculation was induced by ConvolutionBackward0. Traceback of forward call that induced the previous calculation: File "/home/.venv/lib/python3.10/site-packages/torch/_functorch/apis.py", line 433, in wrapper return eager_transforms.grad_impl(func, argnums, has_aux, args, kwargs) File "/home/.venv/lib/python3.10/site-packages/torch/_functorch/eager_transforms.py", line 1506, in grad_impl results = grad_and_value_impl(func, argnums, has_aux, args, kwargs) File "/home/.venv/lib/python3.10/site-packages/torch/_functorch/vmap.py", line 56, in fn return f(*args, **kwargs) File "/home/.venv/lib/python3.10/site-packages/torch/_functorch/eager_transforms.py", line 1457, in grad_and_value_impl output = func(*args, **kwargs) File "/home/bugs/crash_3c0ff967_reporting.py", line 44, in _fn_grad_106941 t3759182 = _m_t3759182(t3759174) (Triggered internally at /pytorch/torch/csrc/autograd/python_anomaly_mode.cpp:129.) return Variable._execution_engine.run_backward( # Calls into the C++ engine to run the backward pass Traceback (most recent call last): File "/home/bugs/crash_3c0ff967_reporting.py", line 55, in <module> _fgrad_dynamic = torch.compile(_torch_func.grad(_fn_grad_106941), dynamic=True)(t3759172) File "/home/.venv/lib/python3.10/site-packages/torch/_dynamo/eval_frame.py", line 1038, in compile_wrapper raise e.remove_dynamo_frames() from None # see TORCHDYNAMO_VERBOSE=1 File "/home/.venv/lib/python3.10/site-packages/torch/_dynamo/eval_frame.py", line 1024, in compile_wrapper return fn(*args, **kwargs) File "/home/.venv/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 2316, in call result = self._torchdynamo_orig_backend( File "/home/.venv/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 2052, in call result = self._inner_convert( File "/home/.venv/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 729, in call result = _compile( File "/home/.venv/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 1827, in _compile guarded_code, tracer_output = compile_inner(code, one_graph, hooks) File "/home/.venv/lib/python3.10/site-packages/torch/_utils_internal.py", line 96, in wrapper_function return function(*args, **kwargs) File "/home/.venv/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 1500, in compile_inner return _compile_inner(code, one_graph, hooks) File "/home/.venv/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 1534, in _compile_inner dynamo_output = compile_frame( File "/home/.venv/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 1408, in compile_frame bytecode, tracer_output = transform_code_object(code, transform) File "/home/.venv/lib/python3.10/site-packages/torch/_dynamo/bytecode_transformation.py", line 1608, in transform_code_object tracer_output = transformations(instructions, code_options) File "/home/.venv/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 1380, in transform tracer_output = trace_frame( File "/home/.venv/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 341, in _fn return fn(*args, **kwargs) File "/home/.venv/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 863, in trace_frame run_tracer() File "/home/.venv/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 844, in run_tracer tracer.run() File "/home/.venv/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 1794, in run while self.step(): File "/home/.venv/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 1459, in step self.dispatch_table[inst.opcode](self, inst) File "/home/.venv/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 5570, in RETURN_VALUE self._return(inst) File "/home/.venv/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 5552, in _return all_stack_locals_metadata = self.output.compile_subgraph( File "/home/.venv/lib/python3.10/site-packages/torch/_dynamo/output_graph.py", line 1889, in compile_subgraph self.compile_and_call_fx_graph(tx, pass2.graph_output_vars(), root) File "/home/.venv/lib/python3.10/site-packages/torch/_dynamo/output_graph.py", line 2460, in compile_and_call_fx_graph compiled_fn = self.call_user_compiler(gm, self.example_inputs()) File "/home/.venv/lib/python3.10/site-packages/torch/_dynamo/output_graph.py", line 2613, in call_user_compiler return self._call_user_compiler(gm, example_inputs) File "/home/.venv/lib/python3.10/site-packages/torch/_dynamo/output_graph.py", line 2689, in _call_user_compiler raise BackendCompilerFailed( File "/home/.venv/lib/python3.10/site-packages/torch/_dynamo/output_graph.py", line 2664, in call_user_compiler compiled_fn = compiler_fn(gm, example_inputs) File "/home/.venv/lib/python3.10/site-packages/torch/dynamo/repro/after_dynamo.py", line 156, in call compiled_gm = compiler_fn(gm, example_inputs) File "/home/.venv/lib/python3.10/site-packages/torch/init.py", line 2461, in call return compile_fx(model, inputs, config_patches=self.config) File "/home/.venv/lib/python3.10/site-packages/torch/_inductor/compile_fx.py", line 2578, in compile_fx return _maybe_wrap_and_compile_fx_main( File "/home/.venv/lib/python3.10/site-packages/torch/_inductor/compile_fx.py", line 2655, in _maybe_wrap_and_compile_fx_main return _compile_fx_main( File "/home/.venv/lib/python3.10/site-packages/torch/_inductor/compile_fx.py", line 2850, in _compile_fx_main return aot_autograd( File "/home/.venv/lib/python3.10/site-packages/torch/_dynamo/backends/common.py", line 124, in call cg = aot_module_simplified(gm, example_inputs, **self.kwargs) File "/home/.venv/lib/python3.10/site-packages/torch/_functorch/aot_autograd.py", line 1160, in aot_module_simplified aot_graph_capture = aot_stage1_graph_capture(aot_state, functional_call) File "/home/.venv/lib/python3.10/site-packages/torch/_functorch/_aot_autograd/graph_compile.py", line 223, in aot_stage1_graph_capture ) = aot_dispatch_autograd_graph( File "/home/.venv/lib/python3.10/site-packages/torch/_functorch/_aot_autograd/graph_capture.py", line 482, in aot_dispatch_autograd_graph fx_g = _create_graph( File "/home/.venv/lib/python3.10/site-packages/torch/_functorch/_aot_autograd/graph_capture.py", line 96, in _create_graph fx_g = make_fx( File "/home/.venv/lib/python3.10/site-packages/torch/fx/experimental/proxy_tensor.py", line 2824, in wrapped return make_fx_tracer.trace(f, *args) File "/home/.venv/lib/python3.10/site-packages/torch/fx/experimental/proxy_tensor.py", line 2725, in trace return self._trace_inner(f, *args) File "/home/.venv/lib/python3.10/site-packages/torch/fx/experimental/proxy_tensor.py", line 2686, in _trace_inner t = dispatch_trace( File "/home/.venv/lib/python3.10/site-packages/torch/_compile.py", line 54, in inner return disable_fn(*args, **kwargs) File "/home/.venv/lib/python3.10/site-packages/torch/_dynamo/eval_frame.py", line 1263, in _fn return fn(*args, **kwargs) File "/home/.venv/lib/python3.10/site-packages/torch/fx/experimental/proxy_tensor.py", line 1533, in dispatch_trace graph = tracer.trace(root, concrete_args) # type: ignore[arg-type] File "/home/.venv/lib/python3.10/site-packages/torch/_dynamo/eval_frame.py", line 1263, in _fn return fn(*args, **kwargs) File "/home/.venv/lib/python3.10/site-packages/torch/fx/_symbolic_trace.py", line 890, in trace (self.create_arg(fn(*args)),), File "/home/.venv/lib/python3.10/site-packages/torch/fx/_symbolic_trace.py", line 735, in flatten_fn tree_out = root_fn(*tree_args) File "/home/.venv/lib/python3.10/site-packages/torch/fx/experimental/proxy_tensor.py", line 1603, in wrapped out = f(*tensors) # type:ignore[call-arg] File "/home/.venv/lib/python3.10/site-packages/torch/_functorch/_aot_autograd/graph_capture.py", line 79, in inner_f out, out_descs = call_and_expect_output_descs(f, args) File "/home/.venv/lib/python3.10/site-packages/torch/_functorch/_aot_autograd/utils.py", line 785, in call_and_expect_output_descs outs_pair = fn(*args) File "/home/.venv/lib/python3.10/site-packages/torch/_functorch/_aot_autograd/graph_capture_wrappers.py", line 1215, in inner_fn outs, outs_descs = call_and_expect_output_descs(fn, args) File "/home/.venv/lib/python3.10/site-packages/torch/_functorch/_aot_autograd/utils.py", line 785, in call_and_expect_output_descs outs_pair = fn(*args) File "/home/.venv/lib/python3.10/site-packages/torch/_functorch/_aot_autograd/graph_capture_wrappers.py", line 1157, in joint_helper return _functionalized_f_helper(primals, tangents) File "/home/.venv/lib/python3.10/site-packages/torch/_functorch/_aot_autograd/graph_capture_wrappers.py", line 892, in _functionalized_f_helper f_outs, f_outs_descs = call_and_expect_output_descs(fn, f_args) File "/home/.venv/lib/python3.10/site-packages/torch/_functorch/_aot_autograd/utils.py", line 785, in call_and_expect_output_descs outs_pair = fn(*args) File "/home/.venv/lib/python3.10/site-packages/torch/_functorch/_aot_autograd/graph_capture_wrappers.py", line 495, in joint_helper return inner_fn_with_anomaly(primals, tangents) File "/home/.venv/lib/python3.10/site-packages/torch/_functorch/_aot_autograd/graph_capture_wrappers.py", line 487, in inner_fn_with_anomaly return inner_fn(primals, tangents) File "/home/.venv/lib/python3.10/site-packages/torch/_functorch/_aot_autograd/graph_capture_wrappers.py", line 451, in inner_fn backward_out = torch.autograd.grad( File "/home/.venv/lib/python3.10/site-packages/torch/autograd/init.py", line 481, in grad return handle_torch_function( File "/home/.venv/lib/python3.10/site-packages/torch/overrides.py", line 1741, in handle_torch_function result = mode.torch_function(public_api, types, args, kwargs) File "/home/.venv/lib/python3.10/site-packages/torch/fx/experimental/proxy_tensor.py", line 1654, in torch_function return func(*args, kwargs) File "/home/.venv/lib/python3.10/site-packages/torch/autograd/init.py", line 532, in grad result = _engine_run_backward( File "/home/.venv/lib/python3.10/site-packages/torch/autograd/graph.py", line 869, in _engine_run_backward return Variable._execution_engine.run_backward( # Calls into the C++ engine to run the backward pass torch._dynamo.exc.BackendCompilerFailed: backend='inductor' raised: RuntimeError: Cannot call numel() on tensor with symbolic sizes/strides Exception raised from throw_cannot_call_with_symbolic at /pytorch/c10/core/TensorImpl.cpp:289 (most recent call first): frame #0: c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) + 0x9d (0x7c87b137305d in /home/.venv/lib/python3.10/site-packages/torch/lib/libc10.so) frame #1: c10::TensorImpl::throw_cannot_call_with_symbolic(char const) const + 0x8b (0x7c87b1305f73 in /home/.venv/lib/python3.10/site-packages/torch/lib/libc10.so) frame #2: c10::TensorImpl::numel_custom() const + 0x9c (0x7c87b134c3cc in /home/.venv/lib/python3.10/site-packages/torch/lib/libc10.so) frame #3: at::native::_convolution_double_backward(std::optionalat::Tensor const&, std::optionalat::Tensor const&, std::optionalat::Tensor const&, at::Tensor const&, at::Tensor const&, at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool, c10::ArrayRef<long>, long, std::array<bool, 3ul>) + 0x1d06 (0x7c871ba10936 in /home/.venv/lib/python3.10/site-packages/torch/lib/libtorch_cpu.so) frame #4: <unknown function> + 0x3395e64 (0x7c871cf95e64 in /home/.venv/lib/python3.10/site-packages/torch/lib/libtorch_cpu.so) frame #5: <unknown function> + 0x76a9ca (0x7c872fb6a9ca in /home/.venv/lib/python3.10/site-packages/torch/lib/libtorch_python.so) frame #6: <unknown function> + 0x1c54bc1 (0x7c871b854bc1 in /home/.venv/lib/python3.10/site-packages/torch/lib/libtorch_cpu.so) frame #7: <unknown function> + 0x76a9ca (0x7c872fb6a9ca in /home/.venv/lib/python3.10/site-packages/torch/lib/libtorch_python.so) frame #8: <unknown function> + 0x2f0ad3a (0x7c871cb0ad3a in /home/.venv/lib/python3.10/site-packages/torch/lib/libtorch_cpu.so) frame #9: at::_ops::_convolution_double_backward::call(std::optionalat::Tensor const&, std::optionalat::Tensor const&, std::optionalat::Tensor const&, at::Tensor const&, at::Tensor const&, at::Tensor const&, c10::ArrayRefc10::SymInt, c10::ArrayRefc10::SymInt, c10::ArrayRefc10::SymInt, bool, c10::ArrayRefc10::SymInt, c10::SymInt, std::array<bool, 3ul>) + 0x723 (0x7c871cacf6d3 in /home/.venv/lib/python3.10/site-packages/torch/lib/libtorch_cpu.so) frame #10: <unknown function> + 0x514cd40 (0x7c871ed4cd40 in /home/.venv/lib/python3.10/site-packages/torch/lib/libtorch_cpu.so) frame #11: torch::autograd::generated::ConvolutionBackwardBackward0::apply(std::vector<at::Tensor, std::allocatorat::Tensor >&&) + 0x1b5 (0x7c871ed4d445 in /home/.venv/lib/python3.10/site-packages/torch/lib/libtorch_cpu.so) frame #12: <unknown function> + 0x5e52eeb (0x7c871fa52eeb in /home/.venv/lib/python3.10/site-packages/torch/lib/libtorch_cpu.so) frame #13: torch::autograd::Engine::evaluate_function(std::shared_ptrtorch::autograd::GraphTask&, torch::autograd::Node, torch::autograd::InputBuffer&, std::shared_ptrtorch::autograd::ReadyQueue const&) + 0x956 (0x7c871fa4c1f6 in /home/.venv/lib/python3.10/site-packages/torch/lib/libtorch_cpu.so) frame #14: torch::autograd::Engine::thread_main(std::shared_ptrtorch::autograd::GraphTask const&) + 0x5c9 (0x7c871fa4d689 in /home/.venv/lib/python3.10/site-packages/torch/lib/libtorch_cpu.so) frame #15: torch::autograd::Engine::execute_with_graph_task(std::shared_ptrtorch::autograd::GraphTask const&, std::shared_ptrtorch::autograd::Node, torch::autograd::InputBuffer&&) + 0x423 (0x7c871fa482d3 in /home/.venv/lib/python3.10/site-packages/torch/lib/libtorch_cpu.so) frame #16: <unknown function> + 0x813375 (0x7c872fc13375 in /home/.venv/lib/python3.10/site-packages/torch/lib/libtorch_python.so) frame #17: torch::autograd::Engine::execute(std::vector<torch::autograd::Edge, std::allocatortorch::autograd::Edge > const&, std::vector<at::Tensor, std::allocatorat::Tensor > const&, bool, bool, bool, std::vector<torch::autograd::Edge, std::allocatortorch::autograd::Edge > const&) + 0x755 (0x7c871fa4b0d5 in /home/.venv/lib/python3.10/site-packages/torch/lib/libtorch_cpu.so) frame #18: <unknown function> + 0x813306 (0x7c872fc13306 in /home/.venv/lib/python3.10/site-packages/torch/lib/libtorch_python.so) frame #19: <unknown function> + 0x813712 (0x7c872fc13712 in /home/.venv/lib/python3.10/site-packages/torch/lib/libtorch_python.so) <omitting python frames>

Versions

Collecting environment information... PyTorch version: 2.11.0+cu130 Is debug build: False CUDA used to build PyTorch: 13.0 ROCM used to build PyTorch: N/A

OS: Ubuntu 22.04.5 LTS (x86_64) GCC version: (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0 Clang version: 15.0.0 ([email protected]:llvm/llvm-project.git 4ba6a9c9f65bbc8bd06e3652cb20fd4dfc846137) CMake version: version 3.22.1 Libc version: glibc-2.35

Python version: 3.10.12 (main, Mar 3 2026, 11:56:32) [GCC 11.4.0] (64-bit runtime) Python platform: Linux-6.8.0-94-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 Is XPU available: False HIP runtime version: N/A MIOpen runtime version: N/A Is XNNPACK available: True Caching allocator config: N/A

CPU: Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Address sizes: 52 bits physical, 57 bits virtual Byte Order: Little Endian CPU(s): 384 On-line CPU(s) list: 0-383 Vendor ID: AuthenticAMD Model name: AMD EPYC 9684X 96-Core Processor CPU family: 25 Model: 17 Thread(s) per core: 2 Core(s) per socket: 96 Socket(s): 2 Stepping: 2 BogoMIPS: 5099.98 Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good amd_lbr_v2 nopl nonstop_tsc cpuid extd_apicid aperfmperf rapl pni pclmulqdq monitor ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpb cat_l3 cdp_l3 hw_pstate ssbd mba perfmon_v2 ibrs ibpb stibp ibrs_enhanced vmmcall fsgsbase bmi1 avx2 smep bmi2 erms invpcid cqm rdt_a avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local user_shstk avx512_bf16 clzero irperf xsaveerptr rdpru wbnoinvd amd_ppin cppc amd_ibpb_ret arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload vgif x2avic v_spec_ctrl vnmi avx512vbmi umip pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg avx512_vpopcntdq la57 rdpid overflow_recov succor smca fsrm flush_l1d debug_swap ibpb_exit_to_user Virtualization: AMD-V L1d cache: 6 MiB (192 instances) L1i cache: 6 MiB (192 instances) L2 cache: 192 MiB (192 instances) L3 cache: 2.3 GiB (24 instances) NUMA node(s): 2 NUMA node0 CPU(s): 0-95,192-287 NUMA node1 CPU(s): 96-191,288-383 Vulnerability Gather data sampling: Not affected Vulnerability Itlb multihit: Not affected Vulnerability L1tf: Not affected Vulnerability Mds: Not affected Vulnerability Meltdown: Not affected Vulnerability Mmio stale data: Not affected Vulnerability Reg file data sampling: Not affected Vulnerability Retbleed: Not affected Vulnerability Spec rstack overflow: Mitigation; Safe RET Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization Vulnerability Spectre v2: Mitigation; Enhanced / Automatic IBRS; IBPB conditional; STIBP always-on; RSB filling; PBRSB-eIBRS Not affected; BHI Not affected Vulnerability Srbds: Not affected Vulnerability Tsx async abort: Not affected Vulnerability Vmscape: Mitigation; IBPB before exit to userspace

Versions of relevant libraries: [pip3] numpy==2.2.6 [pip3] nvidia-cublas==13.1.0.3 [pip3] nvidia-cuda-cupti==13.0.85 [pip3] nvidia-cuda-nvrtc==13.0.88 [pip3] nvidia-cuda-runtime==13.0.96 [pip3] nvidia-cudnn-cu13==9.19.0.56 [pip3] nvidia-cufft==12.0.0.61 [pip3] nvidia-curand==10.4.0.35 [pip3] nvidia-cusolver==12.0.4.66 [pip3] nvidia-cusparse==12.6.3.3 [pip3] nvidia-cusparselt-cu13==0.8.0 [pip3] nvidia-nccl-cu13==2.28.9 [pip3] nvidia-nvjitlink==13.0.88 [pip3] nvidia-nvtx==13.0.85 [pip3] torch==2.11.0 [pip3] triton==3.6.0 [conda] Could not collect

cc @chauhang @penguinwu @Chillee @samdow @kshitij12345 @ezyang @bobrenjc93 @aditvenk @laithsakka

extent analysis

TL;DR

The issue can be mitigated by avoiding the use of torch.compile with dynamic=True when composing torch.func.grad with functions containing nn.ConvTranspose2d, or by using static compilation.

Guidance

  • The error occurs due to the incompatibility of torch.compile with dynamic=True and torch.func.grad when used with nn.ConvTranspose2d.
  • To verify the issue, try running the code with torch.compile and dynamic=False to see if the error persists.
  • As a temporary workaround, consider using static compilation or avoiding the use of torch.compile with dynamic=True when composing torch.func.grad with functions containing nn.ConvTranspose2d.
  • The root cause of the issue seems to be related to the inductor backend and the way it handles symbolic tensor sizes and strides.

Example

No specific code example is provided as the issue seems to be related to the interaction between torch.compile, torch.func.grad, and nn.ConvTranspose2d. However, the code snippet in the issue description can be used to reproduce the error.

Notes

The issue is specific to PyTorch version 2.11.0 and may be resolved in future versions. The use of torch.compile with dynamic=True is still an experimental feature and may have limitations and compatibility issues with certain PyTorch modules.

Recommendation

Apply a workaround by using static compilation or avoiding the use of torch.compile with dynamic=True when composing torch.func.grad with functions containing nn.ConvTranspose2d, as this seems to be the most straightforward way to mitigate the issue.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

pytorch - 💡(How to fix) Fix [aot_autograd] RuntimeError: Cannot call numel() on tensor with symbolic sizes/strides in _convolution_double_backward when using torch.compile(dynamic=True) with torch.func.grad over ConvTranspose2d [1 participants]