Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid importing apex transformer automatically #1801

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion apex/__init__.py
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, remove "transformer" from the dunder all

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, "the dunder all" means? :)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

meaning

__all__ = ["amp", "fp16_utils", "optimizers", "normalization", "transformer"]

Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
# load time) the error message is timely and visible.
from . import optimizers
from . import normalization
from . import transformer


# Logging utilities for apex.transformer module
Expand Down
2 changes: 2 additions & 0 deletions apex/transformer/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
# The following 4 lines are for backward comparability with
# older PyTorch.
if "all_gather_into_tensor" not in dir(torch.distributed):
if not torch.distributed.is_available():
raise RuntimeError("PyTorch Distributed is Not available or Disabled.")
torch.distributed.all_gather_into_tensor = torch.distributed._all_gather_base

def ensure_divisibility(numerator, denominator):
Expand Down