Skip to content

TST: pretrained-compat contract covers every model with released weights - #1252

Merged
bruAristimunha merged 3 commits into
braindecode:masterfrom
bruAristimunha:w41/fix-compat-test
Oct 8, 2026
Merged

bruAristimunha merged 3 commits into
braindecode:masterfrom
bruAristimunha:w41/fix-compat-test

Conversation

@bruAristimunha

@bruAristimunha bruAristimunha commented Oct 7, 2026 •

Copy link
Copy Markdown
Collaborator

test_pretrained_compat.py is meant to cover every model class with released weights. On master it covers 21 classes and misses 7: NeuroRVQ, MAPA, BrainOmni, BrainTokenizer, SignalJEPA_Contextual, SignalJEPA_PostLocal, SignalJEPA_PreLocal. Nothing checked that the list was complete.

Changes, all in test/unit_tests/models/test_pretrained_compat.py unless noted:

  • COMPAT entries for the 7 missing classes. MAPA, BrainOmni and BrainTokenizer use 512-sample windows, (256, 1024) short/long windows and skip the 64-channel G2 montage to keep the cells small. MAPA declares a new contact_labels strategy: a name without a trailing contact number (Fz) raises.
  • test_compat_covers_every_pretrained_model: every class in models_dict whose source mentions hf_hub_download, from_pretrained(, huggingface.co/ or Hugging Face Hub must be in COMPAT or in EXCLUDED (NeuroPose and VEMG2Pose, sEMG). Appended to the master version of this file, it fails and lists the 7 classes above.
  • REVE: the cases ran only with --run-network, because test/conftest.py marks the literal param "REVE" as network. The entry is now keyed REVE-local-bank, and an autouse fixture writes reve_positions.json (10-05 positions plus E1..E128) and points REVE_POSITIONS_PATH at it. The 9 REVE cases now run in default CI. The released bank (543 names) contains all names used by the grid; the master REVE cases also pass against it with --run-network (9 passed).
  • Expected errors carry match= (e.g. n_times|window, n_channel_embeddings, locations|positions, channel name, divisible, trailing number) instead of accepting any ValueError/RuntimeError.
  • The blanket warnings.simplefilter("ignore") in the geometry test is replaced by a module filterwarnings list of 5 known messages (padding notice, MNE montage rename, STFT window, nested tensor, weight_norm), so other warnings show up.
  • Module docstring no longer claims "other sampling rates": every geometry runs at the checkpoint's rate.
  • NO_STRATEGY = {NeuroRVQ, MAPA, BrainOmni, BrainTokenizer}: these take no channel_strategy argument, so they are left out of test_native_checkpoint_loads_under_a_strategy.
  • Docs: _SegmentPatch.forward (Labram) and _PatchEmbedNetwork.forward (LUNA) said n_times // patch_size patches; with the default padding the count is ceil(n_times / patch_size).

Checks (CPU, torch 2.14.1, mne 1.13.2):

  • test_pretrained_compat.py: 240 passed, 0 skipped (master: 187 cases, of which the 9 REVE cases are skipped without --run-network).
  • Labram and LUNA, default args, n_times 800/837 and 512/549: outputs and state-dict keys identical to master, max abs diff 0.0.
  • pre-commit on the touched files: passed.

Copilot AI balanced review requested due to automatic review settings October 7, 2026 21:56

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.

🟢 Approval recommended

No blocking issues were identified in the test changes or documentation corrections.

0 open findings

What changed in this PR

Expands pretrained-model compatibility tests while leaving model execution unchanged.

Changes:

  • Adds seven model classes and a coverage-completeness check.
  • Runs REVE cases offline and tightens expected errors and warning filters.
  • Corrects patch-count documentation for padded inputs.
File Description
test/​unit_tests/​models/​test_pretrained_compat.py Expands coverage, adds completeness checks, and enables offline REVE tests.
docs/​whats_new.rst Records compatibility-test improvements.
braindecode/​models/​luna.py Corrects the documented padded patch count.
braindecode/​models/​labram.py Clarifies documented patch shapes and counts.

🧠 Review effort: Balanced


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

@codecov

codecov Bot commented Oct 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.05%. Comparing base (030d24f) to head (da6d783).

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

@bruAristimunha
bruAristimunha merged commit 63b0d02 into braindecode:master Oct 8, 2026
15 checks passed
lindicaphxag-tech added a commit to lindicaphxag-tech/braindecode that referenced this pull request Oct 8, 2026
lindicaphxag-tech added a commit to lindicaphxag-tech/braindecode that referenced this pull request Oct 8, 2026
bruAristimunha added a commit to bruAristimunha/braindecode that referenced this pull request Oct 8, 2026
bruAristimunha added a commit to bruAristimunha/braindecode that referenced this pull request Oct 8, 2026
bruAristimunha added a commit to lindicaphxag-tech/braindecode that referenced this pull request Oct 8, 2026
bfloat16 and HPU inputs now get their spectrogram in float32 on the CPU. The model ships released weights, so the braindecode#1252 coverage test needs a COMPAT entry (channel-agnostic, 200 Hz).
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