Repository navigation
Description
Why
Twenty-one model classes load Hub weights, and each answers the same questions its own way: what is backbone vs head, what "frozen" means, which checkpoint keys may be missing/extra, how to get features, and — the part this issue is about — which input geometry the weights accept (window length, channel count/names/positions, sampling rate). Two downstream projects hit this in one quarter (#1155, #1194, #1195, OpenEEGBench's training_required_parameters).
Proposal in one line, borrowed from timm / HF / KerasHub: adapt where the information allows, refuse loudly where it does not, and prove it for every model with one registry-driven test (timm's test_model_load_pretrained over list_models(pretrained=True) is the model).
Audit 1 — classes with random weights (master 2426ddc3, 19 models × 10 geometries)
G1 canonical montage · G4 permuted · G2 biosemi64 (names+coords) · G3 8 ch coords only · G3b 8 ch names, no coords · 1 s · 30 s · non-divisible window · 100 Hz · 250 Hz. ✔ forwards · ⚠ warning · ✖ raises.
| Model | G1 | G4 | G2 | G3 | G3b | 1 s | 30 s | non-div | 100 Hz | 250 Hz |
|---|---|---|---|---|---|---|---|---|---|---|
| Labram | ✔ | ✔⚠ | ✖ | ✖ | ✖ | ✔ | ✔ | ✖→✔ (#1226) | ✔ | ✔ |
| EEGPT | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| BENDR | ✔ | ✖ | ✖ | ✖ | ✖ | ✔ | ✔ | ✔ | ✔ | ✔ |
| BIOT | ✔⚠ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔⚠ | ✔⚠ |
| CBraMod | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✖→✔ (#1226) | ✔ | ✔ |
| CodeBrain | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| EEGDINO | ✔ | ✔ | ✖ | ✔ | ✔ | ✔ | ✔ | ✔⚠ | ✔⚠ | ✔⚠ |
| LUNA | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✖→✔ (#1226) | ✔ | ✔ |
| REVE | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| SignalJEPA | ✔ | ✔ | ✔ | ✔ | NaN | ✖ | ✔ | ✔ | ✔ | ✔ |
| STEEGFormer | ✔ | ✔ | ✔ | ✔⚠ | ✔ | ✔ | ✔ | ✔ | – | ✔ |
| ZUNA | ✔ | ✔ | ✔ | ✔ | ✖ | ✔ | ✔ | ✖→✔ (#1226) | ✖→✔ | ✖→✔ |
| Brant | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | – |
| BrainBERT | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✖ | ✖ |
| BaRISTA | ✔ | – | ✔ | ✔ | ✖ | ✔ | ✔ | ✔ | ✖ | ✖ |
| DIVER1 | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔⚠ | ✔⚠ | ✔ |
| MIRepNet | ✔ | – | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | – |
| MVPFormer | ✔ | – | ✔ | ✔ | ✔ | ✔⚠ | ✔ | ✔⚠ | ✔⚠ | ✔⚠ |
| PopT | ✔⚠ | – | ✔⚠ | ✔⚠ | ✔ | – | – | – | – | – |
Findings: 15/19 accept any sfreq silently (only BIOT, EEGDINO, BrainBERT warn); three different minimum-length errors (SignalJEPA, BrainBERT, BaRISTA); EEGDINO maps input channel i to embedding slot i (silently wrong on a permuted or unnamed montage); SignalJEPA returns NaN for names without coordinates; LUNA/DIVER-1/REVE accept zero coordinates silently where ZUNA/BaRISTA raise; LaBraM needs ch_names at every forward for anything but its 128-name vocabulary; BENDR refuses even a permutation; BIOT/CodeBrain/MIRepNet/Brant accept any channel count structurally although their checkpoints cannot.
Audit 2 — the same grid through from_pretrained (default Hub checkpoints, CPU, 19 repos)
| model | G1 | G1* | G4 | G2 | G3 | G3b | G5a | G5b | G5c | G6-100 | G6-250 | ok/total |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Labram | ok | · | ok | FN | FN | FN | ok | ok | FS | ok | ok | 6/10 |
| EEGPT | FC | · | FC | FC | FC | FC | FC | FC | FC | FC | FC | 0/10 |
| BENDR | ok | · | FN | FC | FC | FC | ok | ok | ok | ok | ok | 6/10 |
| BIOT | ok | · | ok | FC | FC | FC | ok | ok | ok | FW | FW | 5/10 |
| CBraMod | FL | · | FL | FL | FL | FL | FL | FL | FL | FL | FL | 0/10 |
| CodeBrain | FT | · | FT | FC | FC | FC | FT | ok | FT | FT | FT | 1/10 |
| EEGDINO | ok | · | ok | FC | FC | FC | ok | ok | ok | ok | ok | 7/10 |
| LUNA | ok | · | ok | ok | ok | ok | ok | ok | FS | ok | ok | 9/10 |
| REVE | ok | · | ok | ok | ok | ok | ok | ok | ok | ok | ok | 10/10 |
| SignalJEPA | ok | · | ok | FN | FN | ok | FS | ok | ok | ok | ok | 7/10 |
| STEEGFormer | FC | · | FC | FC | FC | FC | FC | FC | FC | · | FC | 0/9 |
| ZUNA | ok | · | ok | ok | ok | FN | ok | ok | FS | FS | FS | 6/10 |
| Brant | FC | · | FC | FC | FC | FC | FC | FC | FC | FC | · | 0/9 |
| BrainBERT | ok | · | ok | FC | FC | FC | ok | ok | ok | FS | FS | 5/10 |
| BaRISTA | · | FC | · | FN | FC | FC | FC | FC | FC | FC | FC | 0/9 |
| DIVER1 | ok | · | ok | ok | ok | ok | ok | ok | ok | ok | ok | 10/10 |
| MIRepNet | · | ok | · | FC | FC | FC | ok | ok | ok | ok | · | 5/8 |
| MVPFormer | · | FC | · | FC | FC | FC | FC | FC | FC | FC | FC | 0/9 |
| PopT | · | FC | · | ok | FC | FC | · | · | · | · | · | 1/4 |
FC = from_pretrained rejects a chs_info whose count differs from the checkpoint's n_chans before downloading weights (66 of 100 failures — EEGPT/STEEGFormer/Brant/MVPFormer fail even on their canonical montage because the Hub config.json carries the pretraining dataset's n_chans = 62/22/16/32); FL = CBraMod from_pretrained fails at every geometry with a LazyModule "uninitialized parameter" error (torch 2.14, hf_hub 2.1.1; config.json has n_times: null → LazyLinear head) — separate bug; FW = genuine state-dict size mismatch (BIOT at other rates); FT = CodeBrain's fixed 30 s window; FS = patch/STFT shape at forward (fixed for Labram/LUNA/ZUNA by #1226); FN = channel names/locations required. All 19 repos download without a token; 78/178 cells pass; REVE and DIVER-1 pass everything.
Proposal (stacked, each PR small)
- Pad non-divisible windows by default: PatchTokenizer in LaBraM, CBraMod, LUNA; ZUNA default to pad #1226 — pad non-divisible windows by default via the shared
PatchTokenizer(LaBraM, CBraMod, LUNA; ZUNA default flip). Done. - Contract test over every pretrained class × the grid above, expected outcome derived from a declared channel strategy, unhandled cells
xfail(strict). PR follows (stacked on Pad non-divisible windows by default: PatchTokenizer in LaBraM, CBraMod, LUNA; ZUNA default to pad #1226). from_pretrainedchannel-count check → replace the hardn_chanscomparison with the model's own channel handling (EEGPT/STEEGFormer/REVE/ZUNA already adapt by names/coords; the config check blocks them).- CBraMod
from_pretrainedLazyLinear bug (needs a repro with the traceback). ChannelTokenizer— one module, five strategies (nameswith a shared alias table and anon_unknownpolicy,coordswithon_missing_loc="error",fixed_order= today'sChannelInterpolationLayer,index_slotsfor EEGDINO,agnostic), replacing per-model code and theInterpolated*classes; fixes EEGDINO, SignalJEPA NaN, LUNA/DIVER/REVE zero-coords, BENDR permutation.TimePositionEncoding.resample_tofor the table-bound models (LaBraM 16 slots, Brant, MVPFormer).check_compatibility(model, chs_info, sfreq, n_times)public report +from_pretrained(check_inputs=True); a uniformsampling_ratecheck (today 3 of 19 models say anything).- Backbone/head contract:
backbone_prefixes/head_prefixes,freeze_backbone()with PEFT semantics (every backbone parameter, embeddings included), declaredkeys_to_ignore_on_load_*,output_loading_info, pinnedrevisionper default repo.
Not proposed: timm's adapt_input_conv for channels (an electrode is not an RGB plane), in-graph resampling, a declarative config the model only warns about.
Activity
ChannelTokenizer: one module for the five channel strategies (#1227 s…
Channel layer: one channel_strategy for every pretrained model (#1241)
BabaSanfour commentedon Nov 16, 2026
On step 8 (backbone/head contract), some data from using the pretrained models as frozen feature extractors and for fine-tuning, on a 19-channel 10-20 montage, braindecode
main(1e3f4258).With the provenance from #1558, I listed the parameters that
from_pretrainedleaves at their initial values:final_layer.*) onlyuse_mean_pooling=Falseuse_mean_pooling=Truefc_norm.*chan_proj_type="none"chan_proj_typechan_proj.proj.*LaBraM's
fc_normand EEGPT'schan_projare new by design, as in the original fine-tuning recipes. For frozen features, though, they stay at their initialization in front of or after the pretrained encoder, and nothing says so.from_pretrainedonly warns when no parameter at all is loaded.Since #1558 already records what was loaded, step 8 could be:
fc_normorchan_proj);from_pretrainedwarns for any other parameter not loaded from the checkpoint;use_mean_pooling=False,chan_proj_type="none").One small related point:
CBraMod,LUNAandSignalJEPA_Contextual.from_pretrainedraisen_outputs not specifiedwithoutn_outputs, so a headless feature extractor needs a dummy head.Happy to help with step 8 if useful.
lindicaphxag-tech commentedon Nov 17, 2026
Hi @bruAristimunha, I'd like to help with the backbone/head provenance portion of #1227. I saw that #1558 already records loaded parameters and
test_pretrained_compat.pycovers the input-geometry grid, so I would avoid duplicating either.A remaining failure mode seems worth a focused regression: frozen feature extraction can retain newly initialized non-head layers (e.g.
fc_normorchan_proj) after a checkpoint otherwise loads successfully. I've built and locally tested a small, read-only CPU prototype that classifies parameter provenance as loaded, adapted, new, or uninitialized, and flags unexpected frozen new/adapted layers after accounting for declared heads/adapters. Its synthetic tests also cover tied parameters and lazy modules. This is a prototype, not a Braindecode CI result or a claim of checkpoint parity.Would a narrowly scoped, test-first follow-up for that specific contract fit the plan? I'd preserve default
from_pretrainedbehavior initially and hold off on warnings or public API changes until the model-specific expected-new declarations are agreed.