Skip to content

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

Open

Description

@gorkadabo1

Describe the bug

Enabling Oobleck VAE tiling can shorten the encoded audio. In a complete Stable Audio audio-to-audio call using small random-weight components, a 2,097,152-sample waveform produces 1,023 latent frames instead of 1,024. The pipeline then fails when adding the encoded audio to its noise tensor. Disabling tiling makes the same call succeed.

Reproduction

import torch
from diffusers import AutoencoderOobleck

torch.set_num_threads(1)
vae = AutoencoderOobleck(
    encoder_hidden_size=6,
    decoder_channels=3,
    decoder_input_channels=3,
).eval()
audio = torch.zeros(1, 2, 1024 * vae.hop_length)

with torch.no_grad():
    print(vae.encode(audio).latent_dist.mean.shape)
    vae.enable_tiling()
    print(vae.encode(audio).latent_dist.mean.shape)

Context

I was trying to generate a variation of an existing recording with Stable Audio and I enabled VAE tiling to reduce memory use

Logs

torch.Size([1, 3, 1024])
torch.Size([1, 3, 1023])

Expected: both encodings should produce 1,024 latent frames.

In StableAudioPipeline, the mismatch raises:

RuntimeError: The size of tensor a (1023) must match the size of tensor b (1024) at non-singleton dimension 2

System Info

Diffusers 0.44.0.dev0, main 750b3be2c0198e194c87e931a6904066de167a5f; Linux x86_64, Python 3.11.15, PyTorch 2.7.1+cpu, Transformers 5.23.0. Validated on CPU with random-weight components; pretrained audio quality and GPU execution were not tested.

Who can help?

@sayakpaul @sanchit-gandhi Would the maintainers be open to a focused fix aligning Oobleck's encoder tiles to its hop length? I'd be happy to contribute the fix if the approach is approved.

Activity

  1. added
    bug
    on Nov 22, 2026
  2. YidaWeng commented on Nov 22, 2026

    @YidaWeng

    I’d like to work on this. I reproduced the 1024 → 1023 drop on CPU with the snippet above.

    The cause is in AutoencoderOobleck._tiled_encode: the tile windows aren’t aligned to hop_length, and the hop is inferred from the first tile, so the rounded trims lose a frame at the join. I have a local fix that rounds tile_sample_min_length / tile_sample_overlap (and therefore the stride) down to multiples of hop_length, trims with the exact hop, and adds a model-level regression test with deliberately non-aligned tile sizes. Tiled encode now matches the unsplit 1024 frames.

    Would maintainers be open to that approach? If @gorkadabo1 is already planning to submit this, I’m happy to defer.

  3. gorkadabo1 commented on Nov 22, 2026

    @gorkadabo1
    ContributorAuthor

    Thanks for looking into this and for offering to defer! As mentioned in the issue, I've already prepared and validated a fix with tests, so I'd like to take this one forward myself. I'm waiting for maintainer approval before opening the PR.

  4. yiyixuxu commented on Nov 28, 2026

    @yiyixuxu
    Collaborator

    @gorkadabo1
    thanks for opening the issue
    before we look into this, could you share an real use case example? e.g. a script generate correct audio but throw an error when tailing is enabled

  5. gorkadabo1 commented on Nov 28, 2026

    @gorkadabo1
    ContributorAuthor

    Hi @yiyixuxu, I've attached a runnable reproduction script. On upstream, the audio-to-audio pipeline succeeds without tiling but fails with tiling enabled. Both cases pass with my proposed fix.

    reproduce_stable_audio.py

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions