pytorch - 💡(How to fix) Fix DISABLED test_trace_return_namedtuple (__main__.TestFX) [3 comments, 2 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#176966Fetched 2026-04-08 00:23:37
View on GitHub
Comments
3
Participants
2
Timeline
35
Reactions
0
Timeline (top)
mentioned ×14subscribed ×14labeled ×4commented ×3

Error Message

Traceback (most recent call last): File "/var/lib/jenkins/workspace/test/test_fx.py", line 2911, in test_trace_return_namedtuple class MyOutput(NamedTuple): foo: torch.Tensor bar: torch.Tensor File "/opt/conda/envs/py_3.14/lib/python3.14t/typing.py", line 2980, in new types = _lazy_annotationlib.call_annotate_function( original_annotate, _lazy_annotationlib.Format.FORWARDREF) File "/opt/conda/envs/py_3.14/lib/python3.14t/annotationlib.py", line 782, in call_annotate_function globals = _StringifierDict( namespace, ...<3 lines>... format=format, ) File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/convert_frame.py", line 2340, in call result = self._torchdynamo_orig_backend( frame, cache_entry, self.hooks, frame_state, skip=1 ) File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/convert_frame.py", line 2076, in call result = self._inner_convert( frame, cache_entry, hooks, frame_state, skip=skip + 1 ) File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/convert_frame.py", line 727, in call result = _compile( frame.f_code, ...<16 lines>... convert_frame_box=self._box, ) File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/convert_frame.py", line 1915, in _compile raise InternalTorchDynamoError( f"{type(e).qualname}: {str(e)}" ).with_traceback(e.traceback) from None File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/convert_frame.py", line 1851, in _compile guarded_code, tracer_output = compile_inner(code, one_graph, hooks) ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_utils_internal.py", line 96, in wrapper_function return function(*args, **kwargs) File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/convert_frame.py", line 1495, in compile_inner return _compile_inner(code, one_graph, hooks) File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/convert_frame.py", line 1540, in _compile_inner dynamo_output = compile_frame( code, ...<11 lines>... package=package, ) File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/convert_frame.py", line 1403, in compile_frame bytecode, tracer_output = transform_code_object(code, transform) ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^ File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/bytecode_transformation.py", line 1626, in transform_code_object tracer_output = transformations(instructions, code_options) File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/convert_frame.py", line 1375, in transform tracer_output = trace_frame( code, ...<14 lines>... package=package, ) File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/convert_frame.py", line 341, in _fn return fn(*args, **kwargs) File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/convert_frame.py", line 861, in trace_frame run_tracer() ~~~~~~~~~~^^ File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/convert_frame.py", line 842, in run_tracer tracer.run() ~~~~~~~~~~^^ File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/symbolic_convert.py", line 1694, in run while self.step(): ~~~~~~~~~^^ File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/symbolic_convert.py", line 1360, in step self.dispatch_table[inst.opcode](self, inst) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^ File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/symbolic_convert.py", line 898, in wrapper return inner_fn(self, inst) File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/symbolic_convert.py", line 2772, in STORE_ATTR VariableTracker.build(self, setattr).call_function( ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ self, # type: ignore[arg-type] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [obj, VariableTracker.build(self, inst.argval), val], ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ {}, ^^^ ) ^ File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/variables/builtin.py", line 1444, in call_function return handler(tx, args, kwargs) # type: ignore[return-value] File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/variables/builtin.py", line 1030, in <lambda> tx, [v.realize() for v in args], kwargs ~~~~~~~~~^^ File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/variables/lazy.py", line 102, in realize self._cache.realize() ~~~~~~~~~~~~~~~~~~~^^ File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/variables/lazy.py", line 43, in realize self.vt = builder.VariableBuilder( ~~~~~~~~~~~~~~~~~~~~~~~~ tx, self.source, allow_lazy_constant=False ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ )(self.value) ~^^^^^^^^^^^^ File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/variables/builder.py", line 484, in call return self._call_impl(value) ~~~~~~~~~~~~~~~^^^^^^^ File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/variables/builder.py", line 521, in _call_impl vt = self._wrap(value) File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/variables/builder.py", line 867, in _wrap result = dict( build_key_value(i, k, v) for i, (k, v) in enumerate(get_items_from_dict(value)) ) File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/variables/builder.py", line 869, in <genexpr> for i, (k, v) in enumerate(get_items_from_dict(value)) ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^ torch._dynamo.exc.InternalTorchDynamoError: RuntimeError: dictionary changed size during iteration

from user code: File "/opt/conda/envs/py_3.14/lib/python3.14t/annotationlib.py", line 655, in init self.globals = globals

Set TORCHDYNAMO_VERBOSE=1 for the internal stack trace (please do this especially if you're reporting a bug to PyTorch). For even more developer context, set TORCH_LOGS="+dynamo"

To execute this test, run the following from the base repo dir: PYTORCH_TEST_WITH_DYNAMO=1 python test/test_fx.py TestFX.test_trace_return_namedtuple

This message can be suppressed by setting PYTORCH_PRINT_REPRO_ON_FAILURE=0

Root Cause

This test was disabled because it is failing in CI. See recent examples and the most recent trunk workflow logs.

Fix Action

Fix / Workaround

Traceback (most recent call last):
  File "/var/lib/jenkins/workspace/test/test_fx.py", line 2911, in test_trace_return_namedtuple
    class MyOutput(NamedTuple):
        foo: torch.Tensor
        bar: torch.Tensor
  File "/opt/conda/envs/py_3.14/lib/python3.14t/typing.py", line 2980, in __new__
    types = _lazy_annotationlib.call_annotate_function(
        original_annotate, _lazy_annotationlib.Format.FORWARDREF)
  File "/opt/conda/envs/py_3.14/lib/python3.14t/annotationlib.py", line 782, in call_annotate_function
    globals = _StringifierDict(
        namespace,
    ...<3 lines>...
        format=format,
    )
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/convert_frame.py", line 2340, in __call__
    result = self._torchdynamo_orig_backend(
        frame, cache_entry, self.hooks, frame_state, skip=1
    )
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/convert_frame.py", line 2076, in __call__
    result = self._inner_convert(
        frame, cache_entry, hooks, frame_state, skip=skip + 1
    )
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/convert_frame.py", line 727, in __call__
    result = _compile(
        frame.f_code,
    ...<16 lines>...
        convert_frame_box=self._box,
    )
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/convert_frame.py", line 1915, in _compile
    raise InternalTorchDynamoError(
        f"{type(e).__qualname__}: {str(e)}"
    ).with_traceback(e.__traceback__) from None
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/convert_frame.py", line 1851, in _compile
    guarded_code, tracer_output = compile_inner(code, one_graph, hooks)
                                  ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_utils_internal.py", line 96, in wrapper_function
    return function(*args, **kwargs)
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/convert_frame.py", line 1495, in compile_inner
    return _compile_inner(code, one_graph, hooks)
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/convert_frame.py", line 1540, in _compile_inner
    dynamo_output = compile_frame(
        code,
    ...<11 lines>...
        package=package,
    )
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/convert_frame.py", line 1403, in compile_frame
    bytecode, tracer_output = transform_code_object(code, transform)
                              ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/bytecode_transformation.py", line 1626, in transform_code_object
    tracer_output = transformations(instructions, code_options)
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/convert_frame.py", line 1375, in transform
    tracer_output = trace_frame(
        code,
    ...<14 lines>...
        package=package,
    )
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/convert_frame.py", line 341, in _fn
    return fn(*args, **kwargs)
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/convert_frame.py", line 861, in trace_frame
    run_tracer()
    ~~~~~~~~~~^^
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/convert_frame.py", line 842, in run_tracer
    tracer.run()
    ~~~~~~~~~~^^
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/symbolic_convert.py", line 1694, in run
    while self.step():
          ~~~~~~~~~^^
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/symbolic_convert.py", line 1360, in step
    self.dispatch_table[inst.opcode](self, inst)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/symbolic_convert.py", line 898, in wrapper
    return inner_fn(self, inst)
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/symbolic_convert.py", line 2772, in STORE_ATTR
    VariableTracker.build(self, setattr).call_function(
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        self,  # type: ignore[arg-type]
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        [obj, VariableTracker.build(self, inst.argval), val],
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        {},
        ^^^
    )
    ^
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/variables/builtin.py", line 1444, in call_function
    return handler(tx, args, kwargs)  # type: ignore[return-value]
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/variables/builtin.py", line 1030, in <lambda>
    tx, [v.realize() for v in args], kwargs
         ~~~~~~~~~^^
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/variables/lazy.py", line 102, in realize
    self._cache.realize()
    ~~~~~~~~~~~~~~~~~~~^^
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/variables/lazy.py", line 43, in realize
    self.vt = builder.VariableBuilder(
              ~~~~~~~~~~~~~~~~~~~~~~~~
        tx, self.source, allow_lazy_constant=False
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    )(self.value)
    ~^^^^^^^^^^^^
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/variables/builder.py", line 484, in __call__
    return self._call_impl(value)
           ~~~~~~~~~~~~~~~^^^^^^^
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/variables/builder.py", line 521, in _call_impl
    vt = self._wrap(value)
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/variables/builder.py", line 867, in _wrap
    result = dict(
        build_key_value(i, k, v)
        for i, (k, v) in enumerate(get_items_from_dict(value))
    )
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/variables/builder.py", line 869, in <genexpr>
    for i, (k, v) in enumerate(get_items_from_dict(value))
                     ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
torch._dynamo.exc.InternalTorchDynamoError: RuntimeError: dictionary changed size during iteration

Code Example

Traceback (most recent call last):
  File "/var/lib/jenkins/workspace/test/test_fx.py", line 2911, in test_trace_return_namedtuple
    class MyOutput(NamedTuple):
        foo: torch.Tensor
        bar: torch.Tensor
  File "/opt/conda/envs/py_3.14/lib/python3.14t/typing.py", line 2980, in __new__
    types = _lazy_annotationlib.call_annotate_function(
        original_annotate, _lazy_annotationlib.Format.FORWARDREF)
  File "/opt/conda/envs/py_3.14/lib/python3.14t/annotationlib.py", line 782, in call_annotate_function
    globals = _StringifierDict(
        namespace,
    ...<3 lines>...
        format=format,
    )
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/convert_frame.py", line 2340, in __call__
    result = self._torchdynamo_orig_backend(
        frame, cache_entry, self.hooks, frame_state, skip=1
    )
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/convert_frame.py", line 2076, in __call__
    result = self._inner_convert(
        frame, cache_entry, hooks, frame_state, skip=skip + 1
    )
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/convert_frame.py", line 727, in __call__
    result = _compile(
        frame.f_code,
    ...<16 lines>...
        convert_frame_box=self._box,
    )
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/convert_frame.py", line 1915, in _compile
    raise InternalTorchDynamoError(
        f"{type(e).__qualname__}: {str(e)}"
    ).with_traceback(e.__traceback__) from None
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/convert_frame.py", line 1851, in _compile
    guarded_code, tracer_output = compile_inner(code, one_graph, hooks)
                                  ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_utils_internal.py", line 96, in wrapper_function
    return function(*args, **kwargs)
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/convert_frame.py", line 1495, in compile_inner
    return _compile_inner(code, one_graph, hooks)
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/convert_frame.py", line 1540, in _compile_inner
    dynamo_output = compile_frame(
        code,
    ...<11 lines>...
        package=package,
    )
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/convert_frame.py", line 1403, in compile_frame
    bytecode, tracer_output = transform_code_object(code, transform)
                              ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/bytecode_transformation.py", line 1626, in transform_code_object
    tracer_output = transformations(instructions, code_options)
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/convert_frame.py", line 1375, in transform
    tracer_output = trace_frame(
        code,
    ...<14 lines>...
        package=package,
    )
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/convert_frame.py", line 341, in _fn
    return fn(*args, **kwargs)
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/convert_frame.py", line 861, in trace_frame
    run_tracer()
    ~~~~~~~~~~^^
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/convert_frame.py", line 842, in run_tracer
    tracer.run()
    ~~~~~~~~~~^^
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/symbolic_convert.py", line 1694, in run
    while self.step():
          ~~~~~~~~~^^
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/symbolic_convert.py", line 1360, in step
    self.dispatch_table[inst.opcode](self, inst)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/symbolic_convert.py", line 898, in wrapper
    return inner_fn(self, inst)
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/symbolic_convert.py", line 2772, in STORE_ATTR
    VariableTracker.build(self, setattr).call_function(
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        self,  # type: ignore[arg-type]
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        [obj, VariableTracker.build(self, inst.argval), val],
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        {},
        ^^^
    )
    ^
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/variables/builtin.py", line 1444, in call_function
    return handler(tx, args, kwargs)  # type: ignore[return-value]
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/variables/builtin.py", line 1030, in <lambda>
    tx, [v.realize() for v in args], kwargs
         ~~~~~~~~~^^
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/variables/lazy.py", line 102, in realize
    self._cache.realize()
    ~~~~~~~~~~~~~~~~~~~^^
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/variables/lazy.py", line 43, in realize
    self.vt = builder.VariableBuilder(
              ~~~~~~~~~~~~~~~~~~~~~~~~
        tx, self.source, allow_lazy_constant=False
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    )(self.value)
    ~^^^^^^^^^^^^
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/variables/builder.py", line 484, in __call__
    return self._call_impl(value)
           ~~~~~~~~~~~~~~~^^^^^^^
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/variables/builder.py", line 521, in _call_impl
    vt = self._wrap(value)
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/variables/builder.py", line 867, in _wrap
    result = dict(
        build_key_value(i, k, v)
        for i, (k, v) in enumerate(get_items_from_dict(value))
    )
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/variables/builder.py", line 869, in <genexpr>
    for i, (k, v) in enumerate(get_items_from_dict(value))
                     ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
torch._dynamo.exc.InternalTorchDynamoError: RuntimeError: dictionary changed size during iteration

from user code:
   File "/opt/conda/envs/py_3.14/lib/python3.14t/annotationlib.py", line 655, in __init__
    self.globals = globals

Set TORCHDYNAMO_VERBOSE=1 for the internal stack trace (please do this especially if you're reporting a bug to PyTorch). For even more developer context, set TORCH_LOGS="+dynamo"


To execute this test, run the following from the base repo dir:
    PYTORCH_TEST_WITH_DYNAMO=1 python test/test_fx.py TestFX.test_trace_return_namedtuple

This message can be suppressed by setting PYTORCH_PRINT_REPRO_ON_FAILURE=0
RAW_BUFFERClick to expand / collapse

Platforms: dynamo

This test was disabled because it is failing in CI. See recent examples and the most recent trunk workflow logs.

Over the past 6 hours, it has been determined flaky in 9 workflow(s) with 9 failures and 9 successes.

Debugging instructions (after clicking on the recent samples link): DO NOT ASSUME THINGS ARE OKAY IF THE CI IS GREEN. We now shield flaky tests from developers so CI will thus be green but it will be harder to parse the logs. To find relevant log snippets:

  1. Click on the workflow logs linked above
  2. Click on the Test step of the job so that it is expanded. Otherwise, the grepping will not work.
  3. Grep for test_trace_return_namedtuple
  4. There should be several instances run (as flaky tests are rerun in CI) from which you can study the logs.
<details><summary>Sample error message</summary>
Traceback (most recent call last):
  File "/var/lib/jenkins/workspace/test/test_fx.py", line 2911, in test_trace_return_namedtuple
    class MyOutput(NamedTuple):
        foo: torch.Tensor
        bar: torch.Tensor
  File "/opt/conda/envs/py_3.14/lib/python3.14t/typing.py", line 2980, in __new__
    types = _lazy_annotationlib.call_annotate_function(
        original_annotate, _lazy_annotationlib.Format.FORWARDREF)
  File "/opt/conda/envs/py_3.14/lib/python3.14t/annotationlib.py", line 782, in call_annotate_function
    globals = _StringifierDict(
        namespace,
    ...<3 lines>...
        format=format,
    )
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/convert_frame.py", line 2340, in __call__
    result = self._torchdynamo_orig_backend(
        frame, cache_entry, self.hooks, frame_state, skip=1
    )
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/convert_frame.py", line 2076, in __call__
    result = self._inner_convert(
        frame, cache_entry, hooks, frame_state, skip=skip + 1
    )
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/convert_frame.py", line 727, in __call__
    result = _compile(
        frame.f_code,
    ...<16 lines>...
        convert_frame_box=self._box,
    )
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/convert_frame.py", line 1915, in _compile
    raise InternalTorchDynamoError(
        f"{type(e).__qualname__}: {str(e)}"
    ).with_traceback(e.__traceback__) from None
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/convert_frame.py", line 1851, in _compile
    guarded_code, tracer_output = compile_inner(code, one_graph, hooks)
                                  ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_utils_internal.py", line 96, in wrapper_function
    return function(*args, **kwargs)
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/convert_frame.py", line 1495, in compile_inner
    return _compile_inner(code, one_graph, hooks)
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/convert_frame.py", line 1540, in _compile_inner
    dynamo_output = compile_frame(
        code,
    ...<11 lines>...
        package=package,
    )
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/convert_frame.py", line 1403, in compile_frame
    bytecode, tracer_output = transform_code_object(code, transform)
                              ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/bytecode_transformation.py", line 1626, in transform_code_object
    tracer_output = transformations(instructions, code_options)
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/convert_frame.py", line 1375, in transform
    tracer_output = trace_frame(
        code,
    ...<14 lines>...
        package=package,
    )
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/convert_frame.py", line 341, in _fn
    return fn(*args, **kwargs)
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/convert_frame.py", line 861, in trace_frame
    run_tracer()
    ~~~~~~~~~~^^
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/convert_frame.py", line 842, in run_tracer
    tracer.run()
    ~~~~~~~~~~^^
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/symbolic_convert.py", line 1694, in run
    while self.step():
          ~~~~~~~~~^^
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/symbolic_convert.py", line 1360, in step
    self.dispatch_table[inst.opcode](self, inst)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/symbolic_convert.py", line 898, in wrapper
    return inner_fn(self, inst)
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/symbolic_convert.py", line 2772, in STORE_ATTR
    VariableTracker.build(self, setattr).call_function(
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        self,  # type: ignore[arg-type]
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        [obj, VariableTracker.build(self, inst.argval), val],
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        {},
        ^^^
    )
    ^
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/variables/builtin.py", line 1444, in call_function
    return handler(tx, args, kwargs)  # type: ignore[return-value]
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/variables/builtin.py", line 1030, in <lambda>
    tx, [v.realize() for v in args], kwargs
         ~~~~~~~~~^^
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/variables/lazy.py", line 102, in realize
    self._cache.realize()
    ~~~~~~~~~~~~~~~~~~~^^
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/variables/lazy.py", line 43, in realize
    self.vt = builder.VariableBuilder(
              ~~~~~~~~~~~~~~~~~~~~~~~~
        tx, self.source, allow_lazy_constant=False
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    )(self.value)
    ~^^^^^^^^^^^^
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/variables/builder.py", line 484, in __call__
    return self._call_impl(value)
           ~~~~~~~~~~~~~~~^^^^^^^
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/variables/builder.py", line 521, in _call_impl
    vt = self._wrap(value)
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/variables/builder.py", line 867, in _wrap
    result = dict(
        build_key_value(i, k, v)
        for i, (k, v) in enumerate(get_items_from_dict(value))
    )
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_dynamo/variables/builder.py", line 869, in <genexpr>
    for i, (k, v) in enumerate(get_items_from_dict(value))
                     ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
torch._dynamo.exc.InternalTorchDynamoError: RuntimeError: dictionary changed size during iteration

from user code:
   File "/opt/conda/envs/py_3.14/lib/python3.14t/annotationlib.py", line 655, in __init__
    self.globals = globals

Set TORCHDYNAMO_VERBOSE=1 for the internal stack trace (please do this especially if you're reporting a bug to PyTorch). For even more developer context, set TORCH_LOGS="+dynamo"


To execute this test, run the following from the base repo dir:
    PYTORCH_TEST_WITH_DYNAMO=1 python test/test_fx.py TestFX.test_trace_return_namedtuple

This message can be suppressed by setting PYTORCH_PRINT_REPRO_ON_FAILURE=0
</details>

Test file path: test_fx.py

For all disabled tests (by GitHub issue), see https://hud.pytorch.org/disabled.

cc @ezyang @EikanWang @jgong5 @wenzhe-nrv @chauhang @penguinwu

extent analysis

Fix Plan

Problem Summary

The test test_trace_return_namedtuple is failing in CI due to a RuntimeError: dictionary changed size during iteration error.

Root Cause Analysis

The error is caused by a dictionary being modified while it's being iterated over in the PyTorch Dynamo code.

Fix Plan

To fix this issue, we need to ensure that the dictionary is not modified while it's being iterated over. We can do this by creating a copy of the dictionary before iterating over it.

Step-by-Step Solution

  1. Create a copy of the dictionary: In the annotationlib.py file, modify the __init__ method to create a copy of the globals dictionary before assigning it to self.globals.

    def __init__(self, ...):
        self.globals = dict(globals)  # Create a copy of the globals dictionary

2. **Update the test file**: Update the `test_fx.py` file to use the `PYTORCH_TEST_WITH_DYNAMO` environment variable to run the test with Dynamo enabled.

    ```python
    import os
    import pytest

    @pytest.mark.skipif(not os.environ.get('PYTORCH_TEST_WITH_DYNAMO'), reason='Dynamo test')
    def test_trace_return_namedtuple():
        ...

Verification

To verify that the fix worked, run the test test_trace_return_namedtuple with the PYTORCH_TEST_WITH_DYNAMO environment variable set to 1. If the test passes, the fix is successful.

Extra Tips

  • Make sure to set the PYTORCH_TEST_WITH_DYNAMO environment variable to 1 when running the test.
  • If the test still fails, try setting the TORCHDYNAMO_VERBOSE environment variable to 1 for more detailed error messages.
  • To prevent regressions,

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 DISABLED test_trace_return_namedtuple (__main__.TestFX) [3 comments, 2 participants]