Skip to content

FIX MEDFormer crashed for windows longer than 5000 samples - #1311

Merged
bruAristimunha merged 3 commits into
braindecode:masterfrom
bruAristimunha:w41/shape-medformer-long
Oct 10, 2026
Merged

bruAristimunha merged 3 commits into
braindecode:masterfrom
bruAristimunha:w41/shape-medformer-long

Conversation

@bruAristimunha

@bruAristimunha bruAristimunha commented Oct 10, 2026 •

Copy link
Copy Markdown
Collaborator

MEDFormer adds a sinusoidal table indexed by time sample (_ListPatchEmbedding.channel_embedding), built with a fixed max_len=5000. Windows longer than 5000 samples (30 s at 200 Hz, 10 s at 1000 Hz, ...) crashed in forward with The size of tensor a (6000) must match the size of tensor b (5000). The table now has max(5000, n_times) rows; its first 5000 rows are the same values, so the buffer and outputs of windows up to 5000 samples are unchanged.

Geometry grid (251 cells): cells crashing in forward, master 53 (every window above 5000 samples), this PR 0 (251/251 cells run).

Parity vs master (fp32, CPU; sha1 of tensors, equal = max-abs 0.0) on the 198 cells that ran on master (initial state dict, eval output, train loss, gradients, state dict after a train step): 198/198 identical. TorchScript scripted == eager unchanged. No released checkpoint.

Tests: new test_medformer_window_longer_than_5000_samples fails on master and passes here. Suites -k MEDFormer: 36 passed on master, 37 here.

Copilot AI balanced review requested due to automatic review settings October 10, 2026 16:45

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 10, 2026 16:45

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 10, 2026 16:49

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 d848e4f into braindecode:master Oct 10, 2026
8 of 13 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