Skip to content

FIX from_pretrained with explicit None geometry; LaBraM decoder honours on_non_divisible - #1250

Merged
bruAristimunha merged 6 commits into
braindecode:masterfrom
bruAristimunha:w41/fix-loading
Oct 8, 2026
Merged

bruAristimunha merged 6 commits into
braindecode:masterfrom
bruAristimunha:w41/fix-loading

Conversation

@bruAristimunha

Copy link
Copy Markdown
Collaborator

Fixes the loading/patching findings reported in #1232 and #1226.

  • EEGModuleMixin.from_pretrained: an explicit chs_info=None / n_chans=None (e.g. forwarded by a wrapper) no longer pins the other geometry argument to None; the saved geometry loads again. Pinning now checks the value, not the key.
  • Labram(neural_tokenizer=False): _PatchEmbed pads / crops / raises on a window not divisible by patch_size, following on_non_divisible like the tokenizer mode (it no longer adds parameters).
  • PatchTokenizer.prepare_input is public; LaBraM and LUNA call it.

Checks

  • New tests fail on master 030d24f (2 failed: test_eegdino::test_from_pretrained_takes_geometry_from_the_caller_not_the_config, test_non_divisible_window_padded_by_default[Labram-kwargs1-200]) and pass on this branch.
  • Default arguments, seed 0, fixed input, branch vs master: max-abs output difference 0.0 for Labram, Labram(neural_tokenizer=False), LUNA and EEGDINO; state-dict keys and shapes unchanged.
  • test_models, test_integration, test_return_features, test_eegdino, test_foundation_models, test/unit_tests/modules filtered on these models/tokenizer: 154 passed, 15 skipped.

…rs on_non_divisible

- from_pretrained(d, chs_info=None) / (d, n_chans=None) load the saved
  geometry again: the pinning checks the value, not the key (braindecode#1232).
- Labram(neural_tokenizer=False) pads / crops / raises on a window not
  divisible by patch_size, like the tokenizer mode (braindecode#1226).
- PatchTokenizer.prepare_input is public (_prepare_input kept as alias);
  LaBraM and LUNA call it.
Copilot AI balanced review requested due to automatic review settings October 7, 2026 21:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Explicit null values still suppress matching saved geometry fields, leaving some checkpoints without usable geometry.

1 open finding
What changed in this PR

Fixes geometry restoration during pretrained loading and applies LaBraM’s non-divisible-window policy in decoder mode.

Changes:

  • Refines pretrained geometry handling for explicit None values.
  • Exposes and reuses PatchTokenizer.prepare_input.
  • Adds LaBraM decoder regression coverage and release notes.
File Description
braindecode/​models/​base.py Adjusts pretrained geometry selection.
braindecode/​modules/​blocks.py Makes tokenizer input preparation public.
braindecode/​models/​labram.py Adds decoder padding/cropping/error handling.
braindecode/​models/​luna.py Uses the public tokenizer method.
test/​unit_tests/​models/​test_eegdino.py Tests explicit-null geometry loading.
test/​unit_tests/​models/​test_foundation_models.py Covers LaBraM decoder padding.
docs/​whats_new.rst Documents both fixes.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread braindecode/models/base.py Outdated
@codecov

codecov Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 89.05%. Comparing base (63b0d02) to head (1820823).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1250   +/-   ##
=======================================
  Coverage   89.05%   89.05%           
=======================================
  Files         157      157           
  Lines       19654    19660    +6     
=======================================
+ Hits        17503    17509    +6     
  Misses       2151     2151           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI balanced review requested due to automatic review settings October 8, 2026 06:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@bruAristimunha
bruAristimunha merged commit d853e31 into braindecode:master Oct 8, 2026
15 checks passed
bruAristimunha added a commit to bruAristimunha/braindecode that referenced this pull request Oct 8, 2026
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