Skip to content

Support transformer-style tu- encoders in UnetPlusPlus and Linknet#1294

Merged
qubvel merged 2 commits intoqubvel-org:mainfrom
ShunsukeKikuchi:fix-tu-transformer-decoders
Mar 19, 2026
Merged

Support transformer-style tu- encoders in UnetPlusPlus and Linknet#1294
qubvel merged 2 commits intoqubvel-org:mainfrom
ShunsukeKikuchi:fix-tu-transformer-decoders

Conversation

@ShunsukeKikuchi
Copy link
Copy Markdown
Contributor

Hi @qubvel,

Fixes #1260.

This PR fixes decoder compatibility for transformer-style tu- encoders in UnetPlusPlus and Linknet.

Problem

TimmUniversalEncoder inserts a zero-channel placeholder for the missing 1/2-scale feature in transformer-style backbones such as ConvNeXt / ConvNeXtV2 (tu-convnext_atto, tu-convnextv2_base, etc.).

This works for some decoders, but UnetPlusPlus and Linknet currently fail when they encounter that zero-channel stage.

Changes

UnetPlusPlus

  • Treat zero-channel dense decoder nodes as explicit no-op tensors
  • Keep the existing TimmUniversalEncoder behavior unchanged

Linknet

  • Ignore zero-channel skip connections during skip fusion
  • Keep decoder stream channels non-zero when the encoder exposes a zero-channel placeholder stage

These changes make decoders explicitly handle the missing 1/2-scale stage rather than trying to materialize invalid zero-channel operations.

Tests

Added regression tests for tu-convnext_atto on both UnetPlusPlus and Linknet

  1. Ran regression tests for the affected models and timm universal encoders:
uv run --with-requirements requirements/test.txt pytest \
  tests/models/test_unetplusplus.py \
  tests/models/test_linknet.py \
  tests/encoders/test_timm_universal.py -q

Result: 30 passed, 2 skipped, 36 subtests passed

  1. Ran the repository standard non-marked suite:
uv run --with-requirements requirements/test.txt pytest -v -rsx -n 2 tests/ --non-marked-only
Result:

Result: 198 passed, 7 skipped, 213 subtests passed

Copy link
Copy Markdown
Collaborator

@qubvel qubvel left a comment

Choose a reason for hiding this comment

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

Looks good, thanks for fixing!

@qubvel qubvel merged commit 3d9aef1 into qubvel-org:main Mar 19, 2026
17 checks passed
@ShunsukeKikuchi ShunsukeKikuchi deleted the fix-tu-transformer-decoders branch March 19, 2026 16:29
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.

tu-convnextv2_base cannot be combined with UnetPlusPlus

2 participants