fix(ltx2): cap encoder channels to match pretrained VAE weights#27
Open
silas-dsc wants to merge 1 commit intoBlaizzy:mainfrom
Open
fix(ltx2): cap encoder channels to match pretrained VAE weights#27silas-dsc wants to merge 1 commit intoBlaizzy:mainfrom
silas-dsc wants to merge 1 commit intoBlaizzy:mainfrom
Conversation
The LTX-2.3-dev pretrained VAE encoder caps feature channels at 1024,
but `_make_encoder_block` blindly applied `out_channels = in_channels *
multiplier`. With the default config the second `compress_all_res`
block expanded 1024 → 2048 channels, while its actual conv weight
`(128, 3, 3, 3, 1024)` only produces 128 × 8 = 1024 channels after the
space-to-depth, causing a broadcast error in `x_conv + x_in`:
ValueError: [broadcast_shapes] Shapes (1,1024,1,8,12) and
(1,2048,1,8,12) cannot be broadcast.
Add an optional `max_channels` (default 1024) to the three
`compress_*_res` block builders so `out_channels = min(in_channels *
multiplier, max_channels)`. This matches the pretrained weights
(conv_out has in=1024) and unblocks I2V / two-stage HQ pipelines that
exercise the encoder.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The LTX-2.3-dev pretrained VAE encoder caps feature channels at 1024, but
_make_encoder_blockinmlx_video/models/ltx_2/video_vae/video_vae.pyblindly appliedout_channels = in_channels * multiplier. With the default config the secondcompress_all_resblock tried to expand 1024 → 2048, while the actual conv weight(128, 3, 3, 3, 1024)only produces 128 × 8 = 1024 channels after space-to-depth.This caused a broadcast error in
SpaceToDepthDownsample.__call__(return x_conv + x_in) on every I2V / two-stage HQ run that exercises the VAE encoder:Add an optional
max_channels(default 1024) to the threecompress_*_resblock builders soout_channels = min(in_channels * multiplier, max_channels). This matches the pretrained weights (e.g.conv_out.conv.weighthasin=1024,down_blocks.7.conv.conv.weighthasout=128).Reproduction
Before the fix, this crashes inside
vae_encoder(stage1_image_tensor). After the fix, the encoder produces a(1, 128, 1, 8, 12)latent and the full pipeline runs end-to-end (verified locally — 81-frame 768x512 mp4 generated in ~18m, peak 44.88GB).Test plan
VideoEncoder.from_pretrained(...)— no shape errors, output shape(1, 128, 1, 8, 12).dev-two-stage-hqpipeline with I2V + A2V — completes and writes a valid mp4.🤖 Generated with Claude Code