Repository navigation
FIX BENDR contextualizer output to match the pretrained reference - #1498
Merged
bruAristimunha merged 1 commit intoNov 1, 2026
Merged
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
The reference defines a final norm but does not call it. Keep its state keys for existing checkpoints and freeze the unused parameters so default training does not acquire unused gradients.
antonsoo
force-pushed
the
fix/1495-bendr-reference-norm
branch
from
October 31, 2026 01:17
25568a8 to
54370fa
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1498 +/- ##
==========================================
+ Coverage 91.19% 91.20% +0.01%
==========================================
Files 168 169 +1
Lines 21862 21915 +53
==========================================
+ Hits 19937 19988 +51
- Misses 1925 1927 +2 🚀 New features to boost your workflow:
|
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
Address the final LayerNorm part of #1495. The original contextualizer projects the transformer outputs directly; Braindecode normalizes them first. The maintainer confirmed that difference in the issue.
Changes
Remove the extra normalization. Retain its state-dict keys so existing checkpoints load strictly, and freeze those unused parameters so training does not expect their gradients. Add an analytic regression covering all sequence positions, start-token settings and train/eval modes, plus a changelog entry.
Testing
Six new regression cases fail on master and pass here.
Affected BENDR model/channel/geometry/feature checks: 50 passed; one unchanged torch 2.7 meta-kernel failure also reproduced on master. Integration, export, TorchScript and dtype checks: 11 passed, 1 skipped.
pre-commit run --files braindecode/models/bendr.py test/unit_tests/models/test_bendr.py docs/whats_new.rst: passed.Original release tensors, 12 recorded PhysioNet EEG windows, CPU/CUDA: public features match the original contextualizer's start-token output exactly; full sequences agree within 1.8e-8. Repeated from the built wheel. Strict trained-checkpoint/Adam loading, exact resumed training, encoder-only controls and three single-process DDP reducer steps pass.
New or changed behavior is covered by relevant regression tests
Style checks recorded
docs/whats_new.rstupdatedNotes for reviewers
The separate Hub projection-weight mismatch remains: these numerical comparisons use the original release tensors. This changes outputs of the full contextualizer, including previously fine-tuned models. Encoder-only outputs are unchanged. No downstream accuracy claim is made.
Rebased on current master, including its separate filter TorchScript repair. The BENDR implementation and regression-test blobs are unchanged by the rebase. A newly built wheel matches all 170 tracked package files. The complete 157,142,075-parameter EEGClassifier resume on all 15 recorded PhysioNet S001R04 trials reproduces the previous five-update final model, prediction hashes and loss exactly; final gradients and all 306 Adam tensors are finite. The six focused regressions pass again.
The complete local suite and documentation build have not been rerun after this documentation-conflict repair. The new hosted run is pending; earlier hosted results describe the previous head.