pytorch - ✅(Solved) Fix [dynamo]repro_run should call compile_fx_inner with a deepcopy of mod to avoid in-place mutation [1 pull requests, 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#177122Fetched 2026-04-08 00:22:06
View on GitHub
Comments
0
Participants
1
Timeline
37
Reactions
0
Author
Participants
Timeline (top)
mentioned ×15subscribed ×15labeled ×5cross-referenced ×1

Error Message

Traceback (most recent call last): File "/usr/local/lib/python3.12/dist-packages/torch/fx/graph_module.py", line 400, in call return super(self.cls, obj).call(*args, **kwargs) # type: ignore[misc] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/dist-packages/torch/nn/modules/module.py", line 1775, in _wrapped_call_impl return self._call_impl(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/dist-packages/torch/nn/modules/module.py", line 1786, in _call_impl return forward_call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "<eval_with_key>.2", line 6, in forward getitem = _foreach_add[0]; getitem = None ~~~~~~~~~~~~^^^ TypeError: 'NoneType' object is not subscriptable

Call using an FX-traced Module, line 6 of the traced Module's generated forward function: _foreach_add = torch.ops.aten.foreach_add.Scalar([arg1_1, arg0_1, arg2_1, arg3_1, arg4_1, arg5_1, arg6_1, arg7_1, arg8_1, arg9_1, arg10_1, arg11_1, arg12_1, arg13_1, arg14_1, arg15_1, arg16_1, arg17_1], 1); arg1_1 = arg0_1 = arg2_1 = arg3_1 = arg4_1 = arg5_1 = arg6_1 = arg7_1 = arg8_1 = arg9_1 = arg10_1 = arg11_1 = arg12_1 = arg13_1 = arg14_1 = arg15_1 = arg16_1 = arg17_1 = None getitem = _foreach_add[0]; getitem = None

    getitem_1 = _foreach_add[1];  getitem_1 = None

    getitem_2 = _foreach_add[2];  getitem_2 = None

Traceback (most recent call last):
  File "/root/test.py", line 103, in <module>
    run_repro(mod, load_args, accuracy=True, command='run', save_dir=None, tracing_mode='real', check_str=None)
  File "/usr/local/lib/python3.12/dist-packages/torch/_dynamo/repro/after_aot.py", line 1235, in run_repro
    return COMMAND_FNS[options.command](options, mod, load_args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/torch/_dynamo/repro/after_aot.py", line 989, in repro_run
    if not same_two_models(
           ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/torch/_dynamo/debug_utils.py", line 415, in same_two_models
    ref = run_fwd_maybe_bwd(gm, example_inputs, only_fwd)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/torch/_dynamo/debug_utils.py", line 386, in run_fwd_maybe_bwd
    out = gm(args) if getattr(gm, "_boxed_call", False) else gm(*args)
                                                             ^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/torch/fx/graph_module.py", line 837, in call_wrapped
    return self._wrapped_call(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/torch/fx/graph_module.py", line 411, in __call__
    raise e.with_traceback(None)  # noqa: B904
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'NoneType' object is not subscriptable

Fix Action

Fix / Workaround

CPU: Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Address sizes: 46 bits physical, 57 bits virtual Byte Order: Little Endian CPU(s): 112 On-line CPU(s) list: 0-111 Vendor ID: GenuineIntel Model name: Intel(R) Xeon(R) Gold 6330 CPU @ 2.00GHz CPU family: 6 Model: 106 Thread(s) per core: 2 Core(s) per socket: 28 Socket(s): 2 Stepping: 6 Frequency boost: enabled CPU(s) scaling MHz: 34% CPU max MHz: 3100.0000 CPU min MHz: 800.0000 BogoMIPS: 4000.00 Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 invpcid_single ssbd mba ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid cqm rdt_a avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb intel_pt avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local wbnoinvd dtherm ida arat pln pts avx512vbmi umip pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg tme avx512_vpopcntdq rdpid md_clear pconfig flush_l1d arch_capabilities Virtualization: VT-x L1d cache: 2.6 MiB (56 instances) L1i cache: 1.8 MiB (56 instances) L2 cache: 70 MiB (56 instances) L3 cache: 84 MiB (2 instances) NUMA node(s): 2 NUMA node0 CPU(s): 0-27,56-83 NUMA node1 CPU(s): 28-55,84-111 Vulnerability Itlb multihit: Not affected Vulnerability L1tf: Not affected Vulnerability Mds: Not affected Vulnerability Meltdown: Not affected Vulnerability Mmio stale data: Vulnerable: Clear CPU buffers attempted, no microcode; SMT vulnerable Vulnerability Retbleed: 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; Enhanced IBRS, IBPB conditional, RSB filling, PBRSB-eIBRS SW sequence Vulnerability Srbds: Not affected Vulnerability Tsx async abort: Not affected

PR fix notes

PR #177123: fix(dynamo):repro_run should call compile_fx_inner with a deepcopy of mod to avoid in-place mutation

Description (problem / solution / changelog)

Fix https://github.com/pytorch/pytorch/issues/177122

cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @kadeng @chauhang @amjames @Lucaskabela @jataylo

Changed files

  • test/dynamo/test_after_aot.py (modified, +32/-1)
  • torch/_dynamo/repro/after_aot.py (modified, +2/-1)

Code Example

import sys
import os
import torch
import torch.fx as fx
import torch._inductor.inductor_prims
from torch import tensor, device
from torch.nn import *
from torch._dynamo.testing import rand_strided
from math import inf
SEED=100
torch.manual_seed(SEED)
torch.cuda.manual_seed(SEED)
torch.cuda.manual_seed_all(SEED)
torch.backends.cudnn.deterministic = True
torch.backends.cudnn.benchmark = False
    
class Repro(torch.nn.Module):
    def __init__(self) -> None:
        super().__init__()
    def forward(self, arg18_1, arg21_1, arg22_1, arg23_1, arg24_1, arg25_1, arg26_1, arg27_1, arg28_1, arg29_1, arg30_1, arg31_1, arg32_1, arg33_1, arg34_1, arg35_1, arg36_1, arg37_1):
        _foreach_add = torch.ops.aten._foreach_add.Scalar([arg21_1, arg18_1, arg22_1, arg23_1, arg24_1, arg25_1, arg26_1, arg27_1, arg28_1, arg29_1, arg30_1, arg31_1, arg32_1, arg33_1, arg34_1, arg35_1, arg36_1, arg37_1], 1)
        getitem = _foreach_add[0]
        getitem_1 = _foreach_add[1]
        getitem_2 = _foreach_add[2]
        getitem_3 = _foreach_add[3]
        getitem_4 = _foreach_add[4]
        getitem_5 = _foreach_add[5]
        getitem_6 = _foreach_add[6]
        getitem_7 = _foreach_add[7]
        getitem_8 = _foreach_add[8]
        getitem_9 = _foreach_add[9]
        getitem_10 = _foreach_add[10]
        getitem_11 = _foreach_add[11]
        getitem_12 = _foreach_add[12]
        getitem_13 = _foreach_add[13]
        getitem_14 = _foreach_add[14]
        getitem_15 = _foreach_add[15]
        getitem_16 = _foreach_add[16]
        getitem_17 = _foreach_add[17];  _foreach_add = None
        copy__18 = torch.ops.aten.copy_.default(arg18_1, getitem_1);  arg18_1 = getitem_1 = copy__18 = None
        copy__21 = torch.ops.aten.copy_.default(arg21_1, getitem);  arg21_1 = getitem = copy__21 = None
        copy__22 = torch.ops.aten.copy_.default(arg22_1, getitem_2);  arg22_1 = getitem_2 = copy__22 = None
        copy__23 = torch.ops.aten.copy_.default(arg23_1, getitem_3);  arg23_1 = getitem_3 = copy__23 = None
        copy__24 = torch.ops.aten.copy_.default(arg24_1, getitem_4);  arg24_1 = getitem_4 = copy__24 = None
        copy__25 = torch.ops.aten.copy_.default(arg25_1, getitem_5);  arg25_1 = getitem_5 = copy__25 = None
        copy__26 = torch.ops.aten.copy_.default(arg26_1, getitem_6);  arg26_1 = getitem_6 = copy__26 = None
        copy__27 = torch.ops.aten.copy_.default(arg27_1, getitem_7);  arg27_1 = getitem_7 = copy__27 = None
        copy__28 = torch.ops.aten.copy_.default(arg28_1, getitem_8);  arg28_1 = getitem_8 = copy__28 = None
        copy__29 = torch.ops.aten.copy_.default(arg29_1, getitem_9);  arg29_1 = getitem_9 = copy__29 = None
        copy__30 = torch.ops.aten.copy_.default(arg30_1, getitem_10);  arg30_1 = getitem_10 = copy__30 = None
        copy__31 = torch.ops.aten.copy_.default(arg31_1, getitem_11);  arg31_1 = getitem_11 = copy__31 = None
        copy__32 = torch.ops.aten.copy_.default(arg32_1, getitem_12);  arg32_1 = getitem_12 = copy__32 = None
        copy__33 = torch.ops.aten.copy_.default(arg33_1, getitem_13);  arg33_1 = getitem_13 = copy__33 = None
        copy__34 = torch.ops.aten.copy_.default(arg34_1, getitem_14);  arg34_1 = getitem_14 = copy__34 = None
        copy__35 = torch.ops.aten.copy_.default(arg35_1, getitem_15);  arg35_1 = getitem_15 = copy__35 = None
        copy__36 = torch.ops.aten.copy_.default(arg36_1, getitem_16);  arg36_1 = getitem_16 = copy__36 = None
        copy__37 = torch.ops.aten.copy_.default(arg37_1, getitem_17);  arg37_1 = getitem_17 = copy__37 = None
        return ()
def load_args(reader):
    buf18 = reader.storage(None, 4, device=device(type='cuda', index=0))
    reader.tensor(buf18, (), is_leaf=True)
    buf21 = reader.storage(None, 4, device=device(type='cuda', index=0))
    reader.tensor(buf21, (), is_leaf=True)
    buf22 = reader.storage(None, 4, device=device(type='cuda', index=0))
    reader.tensor(buf22, (), is_leaf=True)
    buf23 = reader.storage(None, 4, device=device(type='cuda', index=0))
    reader.tensor(buf23, (), is_leaf=True)
    buf24 = reader.storage(None, 4, device=device(type='cuda', index=0))
    reader.tensor(buf24, (), is_leaf=True)
    buf25 = reader.storage(None, 4, device=device(type='cuda', index=0))
    reader.tensor(buf25, (), is_leaf=True)
    buf26 = reader.storage(None, 4, device=device(type='cuda', index=0))
    reader.tensor(buf26, (), is_leaf=True)
    buf27 = reader.storage(None, 4, device=device(type='cuda', index=0))
    reader.tensor(buf27, (), is_leaf=True)
    buf28 = reader.storage(None, 4, device=device(type='cuda', index=0))
    reader.tensor(buf28, (), is_leaf=True)
    buf29 = reader.storage(None, 4, device=device(type='cuda', index=0))
    reader.tensor(buf29, (), is_leaf=True)
    buf30 = reader.storage(None, 4, device=device(type='cuda', index=0))
    reader.tensor(buf30, (), is_leaf=True)
    buf31 = reader.storage(None, 4, device=device(type='cuda', index=0))
    reader.tensor(buf31, (), is_leaf=True)
    buf32 = reader.storage(None, 4, device=device(type='cuda', index=0))
    reader.tensor(buf32, (), is_leaf=True)
    buf33 = reader.storage(None, 4, device=device(type='cuda', index=0))
    reader.tensor(buf33, (), is_leaf=True)
    buf34 = reader.storage(None, 4, device=device(type='cuda', index=0))
    reader.tensor(buf34, (), is_leaf=True)
    buf35 = reader.storage(None, 4, device=device(type='cuda', index=0))
    reader.tensor(buf35, (), is_leaf=True)
    buf36 = reader.storage(None, 4, device=device(type='cuda', index=0))
    reader.tensor(buf36, (), is_leaf=True)
    buf37 = reader.storage(None, 4, device=device(type='cuda', index=0))
    reader.tensor(buf37, (), is_leaf=True)

load_args._version = 0
mod = Repro().cuda()
if __name__ == '__main__':
    from torch._dynamo.repro.after_aot import run_repro
    with torch.no_grad():
        run_repro(mod, load_args, accuracy=True, command='run', save_dir=None, tracing_mode='real', check_str=None)

---

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/dist-packages/torch/fx/graph_module.py", line 400, in __call__
    return super(self.cls, obj).__call__(*args, **kwargs)  # type: ignore[misc]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/torch/nn/modules/module.py", line 1775, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/torch/nn/modules/module.py", line 1786, in _call_impl
    return forward_call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<eval_with_key>.2", line 6, in forward
    getitem = _foreach_add[0];  getitem = None
              ~~~~~~~~~~~~^^^
TypeError: 'NoneType' object is not subscriptable

Call using an FX-traced Module, line 6 of the traced Module's generated forward function:
    _foreach_add = torch.ops.aten._foreach_add_.Scalar([arg1_1, arg0_1, arg2_1, arg3_1, arg4_1, arg5_1, arg6_1, arg7_1, arg8_1, arg9_1, arg10_1, arg11_1, arg12_1, arg13_1, arg14_1, arg15_1, arg16_1, arg17_1], 1);  arg1_1 = arg0_1 = arg2_1 = arg3_1 = arg4_1 = arg5_1 = arg6_1 = arg7_1 = arg8_1 = arg9_1 = arg10_1 = arg11_1 = arg12_1 = arg13_1 = arg14_1 = arg15_1 = arg16_1 = arg17_1 = None
    getitem = _foreach_add[0];  getitem = None

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <--- HERE
    getitem_1 = _foreach_add[1];  getitem_1 = None

    getitem_2 = _foreach_add[2];  getitem_2 = None

Traceback (most recent call last):
  File "/root/test.py", line 103, in <module>
    run_repro(mod, load_args, accuracy=True, command='run', save_dir=None, tracing_mode='real', check_str=None)
  File "/usr/local/lib/python3.12/dist-packages/torch/_dynamo/repro/after_aot.py", line 1235, in run_repro
    return COMMAND_FNS[options.command](options, mod, load_args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/torch/_dynamo/repro/after_aot.py", line 989, in repro_run
    if not same_two_models(
           ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/torch/_dynamo/debug_utils.py", line 415, in same_two_models
    ref = run_fwd_maybe_bwd(gm, example_inputs, only_fwd)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/torch/_dynamo/debug_utils.py", line 386, in run_fwd_maybe_bwd
    out = gm(args) if getattr(gm, "_boxed_call", False) else gm(*args)
                                                             ^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/torch/fx/graph_module.py", line 837, in call_wrapped
    return self._wrapped_call(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/torch/fx/graph_module.py", line 411, in __call__
    raise e.with_traceback(None)  # noqa: B904
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'NoneType' object is not subscriptable
RAW_BUFFERClick to expand / collapse

🐛 Describe the bug

import sys
import os
import torch
import torch.fx as fx
import torch._inductor.inductor_prims
from torch import tensor, device
from torch.nn import *
from torch._dynamo.testing import rand_strided
from math import inf
SEED=100
torch.manual_seed(SEED)
torch.cuda.manual_seed(SEED)
torch.cuda.manual_seed_all(SEED)
torch.backends.cudnn.deterministic = True
torch.backends.cudnn.benchmark = False
    
class Repro(torch.nn.Module):
    def __init__(self) -> None:
        super().__init__()
    def forward(self, arg18_1, arg21_1, arg22_1, arg23_1, arg24_1, arg25_1, arg26_1, arg27_1, arg28_1, arg29_1, arg30_1, arg31_1, arg32_1, arg33_1, arg34_1, arg35_1, arg36_1, arg37_1):
        _foreach_add = torch.ops.aten._foreach_add.Scalar([arg21_1, arg18_1, arg22_1, arg23_1, arg24_1, arg25_1, arg26_1, arg27_1, arg28_1, arg29_1, arg30_1, arg31_1, arg32_1, arg33_1, arg34_1, arg35_1, arg36_1, arg37_1], 1)
        getitem = _foreach_add[0]
        getitem_1 = _foreach_add[1]
        getitem_2 = _foreach_add[2]
        getitem_3 = _foreach_add[3]
        getitem_4 = _foreach_add[4]
        getitem_5 = _foreach_add[5]
        getitem_6 = _foreach_add[6]
        getitem_7 = _foreach_add[7]
        getitem_8 = _foreach_add[8]
        getitem_9 = _foreach_add[9]
        getitem_10 = _foreach_add[10]
        getitem_11 = _foreach_add[11]
        getitem_12 = _foreach_add[12]
        getitem_13 = _foreach_add[13]
        getitem_14 = _foreach_add[14]
        getitem_15 = _foreach_add[15]
        getitem_16 = _foreach_add[16]
        getitem_17 = _foreach_add[17];  _foreach_add = None
        copy__18 = torch.ops.aten.copy_.default(arg18_1, getitem_1);  arg18_1 = getitem_1 = copy__18 = None
        copy__21 = torch.ops.aten.copy_.default(arg21_1, getitem);  arg21_1 = getitem = copy__21 = None
        copy__22 = torch.ops.aten.copy_.default(arg22_1, getitem_2);  arg22_1 = getitem_2 = copy__22 = None
        copy__23 = torch.ops.aten.copy_.default(arg23_1, getitem_3);  arg23_1 = getitem_3 = copy__23 = None
        copy__24 = torch.ops.aten.copy_.default(arg24_1, getitem_4);  arg24_1 = getitem_4 = copy__24 = None
        copy__25 = torch.ops.aten.copy_.default(arg25_1, getitem_5);  arg25_1 = getitem_5 = copy__25 = None
        copy__26 = torch.ops.aten.copy_.default(arg26_1, getitem_6);  arg26_1 = getitem_6 = copy__26 = None
        copy__27 = torch.ops.aten.copy_.default(arg27_1, getitem_7);  arg27_1 = getitem_7 = copy__27 = None
        copy__28 = torch.ops.aten.copy_.default(arg28_1, getitem_8);  arg28_1 = getitem_8 = copy__28 = None
        copy__29 = torch.ops.aten.copy_.default(arg29_1, getitem_9);  arg29_1 = getitem_9 = copy__29 = None
        copy__30 = torch.ops.aten.copy_.default(arg30_1, getitem_10);  arg30_1 = getitem_10 = copy__30 = None
        copy__31 = torch.ops.aten.copy_.default(arg31_1, getitem_11);  arg31_1 = getitem_11 = copy__31 = None
        copy__32 = torch.ops.aten.copy_.default(arg32_1, getitem_12);  arg32_1 = getitem_12 = copy__32 = None
        copy__33 = torch.ops.aten.copy_.default(arg33_1, getitem_13);  arg33_1 = getitem_13 = copy__33 = None
        copy__34 = torch.ops.aten.copy_.default(arg34_1, getitem_14);  arg34_1 = getitem_14 = copy__34 = None
        copy__35 = torch.ops.aten.copy_.default(arg35_1, getitem_15);  arg35_1 = getitem_15 = copy__35 = None
        copy__36 = torch.ops.aten.copy_.default(arg36_1, getitem_16);  arg36_1 = getitem_16 = copy__36 = None
        copy__37 = torch.ops.aten.copy_.default(arg37_1, getitem_17);  arg37_1 = getitem_17 = copy__37 = None
        return ()
def load_args(reader):
    buf18 = reader.storage(None, 4, device=device(type='cuda', index=0))
    reader.tensor(buf18, (), is_leaf=True)
    buf21 = reader.storage(None, 4, device=device(type='cuda', index=0))
    reader.tensor(buf21, (), is_leaf=True)
    buf22 = reader.storage(None, 4, device=device(type='cuda', index=0))
    reader.tensor(buf22, (), is_leaf=True)
    buf23 = reader.storage(None, 4, device=device(type='cuda', index=0))
    reader.tensor(buf23, (), is_leaf=True)
    buf24 = reader.storage(None, 4, device=device(type='cuda', index=0))
    reader.tensor(buf24, (), is_leaf=True)
    buf25 = reader.storage(None, 4, device=device(type='cuda', index=0))
    reader.tensor(buf25, (), is_leaf=True)
    buf26 = reader.storage(None, 4, device=device(type='cuda', index=0))
    reader.tensor(buf26, (), is_leaf=True)
    buf27 = reader.storage(None, 4, device=device(type='cuda', index=0))
    reader.tensor(buf27, (), is_leaf=True)
    buf28 = reader.storage(None, 4, device=device(type='cuda', index=0))
    reader.tensor(buf28, (), is_leaf=True)
    buf29 = reader.storage(None, 4, device=device(type='cuda', index=0))
    reader.tensor(buf29, (), is_leaf=True)
    buf30 = reader.storage(None, 4, device=device(type='cuda', index=0))
    reader.tensor(buf30, (), is_leaf=True)
    buf31 = reader.storage(None, 4, device=device(type='cuda', index=0))
    reader.tensor(buf31, (), is_leaf=True)
    buf32 = reader.storage(None, 4, device=device(type='cuda', index=0))
    reader.tensor(buf32, (), is_leaf=True)
    buf33 = reader.storage(None, 4, device=device(type='cuda', index=0))
    reader.tensor(buf33, (), is_leaf=True)
    buf34 = reader.storage(None, 4, device=device(type='cuda', index=0))
    reader.tensor(buf34, (), is_leaf=True)
    buf35 = reader.storage(None, 4, device=device(type='cuda', index=0))
    reader.tensor(buf35, (), is_leaf=True)
    buf36 = reader.storage(None, 4, device=device(type='cuda', index=0))
    reader.tensor(buf36, (), is_leaf=True)
    buf37 = reader.storage(None, 4, device=device(type='cuda', index=0))
    reader.tensor(buf37, (), is_leaf=True)

load_args._version = 0
mod = Repro().cuda()
if __name__ == '__main__':
    from torch._dynamo.repro.after_aot import run_repro
    with torch.no_grad():
        run_repro(mod, load_args, accuracy=True, command='run', save_dir=None, tracing_mode='real', check_str=None)

error message

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/dist-packages/torch/fx/graph_module.py", line 400, in __call__
    return super(self.cls, obj).__call__(*args, **kwargs)  # type: ignore[misc]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/torch/nn/modules/module.py", line 1775, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/torch/nn/modules/module.py", line 1786, in _call_impl
    return forward_call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<eval_with_key>.2", line 6, in forward
    getitem = _foreach_add[0];  getitem = None
              ~~~~~~~~~~~~^^^
TypeError: 'NoneType' object is not subscriptable

Call using an FX-traced Module, line 6 of the traced Module's generated forward function:
    _foreach_add = torch.ops.aten._foreach_add_.Scalar([arg1_1, arg0_1, arg2_1, arg3_1, arg4_1, arg5_1, arg6_1, arg7_1, arg8_1, arg9_1, arg10_1, arg11_1, arg12_1, arg13_1, arg14_1, arg15_1, arg16_1, arg17_1], 1);  arg1_1 = arg0_1 = arg2_1 = arg3_1 = arg4_1 = arg5_1 = arg6_1 = arg7_1 = arg8_1 = arg9_1 = arg10_1 = arg11_1 = arg12_1 = arg13_1 = arg14_1 = arg15_1 = arg16_1 = arg17_1 = None
    getitem = _foreach_add[0];  getitem = None

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <--- HERE
    getitem_1 = _foreach_add[1];  getitem_1 = None

    getitem_2 = _foreach_add[2];  getitem_2 = None

Traceback (most recent call last):
  File "/root/test.py", line 103, in <module>
    run_repro(mod, load_args, accuracy=True, command='run', save_dir=None, tracing_mode='real', check_str=None)
  File "/usr/local/lib/python3.12/dist-packages/torch/_dynamo/repro/after_aot.py", line 1235, in run_repro
    return COMMAND_FNS[options.command](options, mod, load_args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/torch/_dynamo/repro/after_aot.py", line 989, in repro_run
    if not same_two_models(
           ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/torch/_dynamo/debug_utils.py", line 415, in same_two_models
    ref = run_fwd_maybe_bwd(gm, example_inputs, only_fwd)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/torch/_dynamo/debug_utils.py", line 386, in run_fwd_maybe_bwd
    out = gm(args) if getattr(gm, "_boxed_call", False) else gm(*args)
                                                             ^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/torch/fx/graph_module.py", line 837, in call_wrapped
    return self._wrapped_call(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/torch/fx/graph_module.py", line 411, in __call__
    raise e.with_traceback(None)  # noqa: B904
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'NoneType' object is not subscriptable

Versions

Collecting environment information...

PyTorch version: 2.9.0a0+145a3a7bda.nv25.10 Is debug build: False CUDA used to build PyTorch: 13.0 ROCM used to build PyTorch: N/A

OS: Ubuntu 24.04.3 LTS (x86_64) GCC version: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0 Clang version: Could not collect CMake version: version 3.31.6 Libc version: glibc-2.39

Python version: 3.12.3 (main, Aug 14 2025, 17:47:21) [GCC 13.3.0] (64-bit runtime) Python platform: Linux-5.4.0-150-generic-x86_64-with-glibc2.39 Is CUDA available: True CUDA runtime version: 13.0.88 CUDA_MODULE_LOADING set to: LAZY GPU models and configuration: GPU 0: NVIDIA A100-PCIE-40GB Nvidia driver version: 570.133.20 cuDNN version: Probably one of the following: /usr/lib/x86_64-linux-gnu/libcudnn.so.9.14.0 /usr/lib/x86_64-linux-gnu/libcudnn_adv.so.9.14.0 /usr/lib/x86_64-linux-gnu/libcudnn_cnn.so.9.14.0 /usr/lib/x86_64-linux-gnu/libcudnn_engines_precompiled.so.9.14.0 /usr/lib/x86_64-linux-gnu/libcudnn_engines_runtime_compiled.so.9.14.0 /usr/lib/x86_64-linux-gnu/libcudnn_graph.so.9.14.0 /usr/lib/x86_64-linux-gnu/libcudnn_heuristic.so.9.14.0 /usr/lib/x86_64-linux-gnu/libcudnn_ops.so.9.14.0 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: 46 bits physical, 57 bits virtual Byte Order: Little Endian CPU(s): 112 On-line CPU(s) list: 0-111 Vendor ID: GenuineIntel Model name: Intel(R) Xeon(R) Gold 6330 CPU @ 2.00GHz CPU family: 6 Model: 106 Thread(s) per core: 2 Core(s) per socket: 28 Socket(s): 2 Stepping: 6 Frequency boost: enabled CPU(s) scaling MHz: 34% CPU max MHz: 3100.0000 CPU min MHz: 800.0000 BogoMIPS: 4000.00 Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 invpcid_single ssbd mba ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid cqm rdt_a avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb intel_pt avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local wbnoinvd dtherm ida arat pln pts avx512vbmi umip pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg tme avx512_vpopcntdq rdpid md_clear pconfig flush_l1d arch_capabilities Virtualization: VT-x L1d cache: 2.6 MiB (56 instances) L1i cache: 1.8 MiB (56 instances) L2 cache: 70 MiB (56 instances) L3 cache: 84 MiB (2 instances) NUMA node(s): 2 NUMA node0 CPU(s): 0-27,56-83 NUMA node1 CPU(s): 28-55,84-111 Vulnerability Itlb multihit: Not affected Vulnerability L1tf: Not affected Vulnerability Mds: Not affected Vulnerability Meltdown: Not affected Vulnerability Mmio stale data: Vulnerable: Clear CPU buffers attempted, no microcode; SMT vulnerable Vulnerability Retbleed: 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; Enhanced IBRS, IBPB conditional, RSB filling, PBRSB-eIBRS SW sequence Vulnerability Srbds: Not affected Vulnerability Tsx async abort: Not affected

Versions of relevant libraries: [pip3] intel-openmp==2021.4.0 [pip3] mkl==2021.1.1 [pip3] mkl-devel==2021.1.1 [pip3] mkl-include==2021.1.1 [pip3] mypy_extensions==1.1.0 [pip3] numpy==2.1.0 [pip3] nvidia-cudnn-frontend==1.14.1 [pip3] onnx==1.18.0 [pip3] onnx-ir==0.1.11 [pip3] onnxscript==0.5.4 [pip3] optree==0.17.0 [pip3] pytorch-triton==3.4.0+gitc817b9b6 [pip3] tbb==2021.13.1 [pip3] torch==2.9.0a0+145a3a7bda.nv25.10 [pip3] torch_tensorrt==2.9.0a0 [pip3] torchao==0.14.0+git [pip3] torchprofile==0.0.4 [pip3] torchvision==0.24.0a0+094e7af5 [conda] Could not collect

cc @chauhang @penguinwu @voznesenskym @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @kadeng @amjames @Lucaskabela @jataylo

extent analysis

Fix Plan

Problem Summary

The issue is caused by a TypeError when trying to subscript a None object. This is happening in the forward method of the Repro class.

Root Cause Analysis

The root cause of the issue is likely due to the way the load_args function is loading the arguments for the Repro class. The load_args function is creating a large number of tensors and storing them in the buf variables. However, it seems that these tensors are not being properly initialized, resulting in None values being passed to the forward method.

Fix Plan

Step 1: Modify the load_args function to properly initialize the tensors

def load_args(reader):
    buf18 = reader.storage(None, 4, device=device(type='cuda', index=0))
    reader.tensor(buf18, (1,), is_leaf=True)  # Initialize the tensor with a shape of (1,)
    buf21 = reader.storage(None, 4, device=device(type='cuda', index=0))
    reader.tensor(buf21, (1,), is_leaf=True)  # Initialize the tensor with a shape of (1,)
    # ...

Step 2: Modify the forward method to handle the case where getitem is None

class Repro(torch.nn.Module):
    def forward(self, arg18_1, arg21_1, arg22_1, arg23_1, arg24_1, arg25_1, arg26_1, arg27_1, arg28_1, arg29_1, arg30_1, arg31_1, arg32_1, arg33_1, arg34_1, arg35_1, arg36_1, arg37_1):
        _foreach_add = torch.ops.aten._foreach_add.Scalar([

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 - ✅(Solved) Fix [dynamo]repro_run should call compile_fx_inner with a deepcopy of mod to avoid in-place mutation [1 pull requests, 1 participants]