Fix PocketTTS Mimi decoder CPU crash: restore context-tensor backing removed in d98123e - #76
Conversation
|
Thank you @adambenhassen! I validated the PR locally. The CPU issue is real, and this patch does fix the crash. One concern: the restored ggml_backend_alloc_ctx_tensors(...) path also runs on CUDA, which causes the VRAM usage regression. d98123e was introduced to reduce the memory usage on CUDA #55 So I think the extra context tensor backing should be gated to CPU only. That should keep the CPU fix while avoiding a CUDA peak-memory regression. |
|
@adambenhassen Let me know if the PR is ready (just testing and see updates...). |
Ready! Gating done in a590f43: context-tensor backing now only runs when Also, while testing the failure paths I found a small leak: if graph allocation throws in a constructor, the destructor never runs and the params buffer leaked. c215af6 fixes that (cleanup helper now frees it) plus null-checks the alloc so it fails with a clear error instead of a later If CUDA peak VRAM looks good on your side, should be all set 👍 |
|
@adambenhassen Thanks! Tested and worked well. Merged. |
…removed in 7decb4b (0xShug0#76) * Restore PocketTTS Mimi decoder context tensor allocation * Gate Mimi decoder context tensor backing to host backend * Handle Mimi decoder context tensor allocation failure
…removed in d98123e (0xShug0#76) * Restore PocketTTS Mimi decoder context tensor allocation * Gate Mimi decoder context tensor backing to host backend * Handle Mimi decoder context tensor allocation failure
Problem
On
--backend cpu, every PocketTTS synthesis aborts with:The flow-LM stage runs fine; the crash is on entry to the Mimi codec decoder, deterministically, in both the server and the CLI. CUDA is unaffected.
Repro
Cause
d98123e ("Harden PocketTTS Mimi decoder graph allocation") removed every
ggml_backend_alloc_ctx_tensors(ggml_ctx_, backend_)call in mimi_decoder.cpp, leaving allocation toggml_gallocr_alloc_graphalone. That call gave the decoder's context tensors (graph inputs plus persistent state: KV-cache prefixes, positions, attention mask, latents) stable lifetime-long backend buffers. The CPU path uses a persistent graph plan and repeatedrun()writes into those tensors; gallocr's graph-scoped allocation leaves them unbacked, so on CPU they hitbuffer == NULL. CUDA's path kept them backed, hiding the regression.Fix
Restore
ggml_backend_alloc_ctx_tensors(buffer member + destructor free) in the 5 runtime constructors, while keeping d98123e's gallocr null-checks andrelease_partial_graph_runtimehelper. +25/-0, no deletions.Verification
CPU build; PocketTTS-100M english;
--backend cpu, 4 threads on an Intel N100: valid 24 kHz mono WAV via both CLI and the OpenAI-compatible server (POST /v1/audio/speech), 3 back-to-back requests, no crash, RTF ~0.7.UPDATE:
ggml_backend_alloc_ctx_tensorsbehindcore::is_host_backend(backend_)in all 5 runtime constructors, per review. CUDA/Metal/Vulkan keep the gallocr-only allocation from d98123e, so the pocket_tts: failed CUDA alloc in MimiDecoder::decode aborts the whole server (GGML_ASSERT) — same class as the voice-prep issue fixed in 1627694 #55 VRAM reduction is preserved; only the CPU path (which uses the persistent graph plan) gets the context-tensor backing. Rebuilt and re-verified on CPU.ggml_backend_alloc_ctx_tensorsresult is now null-checked (immediateruntime_errorinstead of a laterGGML_ASSERTabort), andrelease_partial_graph_runtimealso frees the params buffer so a constructor throw after gallocr failure no longer leaks it.