pytorch/torch/_dynamo/variables
William Wen 486b4d2414 [dynamo, nested graph breaks] move cell codegen before side effects codegen (#160601)
This is needed because if we codegen cells for nested frames AFTER side effects, then reconstruction could get messed up. From below:

>The added test case demonstrates the reconstruction failure if we kept cell codegen at the original place (only happens with nested graph breaks since we reconstruct nested frame cells from VariableTracker rather than directly using LOAD_CLOSURE).

>At a high level, what happened before this change was that side_effects was pruning the cells (I don't recall exactly why this happens), and because cells were codegen'd after the side effects were applied, we were unable to properly reconstruct the cell. The error I was seeing was a list/tuple IndexError.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/160601
Approved by: https://github.com/mlazos
2025-10-08 22:02:52 +00:00
..
__init__.py Revert "[dynamo] Support torch.fx.traceback.annotate (#164678)" 2025-10-08 01:49:34 +00:00
base.py [dynamo][guards] More small guard optimizations (#159345) 2025-07-29 18:36:49 +00:00
builder.py [export] Preserve nn_module_stack for aliased nn modules (#164311) 2025-10-01 18:04:33 +00:00
builtin.py Pyrefly suppressions 7/n (#164913) 2025-10-08 07:27:17 +00:00
constant.py [dynamo, 3.14] support LOAD_CONST on slice, codegen LOAD_CONST slice instead of BINARY/STORE_SLICE (#163110) 2025-09-30 17:42:11 +00:00
ctx_manager.py Revert "[dynamo] Support torch.fx.traceback.annotate (#164678)" 2025-10-08 01:49:34 +00:00
dicts.py Realize LazyVariableTracker before raising exception (#163350) 2025-09-19 19:25:17 +00:00
distributed.py Revert "Reapply "C++-accessible Placements via pybind11 (#163030)" (#164519)" 2025-10-07 19:46:17 +00:00
functions.py [1/N] Fix ruff warnings (#164333) 2025-10-01 16:48:32 +00:00
higher_order_ops.py Revert "Enable all SIM rules except disabled ones (#164645)" 2025-10-05 19:32:21 +00:00
iter.py [dynamo, nested graph breaks] move cell codegen before side effects codegen (#160601) 2025-10-08 22:02:52 +00:00
lazy.py [dynamo] Avoid recompiling over unused objects (#156891) 2025-07-09 20:14:34 +00:00
lists.py [dynamo, 3.14] fix BUILD_TUPLE with 0 args (#163818) 2025-09-30 17:42:40 +00:00
misc.py [dynamo, nested graph breaks] move cell codegen before side effects codegen (#160601) 2025-10-08 22:02:52 +00:00
nn_module.py [dynamo] Inline nn module calls using __call__ methods (#164817) 2025-10-07 08:57:20 +00:00
optimizer.py [Dynamo] Don't guard data ptrs by default with mark_static_address (#162208) 2025-09-12 07:15:10 +00:00
script_object.py [dynamo] Replace unimplemented with unimplemented_v2 in torch/_dynamo/variables/script_object.py (#159343) 2025-08-01 21:30:41 +00:00
sdpa.py [Dynamo][Misc] Apply typing hints for codegen (#150289) 2025-04-04 14:26:22 +00:00
tensor.py [2/N] Simplify "in" operation for containers of a single item (#164323) 2025-10-01 05:39:11 +00:00
torch_function.py [dynamo] Be consistent with UserMethodVariable source (#160155) 2025-08-09 04:16:14 +00:00
torch.py Pyrefly suppressions 7/n (#164913) 2025-10-08 07:27:17 +00:00
user_defined.py NamedTuple: Allow side effects for dynamic attributes (#161645) 2025-09-09 19:42:02 +00:00