Skip to content

MAPA: load the braindecode-hosted weights, drop the fc1/fc2 key mapping - #1248

Merged
bruAristimunha merged 1 commit into
braindecode:masterfrom
bruAristimunha:w41/mapa-rehost
Oct 7, 2026
Merged

bruAristimunha merged 1 commit into
braindecode:masterfrom
bruAristimunha:w41/mapa-rehost

Conversation

@bruAristimunha

Copy link
Copy Markdown
Collaborator

What changed

  • MAPA loads the released mapa_vits384 with the standard from_pretrained:
    from braindecode.models import MAPA
    model = MAPA.from_pretrained("braindecode/mapa-pretrained", n_outputs=2, chs_info=raw.info["chs"], regions=regions)
  • New Hub repo braindecode/mapa-pretrained (rev 56c68f7d), converted once from bentang18/MAPA@988efbf3 mapa_vits384.pt (sha256 2d236089…, Apache-2.0). Files: config.json, model.safetensors, pytorch_model.bin, README.md, convert_mapa_checkpoint.py and the authors' NOTICE.
  • The ablation checkpoints (no_region, no_relpos, no_priors) are not re-hosted: no docstring or test loads them.
  • Removed MAPA.mapping (48 entries, mlp.fc1/fc2 → mlp.0/mlp.3). The native file already uses the FeedForwardBlock names, as Julien Gadonneix suggested in his 2026-10-02 comment on Add iEEG MAPA model #1178.
  • Docstring: an .. important:: box with the repo id and an example replaces the paragraph about loading the original file.
  • test_mapa_released_checkpoint_reproduces_the_reference_features now loads the new repo with strict=True and checks the same values from the authors' code.

Parity (2,420 entries)

  • Reference: master f869984 loading the original mapa_vits384.pt through mapping.
  • Candidate: this branch with from_pretrained, on the staged directory and on the Hub repo in a fresh cache.
  • Entries:
    • released weights, window mode: the test's reference windows, T = 2048 and 4096, and a second montage;
    • released weights, session mode (sfreq 32, 30 contacts on 3 arrays, T = 32 and 64 frames): logits, pooled features and the outputs of all 12 blocks;
    • random init in 6 configurations: train and eval outputs, gradients and buffers;
    • state-dict keys, shapes, dtypes and values.
  • Every entry has max-abs 0.0, including the head, which is the seed-0 init in both runs.
  • The re-downloaded files have the same sha256 as the staged files.

Tests

  • -k mapa --run-network in test_foundation_models.py: 24 passed.
  • test/unit_tests/models -k "mapa and not compiled": 47 passed, 4 skipped.
  • pre-commit: rc=0 on both runs.

Diff: 3 files, +32 / −57.

@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 88.62%. Comparing base (f869984) to head (a61b2ac).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1248      +/-   ##
==========================================
- Coverage   88.62%   88.62%   -0.01%     
==========================================
  Files         159      159              
  Lines       19547    19546       -1     
==========================================
- Hits        17324    17323       -1     
  Misses       2223     2223              
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bruAristimunha
bruAristimunha marked this pull request as ready for review October 7, 2026 20:11
Copilot AI balanced review requested due to automatic review settings October 7, 2026 20:11
@bruAristimunha
bruAristimunha merged commit 61004c1 into braindecode:master Oct 7, 2026
14 of 15 checks passed

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

The parity test must pin the documented checkpoint revision rather than track a mutable Hub branch.

1 open finding
What changed in this PR

Updates MAPA to load re-hosted pretrained weights through the standard Hub API and removes obsolete checkpoint key translation.

Changes:

  • Removes MAPA’s legacy fc1/fc2 key mapping.
  • Documents the new pretrained repository and usage.
  • Updates reference-feature testing to load the re-hosted checkpoint strictly.
File Description
braindecode/​models/​mapa.py Documents Hub loading and removes legacy mapping.
test/​unit_tests/​models/​test_foundation_models.py Loads and validates the re-hosted checkpoint.
docs/​whats_new.rst Records the pretrained-loading change.

🧠 Review effort: Balanced


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

cache_dir=str(Path(mne_data_dir) / "mapa_pretrained"),
)
model = MAPA.from_pretrained(
"braindecode/mapa-pretrained",
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