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

Fixes a couple of issues to add fp16 training support #476

Merged
merged 3 commits into from
Jan 20, 2023
Merged

Fixes a couple of issues to add fp16 training support #476

merged 3 commits into from
Jan 20, 2023

Conversation

crisp-snakey
Copy link
Contributor

There were a couple of issues when trying to use fp16 training. For one was that it was not exposed through the configuration system. The other was that the DynamicSoftLabelAssigner used binary_cross_entropy instead of binary_cross_entropy_with_logits. This changes where sigmoid is called on the predictions so that the more stable binary_cross_entropy_with_logits can be used and the Trainer can be configured to use fp16 precision.

crisp-snakey and others added 3 commits November 16, 2022 15:47
Moves the explicit `sigmoid` calculation inside the `dsl_assigner` so
that `binary_cross_entropy_with_logits` can be used. This allows for the
use of `auto_cast` to support training with `fp16` precision. If this is
not done `torch` will complain that using `binary_cross_entropy` with
`fp16` is unstable and as such refuses to train the model in `fp16`
precision.
Allows for setting the model precision during training using the config
system.
@RangiLyu RangiLyu changed the base branch from main to crisp-snakey/add-fp16-support January 20, 2023 07:41
@RangiLyu RangiLyu merged commit 10f64d0 into RangiLyu:crisp-snakey/add-fp16-support Jan 20, 2023
RangiLyu added a commit that referenced this pull request Jan 20, 2023
* Fixes a couple of issues to add fp16 training support (#476)

* Add half precision support to `nanodet_plus` head

Moves the explicit `sigmoid` calculation inside the `dsl_assigner` so
that `binary_cross_entropy_with_logits` can be used. This allows for the
use of `auto_cast` to support training with `fp16` precision. If this is
not done `torch` will complain that using `binary_cross_entropy` with
`fp16` is unstable and as such refuses to train the model in `fp16`
precision.

* Add model precision settings to config

Allows for setting the model precision during training using the config
system.

Co-authored-by: RangiLyu <[email protected]>

* fix lint

* lightning version

Co-authored-by: Bjarne <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants