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

Refactor deprecated torch.cuda.amp.autocast #521

Merged
merged 3 commits into from
Feb 21, 2025
Merged
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
13 changes: 12 additions & 1 deletion pypots/nn/modules/reformer/local_attention.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,22 @@
from einops import rearrange
from einops import repeat, pack, unpack
from torch import nn, einsum
from torch.cuda.amp import autocast

TOKEN_SELF_ATTN_VALUE = -5e4


# overwrite autocast to make it compatible with both torch >=2.4 and <2.4
def autocast(**kwargs):
if torch.__version__ >= "2.4":
from torch.cuda.amp import autocast

return autocast(**kwargs)
else:
from torch.amp import autocast

return autocast("cuda", **kwargs)


def exists(val):
return val is not None

Expand Down
Loading