Skip to content

fix(voxcpm2): correct the streaming decode rationale, drop right context - #623

Merged
0xShug0 merged 1 commit into
0xShug0:mainfrom
mduka:fix/voxcpm2-streaming-context-cleanup
Sep 20, 2026
Merged

0xShug0 merged 1 commit into
0xShug0:mainfrom
mduka:fix/voxcpm2-streaming-context-cleanup

Conversation

@mduka

@mduka mduka commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #622 / #620.

Summary

#622 fixed the clicks at every 160 ms patch boundary of the VoxCPM2 streaming path, but I explained the cause wrongly there: the PR says the AudioVAE decoder is not causal. It is. causal_conv1d pads on the left only and causal_conv_transpose1d crops to the causal output length. The clicks came from invoking that causal decoder statelessly per patch, so its convolution history restarted from zero padding at every boundary. Decoding the preceding patches in the same window rebuilds that history. Right context cannot change anything for a causal decoder, and the measurements in #620 already showed that ("same as with 0" for every left value).

This PR corrects the rationale where #622 wrote it into the tree and removes what only made sense under the wrong explanation. Nothing in it has shipped in a release yet (last tag is v0.8.1).

Change

  • Comments in types.h and generator.cpp and the docs/tts.md entry state the real cause. Benchmark numbers are gone from the header.
  • voxcpm2.stream_right_context is removed, together with the tail flush and the back trim it needed. An unknown option is ignored by the server, so old configs that still set it keep working.
  • VoxCPM2StreamingChunk::generated_patches is again the number of patches generated so far, as before fix(voxcpm2): decode streaming patches with left context #622. fix(voxcpm2): decode streaming patches with left context #622 assigned the emitted-patch index, which only coincided with it for right context 0.
  • stream_left_context is bounded to [0, 8] (kVoxCPM2MaxStreamLeftContext), checked in validate_generation_options and in the request-option parsing. Every emitted patch re-decodes the whole window, so the cost grows with the value while the deviation sits at its floor from 5 on; 16 is already slower than real time on the hardware below.

Default 3 is unchanged. voxcpm2 family plus its docs entry only, no framework code. 4 files, +58/−79.

Validation

Build as in #622 (Vulkan, RelWithDebInfo, AUDIOCPP_MODEL_SET=full), voxcpm2-q8_0.gguf, AMD Strix Halo (gfx1151), served through audiocpp_server with one streaming and one offline id on the same weights. Same method as #620: plain English text, seed 7, temperature 0.7, 8.80 s of audio, 54 patch boundaries, streaming WAV against offline WAV of the same fixed-seed features. The offline reference has one natural step > 0.1 on the grid.

left max deviation samples off by > 0.01 boundary steps > 0.1 RTF
0 0.5466 39.5 % 6 of 54 0.56
1 0.0835 2.7 % 1 of 54 0.59
3 (default) 0.0015 0.0 % 1 of 54 0.64
4 0.0005 0.0 % 1 of 54 0.71
8 0.0004 0.0 % 1 of 54 0.95
16 (before the cap) 0.0004 0.0 % 1 of 54 1.44
9, −1 rejected: stream_left_context must be between 0 and 8

Offline reference: RTF 0.51. The default's output is bit-identical to #622's. The CLI path (--mode streaming --request-option voxcpm2.stream_left_context=9) rejects the same way through validate_generation_options.

Backend tested: Vulkan. CPU build of the family compiles; CUDA / HIP / Metal untested.

Follow-ups, not in this PR

#622 fixed the clicks at every 160 ms patch boundary of the streaming path by
decoding each patch inside a window of preceding patches, but it explained the
cause as a non-causal AudioVAE decoder. That is wrong: the decoder is causal
(causal_conv1d pads on the left only, causal_conv_transpose1d crops to the
causal output length). The clicks came from invoking that causal decoder
statelessly per patch, so its convolution history restarted from zero padding
at every boundary. Left context rebuilds the history; right context cannot
change anything, which the measurements in #620 already showed ("same as with
0" for every left value).

- Correct the comments in types.h and generator.cpp and the docs/tts.md entry.
- Remove voxcpm2.stream_right_context together with the tail flush and back
  trim it needed. The option never shipped in a release.
- chunk.generated_patches is again the number of patches generated so far, as
  before #622 (the emitted-patch index that #622 assigned only coincided with
  it for right context 0).
- Bound stream_left_context to [0, 8] (kVoxCPM2MaxStreamLeftContext), checked
  in validate_generation_options and in the request-option parsing. Every
  emitted patch re-decodes the whole window, so the cost grows with the value
  while the deviation is at its floor from 5 on.

Measured on VoxCPM2 Q8 (48 kHz, Vulkan, seed 7, temperature 0.7, 8.80 s of
audio, 54 boundaries) as streaming WAV against offline WAV, same method as
#620; the offline reference has one natural step > 0.1 on the grid:

  left  max deviation  samples off by >0.01  boundary steps >0.1  RTF
     0         0.5466                39.5 %             6 of 54  0.56
     1         0.0835                 2.7 %             1 of 54  0.59
     3         0.0015                 0.0 %             1 of 54  0.64
     4         0.0005                 0.0 %             1 of 54  0.71
     8         0.0004                 0.0 %             1 of 54  0.94
    16         0.0004                 0.0 %             1 of 54  1.44

Default (3) is unchanged and bit-identical to #622's output. 9 and -1 are
rejected. The upstream VoxCPM release 2.0.3 replaced its equivalent 4-patch
overlap decode with a stateful StreamingVAEDecoder (OpenBMB/VoxCPM#212); that
is the long-term shape for this path and a separate change.
@0xShug0
0xShug0 merged commit 6c70f32 into 0xShug0:main Sep 20, 2026
6 checks passed
@0xShug0

0xShug0 commented Sep 20, 2026

Copy link
Copy Markdown
Owner

Thanks for following up and continuing to improve this! PR merged.

Sign up for free to 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