-
Notifications
You must be signed in to change notification settings - Fork 27.4k
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
[Time series Informer] fix dtype of cumsum #25431
Conversation
The documentation is not available anymore as the PR was closed or merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch! Thanks for the fix. Is there a reason for float32 -> cast to the correct type instead of computing it in the correct dtype? (If so just add a small comment! )
@@ -647,7 +647,7 @@ def forward( | |||
# calculate context for updating the attn_output, based on: | |||
# https://github.com/zhouhaoyi/Informer2020/blob/ac59c7447135473fb2aafeafe94395f884d5c7a5/models/attn.py#L74 | |||
if self.is_decoder: | |||
context = value_states.cumsum(dim=-2) | |||
context = value_states.cumsum(dim=-2, dtype=torch.float32).to(value_states.dtype) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
context = value_states.cumsum(dim=-2, dtype=torch.float32).to(value_states.dtype) | |
context = value_states.cumsum(dim=-2, dtype=value_states.dtype) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so I wanted the cumsum to be in float32 to avoid overflow etc. and then cast...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
* fix dtype of cumsum * add comment
What does this PR do?
Fix an issue when training Informer with FP16, the
cumsum
returns float32.See report here: https://discuss.huggingface.co/t/how-to-train-on-multiple-gpus-the-informer-model-for-time-series-forecasting/48984/3