Skip to content

FIX ZUNA: pos_bins defaults to 100 (ZUNA1.1); re-hosted ZUNA1.1 checkpoint - #1557

Merged
bruAristimunha merged 2 commits into
braindecode:masterfrom
bruAristimunha:fix/zuna-pos-bins
Nov 8, 2026
Merged

bruAristimunha merged 2 commits into
braindecode:masterfrom
bruAristimunha:fix/zuna-pos-bins

Conversation

@bruAristimunha

Copy link
Copy Markdown
Collaborator

Summary

braindecode.models.ZUNA ports the ZUNA1.1 encoder, but two things did not match ZUNA1.1:

  1. The Hub checkpoint. braindecode/ZUNA (revision 10cd7745) held the raw ZUNA1 file of Zyphra/ZUNA, with Zyphra's key names (model.encoder.*, 463 tensors). None of them matches a parameter of the class (encoder.*, 215), and from_pretrained loads non-strictly, so ZUNA.from_pretrained("braindecode/ZUNA") kept a randomly initialised encoder without any error.
  2. pos_bins. ZUNA1.1 buckets electrode coordinates into 100 bins per axis (arXiv:2607.27308, Table II; Zyphra's ZUNA1.1 training and inference configs); 50 was ZUNA1's value. With 50 the encoder output is up to 5.2 away from the original.

Changes

  • pos_bins defaults to 100 (docstring says why); docs/whats_new.rst entry.
  • Hub, already done: braindecode/ZUNA now holds the ZUNA1.1 encoder (Zyphra/ZUNA1.1 @ 10b9d6c8, sha256 295fcddb…) in braindecode's parameter names, revision daf5cccf. Its config.json sets pos_bins: 100, so the checkpoint is right even with the old default; the conversion script is at the repo root and the card has a Revisions note.

Checks

  • Strict load of the export: only final_layer.1.{weight,bias} missing, nothing unexpected; all 213 tensors bit-equal to the upstream file.
  • Parity against the original Zyphra encoder (same weights, eval, 19 standard_1005 channels at 256 Hz, n_times 1280 and 2560, plus biosemi32): float64 max abs 9.1e-13; float32 pooled features 8.3e-6 (per-token 3e-4, the float32 reordering noise of the original code itself).
  • From a fresh Hub download: 213 of 215 parameters loaded (the head is new), datasets on the card read back as ['TUEG'].
  • braindecode 2.0.0 (released) also loads the new checkpoint fully, with identical features (max abs 0.0).
  • Voyager: test_models.py test_return_features.py test_integration.py test_huggingface.py -k "ZUNA and not compiled": 19 passed, 2 skipped. pre-commit clean.

Copilot AI balanced review requested due to automatic review settings November 8, 2026 17:24

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

An offline regression test is needed to confirm the default rotary buffers match explicit pos_bins=100 and differ from pos_bins=50 on a real montage, since existing tests would not catch a reversion.

1 open issue
What changed in this PR

Aligns ZUNA’s default spatial encoding with ZUNA1.1 and documents the separately updated Hub checkpoint.

Changes:

  • Changes pos_bins from 50 to 100 and explains the version-specific default.
  • Adds a release note covering the spatial-bin correction and corrected Hub checkpoint.
File Description
docs/​whats_new.rst Documents the default correction and re-hosted ZUNA1.1 checkpoint.
braindecode/​models/​zuna.py Updates the pos_bins default and its parameter documentation.

Review effort: Balanced

max_seqlen: int = 256,
rope_theta: float = 10000.0,
pos_bins: int = 50,
pos_bins: int = 100,
@codecov

codecov Bot commented Nov 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.48%. Comparing base (e031f8f) to head (1b6124a).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1557   +/-   ##
=======================================
  Coverage   91.48%   91.48%           
=======================================
  Files         170      170           
  Lines       22277    22277           
=======================================
  Hits        20379    20379           
  Misses       1898     1898           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bruAristimunha
bruAristimunha merged commit 23c3b31 into braindecode:master Nov 8, 2026
10 checks passed
bruAristimunha added a commit to bruAristimunha/braindecode that referenced this pull request Nov 9, 2026
Brings in dba9d42 (braindecode#1559, braindecode#1557). No conflicts; NOTICE.txt and docs/whats_new.rst differ from master only by the MEGGPT lines.
bruAristimunha added a commit to bruAristimunha/braindecode that referenced this pull request Nov 9, 2026
bruAristimunha added a commit to bruAristimunha/braindecode that referenced this pull request Nov 9, 2026
Brings in the ch_mask series (braindecode#1545 braindecode#1548 braindecode#1540 braindecode#1549 braindecode#1542 braindecode#1543 braindecode#1544 braindecode#1550), braindecode#1557 and braindecode#1559 (master dba9d42). No conflicts; NOTICE.txt and docs/whats_new.rst carry only this PR's additions over master.
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