This repository was archived by the owner on Jun 3, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 158
Bugfix: use label smoothing only when torch version is >= 1.10 #1352
Merged
Conversation
This file contains hidden or 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
bfineran
suggested changes
Jan 31, 2023
Contributor
bfineran
left a comment
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.
if label smoothing is set to not 0 (default) and torch version is too low, let's raise an exception and fail. LGTM after
corey-nm
reviewed
Jan 31, 2023
Contributor
corey-nm
left a comment
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.
lgtm after adding an error!
bfineran
approved these changes
Jan 31, 2023
corey-nm
approved these changes
Jan 31, 2023
Contributor
corey-nm
left a comment
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.
slick! 🔥
rahul-tuli
added a commit
that referenced
this pull request
Feb 2, 2023
* Bugfix: use label smoothing only when torch version is >= 1.10 * Apply suggestions from code review
bfineran
pushed a commit
that referenced
this pull request
Feb 2, 2023
* Bugfix: use label smoothing only when torch version is >= 1.10 * Apply suggestions from code review
bfineran
pushed a commit
that referenced
this pull request
Feb 3, 2023
* Bugfix: use label smoothing only when torch version is >= 1.10 * Apply suggestions from code review
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Torchvision integration support for torch < 1.10
torch introduced label_smoothing argument for CrossEntropyLoss
in version
1.10and greater. Using this parameter in earlier versions oftorch leads to a
TypeErrorAs of now in our torchvision training integration we do not make this
distinction(rather we always use label_smoothing) which can cause errors with
lower versions of torch
For example on running the following command in an environment with torch 1.9
throws an error
COMMAND:
ENVIRONMENT:
(sparseml3.8) 🥃 sparseml pip list | grep torch torch 1.9.0 torchvision 0.10.0ERROR:
After Current Pull Request
Current PR fixes the issue by adding a check for
torch.__version__andpassing in label-smoothing argument only if it is supported.
After described change, the original command works with both
torch
<1.10and torch>= 1.10With Torch > 1.10
ENVIRONMENT:
(sparseml3.8) 🥃 sparseml pip list | grep torch torch 1.12.0 torchvision 0.13.0OUTPUT:
With Torch < 1.10
ENVIRONMENT:
(sparseml3.8) 🥃 sparseml pip list | grep torch torch 1.9.0 torchvision 0.10.0OUTPUT:
(Works with warnings)
The proposed fixes are in relation to the following Ticket