Skip to content

Fixed GroupNorm implementation #2945

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

Merged
merged 1 commit into from
Mar 24, 2025

Conversation

computer-whisperer
Copy link
Contributor

@computer-whisperer computer-whisperer commented Mar 22, 2025

  • Confirmed that run-checks all script has been executed.
  • Made sure the book is up to date with changes in this PR.

Related Issues/PRs

None

Changes

I discovered that GroupNorm was providing different outputs for the same input as the PyTorch version. The math error was relatively minor, but after this change it now matches the pytorch documentation, and the deviation I experienced in higher-level tests vs pytorch has been resolved.

I also had to tweak the expected test results in InstanceNorm slightly, as it uses GroupNorm internally.

Testing

The cargo tests for burn-core pass with this, and the observed higher-level deviation between my implementation of RWKV and the official pytorch implementation has been resolved.

…nceNorm expected test results (as it uses groupnorm internally).
Copy link

codecov bot commented Mar 23, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.13%. Comparing base (8a6f37c) to head (404d60f).
Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2945      +/-   ##
==========================================
+ Coverage   82.11%   82.13%   +0.01%     
==========================================
  Files         867      867              
  Lines      120268   120268              
==========================================
+ Hits        98763    98778      +15     
+ Misses      21505    21490      -15     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@laggui laggui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, good catch 😅

Epsilon should be added to avoid sqrt(0), looks like the previous implementation was incorrect.

Ref: https://paperswithcode.com/method/group-normalization

@laggui laggui merged commit 1916c68 into tracel-ai:main Mar 24, 2025
11 checks passed
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