pytorch/torch/_dynamo/variables
Ryan Guo 698ff07323 [dynamo] Fix name collision bug for captured cells and locals (#140036)
The `export_freevars` method was introduced very early on, for
propagating writes to unboxed cells from child to parent frame, see
https://github.com/pytorch/torchdynamo/commit/d0c10341.

However, it's no longer needed after we started to modify root tracer's
`symbolic_locals` directly for the unboxed cells, see
https://github.com/pytorch/torchdynamo/commit/663e4d92.

As a result, we no longer need `export_freevars`. In fact, it can cause
a very subtle bug when name collision happens across the parent and
child frames during inlining, because the parent frame isn't necessarily
the frame that defined the cell captured by child frame.

In summary, this patch removes the `export_freevars` bits, and adds a
regression test.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/140036
Approved by: https://github.com/williamwen42, https://github.com/jansel
ghstack dependencies: #140035
2024-11-13 03:14:23 +00:00
..
__init__.py [Dynamo] Allow filter() to handle infinite iterator (#138305) 2024-11-12 17:32:56 +00:00
base.py [dynamo] Add is_mutable() and is_immutable() methods to VariableTracker (#139341) 2024-11-05 19:11:41 +00:00
builder.py add special case for __round__ constant variables (#139583) 2024-11-09 03:25:53 +00:00
builtin.py [Dynamo] Allow filter() to handle infinite iterator (#138305) 2024-11-12 17:32:56 +00:00
constant.py add special case for __round__ constant variables (#139583) 2024-11-09 03:25:53 +00:00
ctx_manager.py [Dynamo] Trace enter/exit of TorchFunctionModes (#135422) (#137114) 2024-10-09 02:29:40 +00:00
dicts.py [dynamo] Add is_mutable() and is_immutable() methods to VariableTracker (#139341) 2024-11-05 19:11:41 +00:00
distributed.py Revert "[dynamo] Fix constant propagation in builtins and UserClasses (#131354)" 2024-11-01 00:13:20 +00:00
functions.py [dynamo] Fix name collision bug for captured cells and locals (#140036) 2024-11-13 03:14:23 +00:00
higher_order_ops.py Add base class for single-subgraph inductor HOPs (#139898) 2024-11-11 16:12:35 +00:00
iter.py [Dynamo] Allow filter() to handle infinite iterator (#138305) 2024-11-12 17:32:56 +00:00
lazy.py [dynamo] Replace __str__ with __repr__ in some places (#136316) 2024-10-21 19:50:38 +00:00
lists.py [dynamo] Add is_mutable() and is_immutable() methods to VariableTracker (#139341) 2024-11-05 19:11:41 +00:00
misc.py [Dynamo] allow dynamic callables on tensor variables (#137940) 2024-11-08 23:49:34 +00:00
nn_module.py [dynamo] Remove dead code path for capturing __class__ in UserFunctionVariable (#140034) 2024-11-12 05:54:35 +00:00
optimizer.py [dynamo] Simplify creation of VariableTrackers (#135714) 2024-10-18 09:36:46 +00:00
script_object.py Add basic mypy annotations to dynamo (#132415) 2024-08-04 18:43:36 +00:00
sdpa.py [dynamo] Simplify creation of VariableTrackers (#135714) 2024-10-18 09:36:46 +00:00
tensor.py Make size a property with an assertion (#139794) 2024-11-09 03:39:41 +00:00
torch_function.py [dynamo] Simplify creation of VariableTrackers (#135714) 2024-10-18 09:36:46 +00:00
torch.py Make size a property with an assertion (#139794) 2024-11-09 03:39:41 +00:00
user_defined.py fix trace nn.parameters() (#138149) 2024-11-12 09:43:45 +00:00