Skip to content

Fix Oobleck tiled encode dropping latent frames (#15376) - #15445

Open
newcloud123 wants to merge 1 commit into
huggingface:mainfrom
newcloud123:fix-oobleck-tiling-frame-count
Open

newcloud123 wants to merge 1 commit into
huggingface:mainfrom
newcloud123:fix-oobleck-tiling-frame-count

Conversation

@newcloud123

Copy link
Copy Markdown

Fixes #15376.

What / why

AutoencoderOobleck._tiled_encode derived the encoder's downsampling factor as
(win_end - win_start) / tile_length from the first tile and used it to round
the left/right trims of every tile. Because the encoder rounds each window's
downsampling independently, that empirical factor is slightly off (e.g.
2051.16 instead of the true 2048). Rounding both trims with it accumulates
an error at tile seams, so a 1024-frame waveform encoded to 1023 latent
frames with tiling enabled, breaking StableAudioPipeline when adding noise.

Fix

  • Use the exact integer self.hop_length (product of downsampling_ratios)
    instead of the empirical factor.
  • Compute trim boundaries by mapping absolute sample positions to latent
    indices with round(pos / hop), referenced to the same absolute grid for
    every tile. Each tile now keeps exactly the frames between core_start and
    core_end, so the concatenated result matches the untiled frame count.

Verification

CPU only, random-weight 6-channel VAE, no weights/GPU:

  • Reproducer from the issue: no tiling = [1,3,1024], with tiling = [1,3,1024]
    after the fix (was [1,3,1023] before).
  • Added tests/test_oobleck_tiling_frame_count.py checking 5 waveform lengths
    (512/768/1024/1025/1500 frames): tiled length == untiled length == expected.
  • pytest with the fix: 1 passed, 5 subtests passed. With the original file
    restored: 4 subtests failed.
  • py_compile on both changed files: pass.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Oobleck VAE tiling drops latent frames and breaks Stable Audio audio-to-audio

1 participant