Skip to content

Avoid redundant VoxCPM2 KV cache staging and resets - #1085

Merged
0xShug0 merged 2 commits into
mainfrom
fix/voxcpm2-kv-import-lifecycle
Oct 25, 2026
Merged

0xShug0 merged 2 commits into
mainfrom
fix/voxcpm2-kv-import-lifecycle

Conversation

@0xShug0

@0xShug0 0xShug0 commented Oct 25, 2026

Copy link
Copy Markdown
Owner

VoxCPM2 still staged and uploaded full-capacity KV buffers on both reset and prefill import. Remove the redundant reset and enable direct prefix uploads with backend tail zeroing. This eliminates cache-sized host staging while preserving every cache byte.

The shared TransformerKVCacheOptions::direct_import option defaults to false and is enabled only by VoxCPM2. It requires dense F32 non-ring caches; existing callers retain their original behavior. Attention dimensions, precision, sampling, CFM conditioning uploads, and prefill graph construction are unchanged.

#950 already addressed the maximum-length attention-cache sizing reported in #917. This PR addresses the remaining KV reset/import overhead; the smaller optimization suggestions in that issue are outside this change.

Validation used debug builds and an existing Q8 GGUF with its embedded spec:

  • All 33 original A/B WAV pairs were byte-identical to main across CUDA, Vulkan, and CPU, covering offline/streaming, voice cloning/TTS, both mem_saver settings on CUDA, alternating lengths/references, consecutive repeats, and four-chunk continuation.
  • Final Vulkan offline/streaming and CPU A–B–A checks also passed with all 10 WAVs byte-identical to main.
  • Cache unit tests cover full-buffer byte equality, signed zero, poisoned stale rows, shorter/empty/full imports, reset after truncation, and invalid storage/ring configurations.

CUDA RTX 5090, Q8, 8 threads, default settings (mem_saver=true, perf_mode=off): three sequential paired sessions, each with one excluded warmup and five measured clone requests. Run order alternated. RTF uses canonical session.wall_ms divided by output duration.

Metric Main This PR
Mean warm RTF 0.13227 0.13125
Peak VRAM 5,226 MiB 5,226 MiB

The measured RTF reduction is only 0.76%; no substantial speedup or peak-VRAM reduction is claimed. All 18 WAV pairs in the repeated performance comparison were byte-identical. The reported Jetson hardware was not tested.

Closes #917.

@0xShug0
0xShug0 merged commit efdf97e into main Oct 25, 2026
7 checks passed
@0xShug0
0xShug0 deleted the fix/voxcpm2-kv-import-lifecycle branch October 25, 2026 19:54
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.

voxcpm2 decode path: attention runs over the full max_length KV cache every token, plus ~1.2 GB of per-request cache zero-fills

1 participant