Repository navigation
test: add coverage for AMWA (Adaptive Momentum Weight Averaging) - #455
Merged
Merged
Conversation
AMWA (dicee/weight_averaging.py, added in #440) was the only weight averaging technique without dedicated tests - SWA/SWAG/EMA/TWA are covered by tests/test_swa.py, ASWA by tests/test_adaptive_swa.py. It had only ever been smoke-tested manually. Adds tests/test_amwa.py: - end-to-end Execute() runs confirming amwa.pt/amwa_history.json are written with the expected fields, under both torchCPUTrainer and PL - direct unit tests of AMWA._compute_momentum/_compute_beta_n/ _compute_delta: zero/negative delta, monotonicity, fixed vs adaptive beta, history shorter than beta_window, window truncation, maximize=False - direct tests of the StableNet EMA update formula (w_stable <- m*w_stable + (1-m)*w_base) at momentum 0/0.25/1 - a test confirming PeriodicEvalCallback's on_train_epoch_end actually checkpoints AMWA's StableNet (via trainer.wa_model), not the live BaseNet, during AMWA training - verified this test genuinely catches a regression by temporarily forcing the live model into that code path (100% tensor mismatch) before reverting Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Fixes #447.
AMWA (
dicee/weight_averaging.py, added in #440) was the only weight-averaging technique without dedicated tests —SWA/SWAG/EMA/TWAare covered bytests/test_swa.py,ASWAbytests/test_adaptive_swa.py. It had only ever been smoke-tested manually.Adds
tests/test_amwa.py(22 tests):Execute()runs confirmingamwa.pt/amwa_history.jsonget written with the expected fields, under bothtorchCPUTrainerandPL.AMWA._compute_momentum/_compute_beta_n/_compute_delta: zero/negative delta, monotonicity, fixed vs. adaptivebeta,delta_historyshorter thanbeta_window, window truncation,maximize=False.w_stable <- m*w_stable + (1-m)*w_base) at momentum 0/0.25/1.PeriodicEvalCallback.on_train_epoch_endactually checkpoints AMWA's StableNet (viatrainer.wa_model), not the live BaseNet, during AMWA training.No source changes — test-only PR.
Test plan
ruff check dicee/ --line-length=200— clean (unaffected, test-only change)dicee/callbacks.pyand confirmed the test fails (100% tensor mismatch, not just a shape/type check), then revertedamwa.ptreload) when onlytrainer.wa_modelitself is unset — it's a legitimate alternate route to the same StableNet weights, not a regression