pytorch/torch/_dynamo/variables
Brian Hirsh e68f5087d8 update _unsafe_set_version_counter to accept lists of tensors (#137921)
See the comment [here](https://github.com/pytorch/pytorch/issues/132014#issuecomment-2379547400) (cc @H-Huang @awgu @kwen2501 @wanchaol @fegin @fduwjj @wz337 @wconstab @d4l3k @c-p-i-o @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @yf225 @chenyang78 @kadeng @muchulee8 @ColinPeppler @amjames @desertfire @chauhang @aakhundov @XilunWu @rec) - this PR updates `_unsafe_set_version_counter` to accept a list of tensors, for overhead-sensitive users (e.g. distributed) who need to hide VC bumps from autograd on a large list of tensors without wanting to suffer the overhead of going from python->C++ separately for every tensor in the list.

I left the binding in pybind, and used a `std::vector`. if we **really** need to optimize overhead even further, we could write a manual cpython binding.

I use this updated API in the next PR to fix FSDP2, so that it properly hides the VC of all `all_gather_buffer` tensors in its call to `split_with_sizes_copy.out(all_gather_buffers)`.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/137921
Approved by: https://github.com/awgu, https://github.com/albanD
2025-02-04 04:51:11 +00:00
..
__init__.py [dynamo][builtin-skipfiles-cleanup] Remove inspect (#146116) 2025-02-04 03:36:07 +00:00
base.py Turn on mypy for _dynamo/variables/builtin.py (#145552) 2025-01-30 22:21:32 +00:00
builder.py [dynamo][builtin-skipfiles-cleanup] Remove inspect (#146116) 2025-02-04 03:36:07 +00:00
builtin.py update _unsafe_set_version_counter to accept lists of tensors (#137921) 2025-02-04 04:51:11 +00:00
constant.py Remove incorrect BuiltinVariable.call_hasattr() (#145551) 2025-01-30 22:21:19 +00:00
ctx_manager.py update _unsafe_set_version_counter to accept lists of tensors (#137921) 2025-02-04 04:51:11 +00:00
dicts.py [dynamo] Support functools.partial variables through inspect.signature (#146339) 2025-02-04 04:39:39 +00:00
distributed.py PEP585 update - torch/_dynamo (#145105) 2025-01-18 20:47:11 +00:00
functions.py [dynamo] Support functools.partial variables through inspect.signature (#146339) 2025-02-04 04:39:39 +00:00
higher_order_ops.py [hop] fix unbacked_bindings meta for while_loop (#143559) 2025-01-30 21:33:09 +00:00
iter.py PEP585 update - torch/_dynamo (#145105) 2025-01-18 20:47:11 +00:00
lazy.py PEP585 update - torch/_dynamo (#145105) 2025-01-18 20:47:11 +00:00
lists.py Remove incorrect BuiltinVariable.call_hasattr() (#145551) 2025-01-30 22:21:19 +00:00
misc.py [dynamo][builtin-skipfiles-cleanup] Remove inspect (#146116) 2025-02-04 03:36:07 +00:00
nn_module.py Revert "inductor: Don't throw an internal error when a nn.module is missing a attribute (#145122)" 2025-01-31 17:39:23 +00:00
optimizer.py PEP585 update - torch/_dynamo (#145105) 2025-01-18 20:47:11 +00:00
script_object.py PEP585 update - torch/_dynamo (#145105) 2025-01-18 20:47:11 +00:00
sdpa.py [dynamo] Simplify creation of VariableTrackers (#135714) 2024-10-18 09:36:46 +00:00
tensor.py [dynamo] Support functools.partial variables through inspect.signature (#146339) 2025-02-04 04:39:39 +00:00
torch_function.py PEP585 update - torch/_dynamo (#145105) 2025-01-18 20:47:11 +00:00
torch.py [Trace PyDispatcher] Support temporarily_pop_interpreter_stack ctx manager (#146271) 2025-02-03 21:47:54 +00:00
user_defined.py [dynamo][enum] Trace through enum.py for enum construction (#146070) 2025-02-02 03:12:36 +00:00