Skip to content

PatchTokenizer: no Identity placeholder named proj, so LoRA on LaBraM and LUNA works again - #1516

Merged
bruAristimunha merged 2 commits into
braindecode:masterfrom
bruAristimunha:bd2-compat-patchtokenizer-lora
Nov 2, 2026
Merged

bruAristimunha merged 2 commits into
braindecode:masterfrom
bruAristimunha:bd2-compat-patchtokenizer-lora

Conversation

@bruAristimunha

Copy link
Copy Markdown
Collaborator

Since #1226, PatchTokenizer keeps an nn.Identity placeholder named proj (and patcher) when that path is unused. PEFT LoRA configs that target proj, 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/models and test/unit_tests/modules show no new failures.

bd2-downstream and others added 2 commits November 2, 2026 12:53
…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.
Copilot AI balanced review requested due to automatic review settings November 2, 2026 13:25
@bruAristimunha
bruAristimunha merged commit 13ecc83 into braindecode:master Nov 2, 2026
4 of 7 checks passed

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.

🟢 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 proj and patcher Identity modules with None and 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

codecov Bot commented Nov 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.33%. Comparing base (7c25ac0) to head (6695ba0).
⚠️ Report is 5 commits behind head on master.

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:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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