Skip to content

Fix BIOT channel embedding ignoring emb_size - #1213

Merged
lehendo merged 2 commits into
sunlabuiuc:masterfrom
fbonc:fix-biot-emb-size
Aug 31, 2026
Merged

lehendo merged 2 commits into
sunlabuiuc:masterfrom
fbonc:fix-biot-emb-size

Conversation

@fbonc

@fbonc fbonc commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Issue

BIOTEncoder created its channel-token embedding as nn.Embedding(n_channels, 256) (biot.py:161), hardcoding dimension 256 while emb_size is user-configurable. In forward the channel-token embedding is added to the emb_size-dimensional spectral embedding, so any emb_size != 256 raises a shape-mismatch RuntimeError.

Fix

Changed the channel-token embedding to nn.Embedding(n_channels, emb_size) so it matches the rest of the encoder.

Notes

Added regression test test_model_non_default_emb_size in tests/core/test_biot.py using emb_size=128 (asserts the channel-token dim and runs a forward/backward pass). Full BIOT test suite (9 tests) passes.

channel_tokens was nn.Embedding(n_channels, 256), hardcoding 256 and
crashing when added to the emb_size-dim spectral embedding for any
emb_size != 256. Use emb_size.
@fbonc
fbonc force-pushed the fix-biot-emb-size branch from 4ce6623 to 0d62b5f Compare August 27, 2026 16:48

@lehendo lehendo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@lehendo
lehendo merged commit 661d54e into sunlabuiuc:master Aug 31, 2026
2 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