Skip to content

FIX restore Deep4Net split_first_layer=False - #1207

Merged
bruAristimunha merged 6 commits into
braindecode:masterfrom
lindicaphxag-tech:fix/deep4-unsplit-first-layer
Oct 5, 2026
Merged

bruAristimunha merged 6 commits into
braindecode:masterfrom
lindicaphxag-tech:fix/deep4-unsplit-first-layer

Conversation

@lindicaphxag-tech

Copy link
Copy Markdown
Contributor

Fixes #1206.

The CombinedConv migration made two split-only assumptions unconditional in Deep4Net: initialization accessed conv_time_spat.conv_time even when split_first_layer=False, and legacy conv_time.* keys were always remapped through conv_time_spat.

This PR restores the two-mode contract:

  • split first layer: keep the current CombinedConv initialization and legacy key migration;
  • unsplit first layer: initialize the direct conv_time module and keep conv_time.* checkpoint keys on that module;
  • classifier key migration remains unchanged.

Regression tests construct and run the unsplit model and load a legacy-style state dict through the compatibility mapping. The default split_first_layer=True path is unchanged.

Copy link
Copy Markdown
Contributor Author

Exact-head validation is green on d195649680fbabccb31c24a83db56838b8a37ec2: touched-file pre-commit passes (Ruff, mypy, isort, codespell, sphinx-lint) and all 15 Deep4-focused tests pass, including the unsplit construction/forward path and legacy-state mapping regression. Evidence: https://github.com/lindicaphxag-tech/lindicaphxag-tech/actions/runs/37136576329. I’ll hold this head for maintainer review.

@codecov

codecov Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.71429% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 87.85%. Comparing base (2426ddc) to head (6a6b69d).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1207   +/-   ##
=======================================
  Coverage   87.84%   87.85%           
=======================================
  Files         151      151           
  Lines       17602    17606    +4     
=======================================
+ Hits        15462    15467    +5     
+ Misses       2140     2139    -1     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bruAristimunha bruAristimunha 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.

Thanks for catching this (#1206). We reproduced the AttributeError on master with your test, verified the branch fix and the legacy state-dict loading, and that the default split_first_layer=True path is unchanged (0.0 output diff). CI green.

Resolved docs/whats_new.rst by keeping both changelog entries.
Resolved docs/whats_new.rst by keeping both changelog entries.

@bruAristimunha bruAristimunha 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.

Thanks for catching this (#1206). Reproduced the AttributeError on master with your test; fix and legacy state-dict loading verified; default path unchanged (0.0 diff).

@bruAristimunha
bruAristimunha merged commit c4c3a5b into braindecode:master Oct 5, 2026
12 of 13 checks passed
@bruAristimunha bruAristimunha added the maintenance Bug fix / refactor / tests — not a new model label Oct 5, 2026

@bruAristimunha bruAristimunha 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.

Thanks for catching this (#1206). We reproduced the AttributeError on master with your test, verified the fix and the legacy state-dict loading, and that the default split_first_layer=True path is unchanged (0.0 output diff). Tests green.

bruAristimunha added a commit to bruAristimunha/braindecode that referenced this pull request Oct 5, 2026
Conflict resolution:
- docs/whats_new.rst: kept both the braindecode#1232 from_pretrained geometry-kwargs bug-fix entry and master's braindecode#1207/braindecode#1212 Deep4Net/ShallowFBCSPNet bug-fix entries.
- test/unit_tests/models/test_eegdino.py: kept both the braindecode#1232 geometry-kwargs test block and master's braindecode#1194 qkv-hook attention test block.
bruAristimunha added a commit to bruAristimunha/braindecode that referenced this pull request Oct 5, 2026
Conflict resolution:
- braindecode/models/cbramod.py: kept master's braindecode#1226 PatchTokenizer on_non_divisible padding and merged the PR's _knows_geometry() helper (superset of master's _n_times/_n_chans-not-None check) into the PatchTokenizer n_times arg, final_layer construction (both __init__ sites), reset_head, and _n_patch.
- docs/whats_new.rst: kept both the braindecode#1233 CBraMod lazy-head bug-fix entry and master's braindecode#1207/braindecode#1212 Deep4Net/ShallowFBCSPNet bug-fix entries.
- test/unit_tests/models/test_foundation_models.py: kept master's MAPA/PopT test blocks and the PR's test_cbramod_head_is_concrete_when_geometry_is_derived.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance Bug fix / refactor / tests — not a new model

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deep4Net split_first_layer=False is broken by unconditional CombinedConv init/remapping

2 participants