Skip to content

BrainOmni: load braindecode-hosted weights, drop the OpenTSLab translation - #1245

Merged
bruAristimunha merged 9 commits into
braindecode:masterfrom
bruAristimunha:w41/brainomni-rehost
Oct 8, 2026
Merged

bruAristimunha merged 9 commits into
braindecode:masterfrom
bruAristimunha:w41/brainomni-rehost

Conversation

@bruAristimunha

Copy link
Copy Markdown
Collaborator

Stacked on #1244 (base commit 517aa14); the diff below is against that commit.

What changed

  • BrainOmni and BrainTokenizer load with the standard from_pretrained. The weights are converted once from OpenTSLab/BrainOmni@9a4d3c70 (MIT):

    • braindecode/braintokenizer-pretrained (rev 945aa489)
    • braindecode/brainomni-tiny-pretrained (rev d111525e)
    • braindecode/brainomni-base-pretrained (rev 40f33629)

    Each repo has config.json, model.safetensors, pytorch_model.bin, README.md and convert_brainomni_checkpoints.py.

  • Removed: BrainTokenizer.from_opentslab_config, BrainOmni.from_opentslab_config, the two load_state_dict overrides, _rename_official_key, _translate_opentslab_config, _TOKENIZER_CONFIG_RENAMES, _BRAINOMNI_CONFIG_RENAMES and _BRAINOMNI_PRETRAINING_KEYS. No key mapping is left.

  • Removed arguments: quantize_optimize_method (BrainTokenizer, BrainOmni, ResidualVectorQuantizer) and activation (BrainTokenizer, which never used it).

  • State dict:

    • pos and sensor_type are now non-persistent, because they are derived from chs_info.
    • weight_g/weight_v become parametrizations.weight.original0/1, since torch.nn.utils.weight_norm is deprecated.
    • SEANet's .model. level is flattened.
  • Windowing is now 3 lines with Tensor.unfold. _unfold and _window_stride are removed.

  • The three attention modules share one SDPA helper. SEANet keeps only the released configuration.

  • Tests: test_brainomni.py now loads the new repo ids. BrainOmni is added to test_pretrained_compat.

Parity (fingerprint of 91 entries: tiny, base and tokenizer weights in fp32/bf16/fp16; T = 512, 1024, 7680 and 12032; random-init outputs, gradients and buffers)

  • Reference: 517aa14 loading the OpenTSLab files.
  • Candidate: this branch loading the Hub repos.
  • Every entry has max-abs 0.0, and the native keys equal the model keys.
  • Pinned reference values: tokenizer and tiny from the released code (340d6b5), base from 517aa14. Network tests: 58/58 pass.

Lines

file before after
braindecode/models/brainomni.py 1971 887
test/unit_tests/models/test_brainomni.py 1361 566
total diff +772 / −2513

@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.00%. Comparing base (63b0d02) to head (a1eedaa).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1245      +/-   ##
==========================================
- Coverage   89.05%   89.00%   -0.05%     
==========================================
  Files         157      157              
  Lines       19654    19367     -287     
==========================================
- Hits        17503    17238     -265     
+ Misses       2151     2129      -22     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

# Conflicts:
#	braindecode/models/brainomni.py
#	docs/whats_new.rst
#	test/unit_tests/models/test_brainomni.py
@bruAristimunha
bruAristimunha marked this pull request as ready for review October 7, 2026 20:20
Copilot AI balanced review requested due to automatic review settings October 7, 2026 20:20

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

Window stride and attention-dimension validation regressions can produce division-by-zero failures for public API inputs.

2 open findings
What changed in this PR

Migrates BrainOmni models to native Braindecode-hosted checkpoints while simplifying checkpoint handling and architecture code.

Changes:

  • Uses standard from_pretrained loading without OpenTSLab translation.
  • Refactors windowing, attention, SEANet, and weight normalization.
  • Updates compatibility, parity, integration tests, and documentation.
File Description
braindecode/​models/​brainomni.py Simplifies model architecture and checkpoint loading.
braindecode/​modules/​quantization.py Removes the fixed EMA strategy argument.
test/​unit_tests/​models/​test_brainomni.py Updates focused and pretrained parity tests.
test/​unit_tests/​models/​test_integration.py Exempts the tokenizer’s fixed activation.
test/​unit_tests/​models/​test_pretrained_compat.py Adds BrainOmni compatibility coverage.
docs/​api.rst Updates pretrained-weight availability.
docs/​whats_new.rst Documents converted Hub checkpoints.

🧠 Review effort: Balanced


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

Comment thread braindecode/models/brainomni.py
Comment thread braindecode/models/brainomni.py
Copilot AI balanced review requested due to automatic review settings October 8, 2026 06:50

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@bruAristimunha
bruAristimunha merged commit 359bbc9 into braindecode:master Oct 8, 2026
21 of 22 checks passed
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