Skip to content

Add modules.TimmAttention; EEGPT and EEGDINO use it (same keys, same outputs) - #1460

Merged
bruAristimunha merged 7 commits into
braindecode:masterfrom
bruAristimunha:cleanup/t24-timm-attention
Oct 18, 2026
Merged

bruAristimunha merged 7 commits into
braindecode:masterfrom
bruAristimunha:cleanup/t24-timm-attention

Conversation

@bruAristimunha

@bruAristimunha bruAristimunha commented Oct 17, 2026 •

Copy link
Copy Markdown
Collaborator

Part of #1442, Tier 2 (shared modules where the parameter layout already matches). Stacked on #1455, #1456 and #1457: the diff includes them until they merge; the commits of this PR are the last three (TimmAttention, and the growth-stop list losing the two removed classes).

eegpt._Attention (130 lines) and eegdino._Attention (42 lines) both implement timm's attention: fused qkv, heads split, attention, proj. They are now braindecode.modules.TimmAttention(dim, num_heads, qkv_bias, qv_bias, attn_drop, proj_drop, exact):

  • qv_bias=True adds BEiT's separate q_bias/v_bias parameters (EEGDINO);
  • exact=True runs timm's op order softmax((q * scale) @ k^T) @ v through the shared helper's exact path (EEGDINO, bit-identical to the reference); otherwise torch's kernels and Gaudi's fused kernel as before (EEGPT, fused_in_lazy=True);
  • forward(x, need_weights=True) returns the attention weights (EEGPT's return_attention_layer).

EEGPT's is_causal was never set to True anywhere; removed with its branch.

Characterization vs master: EEGPT and EEGDINO have identical state_dict keys and weights and bit-identical outputs; test_attention_exact keeps asserting EEGDINO's forward, loss and gradients equal to its previous hand-written op order. 145 related tests pass.

Not moved onto it: LaBraM/NeuroRVQ (_Attention with relative-position bias, qk-norm and windows) and BrainOmni (rotary on a (batch, seq, heads, dim) layout): different modules, not copies.

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

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 17, 2026 21:11

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 11:16
@bruAristimunha
bruAristimunha force-pushed the cleanup/t24-timm-attention branch from 5021b30 to 37ca8d8 Compare 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.

@codecov

codecov Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.03%. Comparing base (8c618f1) to head (9f62770).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1460      +/-   ##
==========================================
+ Coverage   91.01%   91.03%   +0.01%     
==========================================
  Files         167      167              
  Lines       21621    21601      -20     
==========================================
- Hits        19679    19665      -14     
+ Misses       1942     1936       -6     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI balanced review requested due to automatic review settings October 18, 2026 11:40

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/t24-timm-attention branch from 0a54dc2 to a0bc30f Compare October 18, 2026 12:02
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 merged commit 1fffe57 into braindecode:master Oct 18, 2026
10 checks passed
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