Skip to content

feat(mixer): use timm mixer instead of custom mixer - #274

Open
yhisaki wants to merge 3 commits into
devfrom
use-timm-mlp-mixer
Open

feat(mixer): use timm mixer instead of custom mixer#274
yhisaki wants to merge 3 commits into
devfrom
use-timm-mlp-mixer

Conversation

@yhisaki

@yhisaki yhisaki commented Jul 22, 2026

Copy link
Copy Markdown

Summary

This PR replaces the custom MLP-Mixer implementation with the standard MixerBlock provided by timm.

The scene encoders and turn-indicator trajectory encoder now use the same upstream implementation, reducing duplicated code and making the Mixer architecture easier to understand and maintain.

Changes

  • Replace the custom diffusion_planner.model.module.mixer.MixerBlock with timm.models.mlp_mixer.MixerBlock.

  • Remove the custom mixer.py module.

  • Update the following encoders to use the timm Mixer interface:

    • EgoEncoder
    • NeighborEncoder
    • LaneEncoder
    • LineEncoder
    • TrajectoryEncoder
  • Simplify encoder constructors by removing the custom tokens_mlp_dim and channels_mlp_dim arguments.

  • Use each encoder's embedding dimension as the Mixer channel dimension and the corresponding sequence length as the token dimension.

  • Use timm's Mlp implementation for single-token and auxiliary MLP encoders where applicable.

  • Apply drop_path_rate through the residual DropPath mechanism provided by the timm Mixer block.

Motivation

The previous Mixer implementation duplicated functionality already available in timm and required project-specific constructor arguments.

Using the upstream implementation:

  • reduces custom model code,
  • standardizes the Mixer architecture,
  • makes the expected token and channel dimensions clearer,
  • provides conventional MLP-Mixer expansion ratios and stochastic-depth behavior, and
  • makes future maintenance and architecture changes easier.

Behavioral changes

This is not a parameter-for-parameter replacement of the previous Mixer block.

The timm implementation uses its standard token- and channel-MLP expansion ratios and applies drop_path_rate as stochastic depth on the residual branches. Therefore, the internal parameter shapes and regularization behavior differ from those of the previous custom implementation.

Signed-off-by: Y.Hisaki <yhisaki31@gmail.com>
@SakodaShintaro

Copy link
Copy Markdown

Since retraining is required, it is likely to take some time.

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