Repository navigation
PatchTokenizer: no Identity placeholder named proj, so LoRA on LaBraM and LUNA works again - #1516
Merged
bruAristimunha merged 2 commits intoNov 2, 2026
Conversation
…arget_modules=["proj"] works on LaBraM and LUNA Since braindecode#1226 LaBraM, CBraMod and LUNA hold a non-learnable PatchTokenizer whose unused projections were nn.Identity submodules named proj and patcher. Name-based adapters match them: peft LoRA with target_modules=["qkv", "proj"] (neuralbench labram.yaml) or ["qkv_proj", "proj"] (luna.yaml) raised "Target module Identity() is not supported". Unused projections are now None; torch.jit.script prunes the is-not-None branches. State dicts and outputs are unchanged.
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the name-based LoRA targeting compatibility fix.
No open issues 🎉
What changed in this PR
This PR restores compatibility with name-based LoRA targeting by removing unused PatchTokenizer placeholder modules that caused PEFT failures in LaBraM and LUNA.
Changes:
- Replaces unused
projandpatcherIdentity modules withNoneand updates forward-path checks, preserving outputs and state-dict keys. - Adds regression coverage for module registration, TorchScript parity, and optional PEFT integration.
- Documents the compatibility fix in the changelog.
| File | Description |
|---|---|
test/unit_tests/models/test_modules.py |
Adds tokenizer registration, scripting, and model-level LoRA regression tests. |
docs/whats_new.rst |
Documents the LoRA fix and unchanged outputs and saved weights. |
braindecode/modules/blocks.py |
Removes unused Identity placeholders and guards projection calls with None checks. |
Review effort: Balanced
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1516 +/- ##
=======================================
Coverage 91.33% 91.33%
=======================================
Files 170 170
Lines 22100 22100
=======================================
Hits 20184 20184
Misses 1916 1916 🚀 New features to boost your workflow:
|
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.
Since #1226,
PatchTokenizerkeeps annn.Identityplaceholder namedproj(andpatcher) when that path is unused. PEFT LoRA configs that targetproj, as Meta's neuralbench does for LaBraM and LUNA, then match the placeholder and crash with "Target module Identity() is not supported".Unused projections are now
None, so name matching only hits real layers. Outputs and saved weights are unchanged: no state-dict keys move.Verified downstream with neuralbench and neuraltrain against this branch combined with the other 2.0 compat fixes: neuraltrain 716/716 and neuralbench 414/414 pass.
test/unit_tests/modelsandtest/unit_tests/modulesshow no new failures.