Add llama-cpp-python backend for CosyVoice3#1872
Open
Ferraronp wants to merge 4 commits into
Open
Conversation
Syphys
added a commit
to Syphys/maestria
that referenced
this pull request
May 25, 2026
Out of ~1870 GGUFs in a typical local catalogue, ~30-50 are not chat models at all (TTS, audio codec, embedding, vision, video). Running the 28-prompt suite against them wastes minutes and pollutes the radar with all-zero scores. Three signals catch them, ordered cheapest to most structural; any one alone is enough to quarantine. Tier 1 - `general.architecture` blacklist (header-only, instant): extend `NON_GENERATIVE_ARCH` with the dedicated TTS arch names introduced by Qwen3-TTS / OuteTTS / Parler-TTS / Kokoro / MOSS-TTS / SNAC-TTS / Qwen2-TTS GGUFs. Tier 2 - `general.name` regex (header-only, instant): `NON_CHAT_NAME_RE` matches `tokenizer|codec|vocoder|vq|cfm|tts`. Uses `[\W_]` boundary class instead of `\b` because JS regex treats `_` as a word char - `\btokenizer\b` does NOT match `Llamacpp_Tokenizer` (the Cosyvoice3 name). Tested against the real Cosyvoice GGUF + false-positive guards (Mistral, Qwen2.5-Math, Llama-3.1-Instruct, "Ottosaurus" do NOT match). Tier 3 - adaptive quarantine on non-text output (post-launch): `looksLikeNonTextResponse` in `characterize.ts` matches responses consisting entirely of `<|stop_1|>`-style audio codebook tokens. Plus a 5-consecutive-empty-response fallback for models that emit nothing at all. Throws an `Error` with "non-chat model" in the message - `characterizeAll`'s `isUnsupported` regex now catches that pattern so the model lands in `characterization_state:'failed'` and is never re-tried. Side change: read the GGUF header ONCE in `runCharacterization` (arch + name + embedding pooling all come from the same fs read). The `archOf` test seam is still honoured for shape parity. Also wire the `archiveServerLog` calls at the start of each per- model loop in `characterizeAll` AND at the head of `runCharacterization` so single-CARACTÉRISER triggers also get the fresh session log. `prompt_done` events now carry the full `DiagnosticRunEntry` so the renderer can live-update the Interactions tab without waiting for the whole-model signature to land on disk (consumed in the next commit). Refs: https://huggingface.co/cstr/qwen3-tts-1.7b-customvoice-GGUF (Qwen3-TTS arch convention) FunAudioLLM/CosyVoice#1872 (Cosyvoice3 llama-cpp-python backend - confirms it uses an LLM backbone with a separate audio tokenizer) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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
Adds optional llama-cpp-python inference backend for CosyVoice3, allowing CPU and low-VRAM inference using GGUF quantized models.
Changes
cosyvoice/cli/cosyvoice.py: Addedload_llama_cppandgguf_model_pathparameters toCosyVoice3.__init__. Overridesinference_zero_shot,inference_cross_lingual,inference_instruct2with llama.cpp path. Both streaming and non-streaming modes supported.cosyvoice/cli/model.py: Addedtts_with_external_tokensandtts_stream_external_llmmethods.README.md: Added llama-cpp-python backend installation and usage instructions.Usage
All existing inference methods (
inference_zero_shot,inference_cross_lingual,inference_instruct2) work unchanged.Performance (NVIDIA T4, fp16)
~2.6x faster inference on T4 GPU.
Pre-converted GGUF models
Available on Hugging Face: Ferraronp/CosyVoice3-qwen2.5-0.5b-speech-gguf
Converter: Ferraronp/CosyVoice-gguf-converter
Notes
CosyVoice3/Fun-CosyVoice3-0.5Bpip install llama-cpp-pythonload_llama_cpp=True, PyTorch LLM weights are not loaded to save VRAM