Skip to content

Add modules.PreNormBlock; EEGPT, EEGDINO, LUNA, NeuroRVQ use it (same keys, same outputs) - #1462

Merged
bruAristimunha merged 1 commit into
braindecode:masterfrom
bruAristimunha:cleanup/t25-prenorm-block
Oct 18, 2026
Merged

bruAristimunha merged 1 commit into
braindecode:masterfrom
bruAristimunha:cleanup/t25-prenorm-block

Conversation

@bruAristimunha

Copy link
Copy Markdown
Collaborator

Part of #1442, Tier 2. Stacked on #1460 (and so on #1455–#1457); the commit of this PR is the last one.

Four private pre-norm transformer blocks with the same parameter layout (norm1, attn, norm2, mlp, plus gamma_1/gamma_2 layer scale in NeuroRVQ) become braindecode.modules.PreNormBlock(dim, attn, mlp, norm_layer, drop_path, layer_scale): it takes the attention and MLP modules, so each model keeps its own where it differs (LUNA's rotary attention, LaBraM's attention in NeuroRVQ, EEGDINO's MLP without mid dropout).

  • EEGPT _Block → PreNormBlock(TimmAttention, TimmMlp); return_attention_layer is now handled in _EEGTransformer.forward (blk.attn(blk.norm1(x), need_weights=True)), same result.
  • EEGDINO _TransformerEncoderLayer, LUNA _RotaryTransformerBlock (its two DropPath modules had no parameters; one draws the same values), NeuroRVQ _Block → a small _block() factory shared with NeuroRVQTokenizer (its two tests use it).

Characterization vs master: EEGPT, EEGDINO, LUNA, NeuroRVQ, NeuroRVQTokenizer: identical state_dict keys and weights, bit-identical outputs. 326 related tests pass (test_model_exported[LUNA] fails the same way on master with local torch). TorchScript covered (assert isinstance narrows LaBraM's Union return).

Not moved: TCFormer's block (its attention takes cos, sin per call; TorchScript forbids *args, so it stays its own 29 lines).

Copilot AI balanced review requested due to automatic review settings October 17, 2026 21:16

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.

@codecov

codecov Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.02%. Comparing base (bc0fdff) to head (f50cf20).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1462      +/-   ##
==========================================
- Coverage   91.03%   91.02%   -0.02%     
==========================================
  Files         167      167              
  Lines       21601    21565      -36     
==========================================
- Hits        19665    19629      -36     
  Misses       1936     1936              
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bruAristimunha
bruAristimunha force-pushed the cleanup/t25-prenorm-block branch from 65e9bd3 to 702b6a0 Compare October 18, 2026 11:16
Copilot AI balanced review requested due to automatic review settings October 18, 2026 11:16

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.

Copilot AI balanced review requested due to automatic review settings October 18, 2026 12:02

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.

Copilot AI balanced review requested due to automatic review settings October 18, 2026 12:28

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 force-pushed the cleanup/t25-prenorm-block branch from 9f3f1c0 to f50cf20 Compare October 18, 2026 17:31
Copilot AI balanced review requested due to automatic review settings October 18, 2026 17:31

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.

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