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

Benchmarks - Keep BatchNorm as fp32 for pytorch cnn models cast to fp16 #322

Merged
merged 2 commits into from
Mar 6, 2022

Conversation

jeffdaily
Copy link
Contributor

Description
The BatchNorm operator is not numerically stable in fp16. PyTorch documentation recommends to keep the BN op in fp32 for fp16 AMP models. Refer to https://pytorch.org/docs/stable/amp.html#ops-that-can-autocast-to-float32. Preserving BN in fp32 for superbench more accurately reflects real workloads.

@jeffdaily jeffdaily requested a review from a team as a code owner March 3, 2022 16:38
@cp5555 cp5555 requested review from guoshzhao and abuccts March 3, 2022 23:07
@cp5555 cp5555 changed the title keep BatchNorm as fp32 for pytorch cnn models cast to fp16 Benchmarks - Keep BatchNorm as fp32 for pytorch cnn models cast to fp16 Mar 4, 2022
@cp5555 cp5555 added benchmarks SuperBench Benchmarks model-benchmarks Model Benchmark Test for SuperBench Benchmarks labels Mar 4, 2022
@abuccts
Copy link
Member

abuccts commented Mar 4, 2022

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@codecov
Copy link

codecov bot commented Mar 4, 2022

Codecov Report

Merging #322 (80626c2) into main (425b9ff) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #322      +/-   ##
==========================================
+ Coverage   88.64%   88.66%   +0.01%     
==========================================
  Files          76       76              
  Lines        4500     4507       +7     
==========================================
+ Hits         3989     3996       +7     
  Misses        511      511              
Flag Coverage Δ
cpu-unit-test 72.79% <100.00%> (+0.04%) ⬆️
cuda-unit-test 88.59% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...erbench/benchmarks/model_benchmarks/pytorch_cnn.py 93.40% <100.00%> (+0.54%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 425b9ff...80626c2. Read the comment docs.

@abuccts
Copy link
Member

abuccts commented Mar 6, 2022

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@abuccts abuccts enabled auto-merge (squash) March 6, 2022 13:02
@abuccts abuccts merged commit a9ef0f9 into microsoft:main Mar 6, 2022
@cp5555 cp5555 mentioned this pull request Mar 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
benchmarks SuperBench Benchmarks model-benchmarks Model Benchmark Test for SuperBench Benchmarks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants