Skip to content

fix: preserve timestep rank in sinusoidal embedding - #316

Merged
yxlllc merged 1 commit into
openvpi:dual-timestepfrom
KakaruHayate:fix/onnx-timestep-embedding
Aug 2, 2026
Merged

fix: preserve timestep rank in sinusoidal embedding#316
yxlllc merged 1 commit into
openvpi:dual-timestepfrom
KakaruHayate:fix/onnx-timestep-embedding

Conversation

@KakaruHayate

@KakaruHayateKakaruHayate commented Aug 2, 2026

Copy link
Copy Markdown

Summary

  • preserve the input rank in SinusoidalPosEmb
  • restore the singleton frame axis after timestep MLPs when tracing rank-1 timesteps
  • keep rank-2 dual-timestep training and interpolation behavior unchanged

Motivation

The ONNX exporters trace diffusion backbones with a rank-1 timestep tensor. Forcing that tensor to rank 2 inside SinusoidalPosEmb makes the timestep MLP operate on rank-3 inputs, which exports its linear layers as MatMul + Add. ONNX Runtime DirectML graph fusion rejects the resulting diffusion loop graph.

Keeping rank-1 timesteps rank 1 lets the linear layers export as 2-D Gemm, then the backbone restores the existing [B, 1, C] contract. Rank-2 dual timesteps already produce [B, 1, C] and are unchanged.

Validation

  • rank-1 and rank-2 timestep paths produce identical [B, 1, C] output (max_abs_error = 0)
  • legacy ONNX export emits two Gemm nodes and no MatMul for the timestep MLP
  • ONNX checker passes

@yxlllc
yxlllc merged commit 4764cab into openvpi:dual-timestepAug 2, 2026
Sign up for freeto 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

@KakaruHayate@yxlllc