Skip to content

Commit

Permalink
re-export torch.optim._multi_tensor in torch/__init__.py (#129095)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #129095

- PR #127703 introduced a circular dependency
`torch/optim/__init__.py` imports `torch.optim._multi_tensor` and
`torch.optim._multi_tensor/_init__.py` imports `torch.optim`

  This seemed to work fine (green signals everywhere) but caused some internal test failures after it landed; an infinite recursion during import.

- PR #128875 attempted to fix this by removing the import from `torch/optim/__init__.py`.

This seemed to work fine: green signals everywhere and the failing tests started passing but a smaller number of tests started failing; unable to import `torch.optim._multi_tensor`

- This diff re-introduces the import but after `torch.optim` is fully initialized

Test Plan: CI signals

Differential Revision: D58792889
  • Loading branch information
fbgheith authored and facebook-github-bot committed Jun 19, 2024
1 parent 9d06e37 commit aaaff5f
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions torch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1987,6 +1987,7 @@ def _assert(condition, message):
utils as utils,
xpu as xpu,
)
import torch.optim._multi_tensor # usort: skip
from torch.signal import windows as windows

# Quantized, sparse, AO, etc. should be last to get imported, as nothing
Expand Down

0 comments on commit aaaff5f

Please sign in to comment.