-
Notifications
You must be signed in to change notification settings - Fork 955
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
fix deprecated torch.cuda.amp.GradScaler
FutureWarning for pytorch 2.4+
#3132
Merged
Merged
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
5572f88
fix deprecated FutureWarning for pytorch 2.4+
Mon-ius e583d2e
perform `make style` and `make quality`
Mon-ius f5e7ebf
Merge branch 'huggingface:main' into main
Mon-ius c9e6667
try to fix `Quality Check` on `actions/workflows/quality.yml`
Mon-ius 75d87c7
undo changes for `src/accelerate/utils/memory.py`
Mon-ius 5990f7f
adapt scaler for pytorch.__version__
Mon-ius 347bd27
fix scalar waning for npu device deps on pytorch2.4 version check
Mon-ius 6ac8586
fallback to default npu scaler
Mon-ius 7b4c949
fallback to default `GradScaler` doc
Mon-ius File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,8 +86,8 @@ def save_accelerator_state( | |
The current process index in the Accelerator state | ||
step (`int`): | ||
The current step in the internal step tracker | ||
scaler (`torch.cuda.amp.GradScaler`, *optional*): | ||
An optional gradient scaler instance to save | ||
scaler (`torch.amp.GradScaler`, *optional*) for pytorch>2.3: | ||
An optional gradient scaler instance to save; for lower version, check `torch.cuda.amp.GradScaler` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we don't need this extra explanation in the docstring, it should be quite clear as is what this refers to. |
||
save_on_each_node (`bool`, *optional*): | ||
Whether to save on every node, or only the main node. | ||
safe_serialization (`bool`, *optional*, defaults to `True`): | ||
|
@@ -186,7 +186,7 @@ def load_accelerator_state( | |
A list of learning rate schedulers | ||
process_index (`int`): | ||
The current process index in the Accelerator state | ||
scaler (`torch.cuda.amp.GradScaler`, *optional*): | ||
scaler (`torch.amp.GradScaler`, *optional*): | ||
An optional *GradScaler* instance to load | ||
map_location (`str`, *optional*): | ||
What device to load the optimizer state onto. Should be one of either "cpu" or "on_device". | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -209,8 +209,9 @@ def register_comm_hook(self, model): | |
class GradScalerKwargs(KwargsHandler): | ||
""" | ||
Use this object in your [`Accelerator`] to customize the behavior of mixed precision, specifically how the | ||
`torch.cuda.amp.GradScaler` used is created. Please refer to the documentation of this | ||
[scaler](https://pytorch.org/docs/stable/amp.html?highlight=gradscaler) for more information on each argument. | ||
`torch.amp.GradScaler` used is created for pytoch>2.3 or `torch.cuda.amp.GradScaler` for lower version. Please | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same, let's not overexplain. |
||
refer to the documentation of this [scaler](https://pytorch.org/docs/stable/amp.html?highlight=gradscaler) for more | ||
information on each argument. | ||
|
||
<Tip warning={true}> | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Since we both can't test this, let's not touch NPU for now.