Fix BIOT channel embedding ignoring emb_size - #1213
Open
fbonc wants to merge 2 commits into
Open
Conversation
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
force-pushed
the
fix-biot-emb-size
branch
from
August 27, 2026 16:48
4ce6623 to
0d62b5f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.