[dynamo] allow global import from collections import deque in user code (#148676)

See https://github.com/pytorch/pytorch/pull/148669#discussion_r1983462218 for more details.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/148676
Approved by: https://github.com/jansel
This commit is contained in:
Xuehai Pan
2025-03-09 13:28:13 +08:00
committed by PyTorch MergeBot
parent 59f14d19ae
commit 098494e9cb
3 changed files with 86 additions and 10 deletions

View File

@ -563,7 +563,6 @@ class DequeVariable(CommonListMethodsVariable):
)
def reconstruct(self, codegen: "PyCodegen") -> None:
assert "deque" not in codegen.tx.f_globals
codegen.add_push_null(
lambda: codegen.append_output(
codegen.create_load_python_module(collections.deque)