perf: stateful streaming VAE decode — eliminate redundant overlap#212
Merged
Labmem-Zhouyx merged 1 commit intoOpenBMB:mainfrom Apr 15, 2026
Merged
Conversation
Streaming decode previously re-decoded 4 overlapping patches through the VAE each step, discarding 75% of the output. Replace with stateful decode that carries causal conv padding buffers between calls — one patch in, one patch out, no overlap. Changes: - Add StreamingVAEDecoder to audiovae/audio_vae_v2.py — caches CausalConv1d and CausalTransposeConv1d left-pad state between calls - AudioVAE.streaming_decode() context manager for clean lifecycle - _inference yields single-patch latents in streaming mode - _generate and _generate_with_prompt_cache use StreamingVAEDecoder Streaming VAE decode time (isolated): 289ms → 148ms (2x faster) Stateful vs full decode: cosine 1.0000, max diff 0.0005 (more accurate than previous overlap approach at max diff 0.001) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Labmem-Zhouyx
added a commit
that referenced
this pull request
Apr 15, 2026
…ant overlap - StreamingVAEDecoder caches CausalConv1d/CausalTransposeConv1d left-pad state between calls — one patch in, one patch out, no overlap - _inference yields single-patch latents in streaming mode - 2x faster streaming VAE decode, more accurate (max diff 0.0005 vs 0.0011)
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
StreamingVAEDecodercachesCausalConv1dandCausalTransposeConv1dleft-pad state, matching the approach used in the WebGPU ONNX VAE portChanges
StreamingVAEDecodertoaudiovae/audio_vae_v2.pyAudioVAE.streaming_decode()context manager for clean lifecycle_inferenceyields single-patch latents in streaming mode (was 4-patch chunks)_generateand_generate_with_prompt_cacheuseStreamingVAEDecoderBenchmarks
Streaming VAE decode (isolated, 35 patches):
2x faster VAE decode, and more accurate (half the error of the overlap approach).
Correctness
generate()vsgenerate_streaming(): 1.0000Test plan
generate()vsgenerate_streaming()match🤖 Generated with Claude Code