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).
bruAristimunha added a commit that referenced this pull request Oct 9, 2026
* ENH add TFMTokenizer

* DOC license TFMTokenizer per NOTICE.txt convention (MIT link, no bundled text)

* TST fold TFMTokenizer tests into shared test_models.py suite

* MAINT apply pre-commit formatting for TFMTokenizer

* Sync TFMTokenizer registry with current upstream master

* Sync TFMTokenizer registry with current upstream master

* Sync TFMTokenizer registry with current upstream master

* Sync TFMTokenizer registry with current upstream master

* Sync TFMTokenizer docs with current upstream master

* Sync TFMTokenizer documentation with current upstream master

* Sync TFMTokenizer documentation with current upstream master

* Sync TFMTokenizer focused tests with current upstream master

* Sync TFMTokenizer integration skip with current upstream master

* docs: align TFMTokenizer parity claims with audited evidence

* docs: align TFMTokenizer parity claims with audited evidence

* MAINT TFMTokenizer: cut redundant checks, paper prose and generic tests; add pretrained box; outputs unchanged

* TST TFMTokenizer: list as a non-classification model in the integration suite

* MAINT TFMTokenizer: apply ruff-format and blacken-docs

* MAINT TFMTokenizer: reuse modules.quantization.EMACodebook

The private _EMAVectorQuantizer duplicated EMACodebook. With epsilon=1e-5, no dead-code expiry and no k-means init, EMACodebook is the reference EMA update; the uniform init is kept. Never-selected codes now follow the reference update again. Buffers are renamed (embed, embed_avg, inited); the loading snippet maps the released keys. EMACodebook skips the inited host read when k-means init is off.

* FIX TFMTokenizer: STFT through spectral_input; pretrained-compat entry

bfloat16 and HPU inputs now get their spectrogram in float32 on the CPU. The model ships released weights, so the #1252 coverage test needs a COMPAT entry (channel-agnostic, 200 Hz).

* MAINT TFMTokenizer: one loss term, drop no-op flatten, fix stale Notes

---------

Co-authored-by: Bruno Aristimunha <[email protected]>
bruAristimunha added a commit that referenced this pull request Oct 9, 2026
* ENH add EEG-CLIP dual encoder

* FIX match released EEG-CLIP logit-scale semantics

* STY apply current Ruff formatting to EEGCLIP

* test(models): cover EEGCLIP validation branches

* Sync EEG-CLIP registry with current upstream master

* Sync EEG-CLIP summary row with current upstream master

* Sync EEG-CLIP model contract with current upstream master

* Sync EEG-CLIP API docs with current upstream master

* Sync EEG-CLIP categorization with current upstream master

* Sync EEG-CLIP reference with current upstream master

* Sync EEG-CLIP docs with current upstream master

* Sync EEG-CLIP docs with current upstream master

* Sync EEG-CLIP docs with current upstream master

* Test remaining EEG-CLIP mapping and Hub serialization paths

* test: cover EEGCLIP projection and temporal-width edge cases

* Keep EEG-CLIP registry delta minimal on current master

* Keep EEG-CLIP summary delta minimal on current master

* Keep EEG-CLIP model contract delta minimal on current master

* Keep EEG-CLIP API delta minimal on current master

* Keep EEG-CLIP categorization delta minimal on current master

* Keep EEG-CLIP reference delta minimal on current master

* Keep EEG-CLIP changelog delta minimal on current master

* Keep upstream #1252 pretrained-compat changelog while preserving EEG-CLIP entry

* Keep optional HF text examples outside EEGCLIP pretrained-weights compatibility scan

* MAINT EEGCLIP: drop alias, guards and bespoke test file; fold tests into test_models.py

- encode_eeg was an alias of forward: removed (unreleased model).
- Shape/value guards that torch already raises on are removed; one
  forward path (2-D encoder output = one time step).
- Text outputs: tensor, or first element of a tuple / HF ModelOutput.
- reset_head: one loop over both heads, keeps device/dtype/train mode,
  validation via _set_n_outputs.
- Projection head as a module-level helper, same layer order/keys.
- explicit license kwarg, figure and versionadded in the docstring.
- test_eeg_clip.py (492 lines) -> two tests in test_models.py, one of
  them against the authors' ProjectionHead/ClipLoss computation.

* FIX EEGCLIP: default Deep4Net encoder ends with a log-softmax, as in the authors' code

The authors' Deep4Net (braindecode <= 0.8, add_log_softmax=True) feeds
log-probabilities over its 128 outputs to the EEG projection. Without it
the port scored 0.789 vs 0.816 (authors' code 0.830) on TUAB LogReg
pathological in the replication runs.

* DOC EEGCLIP: note on license and the authors' projection head

* MAINT EEGCLIP: drop duplicated zero-shot note; whats_new entry names only what the class provides

---------

Co-authored-by: Bruno Aristimunha <[email protected]>
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