Repository navigation
Conversation
Ryu1845
marked this pull request as ready for review
November 13, 2026 05:31
Backport the applicable layout fixes from Zonos3: use SigmoidModule for the attention gate and materialize codebook index views with ensure_backend_addressable_layout before embedding lookup. Verified Q8_0 TTS and voice cloning on CUDA and Vulkan, including a five-second reference with the speaker encoder on the selected backend. The existing prompt test passes. Document the NVIDIA 550.144.03 shutdown crash in combined CUDA/Vulkan builds; Vulkan-only cloning exits cleanly.
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 Zyphra's ZONOS2 as the community family
zonos2: text to speech and voice cloning, offline and streaming, from the published Zyphra/ZONOS2-GGUF files. The runtime is written on audio.cpp framework modules and validated against Zyphra's ggml port Zyphra/zonos2.cpp.backbone.cpp): 28-layer gated GQA transformer with QK-norm and a per-head temperature, dense SwiGLU layers 0-2 and 27, and 16-expert MoE layers 3-26 (top-1, top-2 on layer 26) whose MLP router carries an EDA state across MoE layers. The router MLP is model-local; the routing tail (MoeModule::build_routing) and the expert matmuls (MoeModule::build) are the framework's. The optional expert cache usesDiskExpertWeightStorefor decode andStagedMoeRuntimefor prefill, with one staged runtime per top-k. F16 KV cache, flash attention for decode.sampler.cpp): port of the upstream Pythonsample_tts(penalty once per distinct code over generated frames only, top-k ties kept, softmax, top-p, min-p).codec_decoder.cpp): frameworkConv1dModule,ConvTranspose1dModule(col2im fast path, or unpadded + crop on the CPU) andSnake1dModule; windowed decoding with context frames for streaming.speaker_encoder.cpp): the framework mel front end plus the ECAPA graph, built for the exact frame count.encode_reference_only,speaker_embedding_file, conditioning rows (speaker background, accurate mode, speaking rate, quality buckets), fade-out, long-form chunking,StreamingAudioControllerstreaming.No framework change.
Build
cmake -S . -B build/zonos2 -DCMAKE_BUILD_TYPE=Release -DAUDIOCPP_MODEL_SET=custom -DAUDIOCPP_MODELS=zonos2 \ -DENGINE_ENABLE_OPENMP=OFF -DGGML_OPENMP=OFF cmake --build build/zonos2 -j 8 --target audiocpp_cli audiocpp_serverFor the parity tests add
-DENGINE_BUILD_TESTS=ON -DENGINE_BUILD_MODEL_TESTS=ON -DAUDIOCPP_ZONOS2_MODEL_DIR=$PWD/models/ZONOS2-GGUF -DAUDIOCPP_ZONOS2_PARITY_DIR=/tmp/zonos2-oracle.Run
Models
zonos2_q8_0(default)zonos2-q8_0.gguf,dac.gguf,spk-encoder.ggufParity
Oracle:
bash tests/community_models/zonos2/make_oracle.sh ../zonos2.cpp/build models/ZONOS2-GGUF assets/resources/a.wav /tmp/zonos2-oracle(zonos2.cpp0e08ea0). It also compilesoracle_decode.cppagainst the zonos2.cpp build tree to record its own teacher-forced KV-cache decode.The backbone is compared with zonos2.cpp's own prefill + KV-cache decode of the same rows: logits are bit-identical (CPU, 4 threads). The plan's first oracle was zonos2.cpp's single F32 prefill pass over the whole sequence (
--validate); zonos2.cpp's own decode departs from that pass on near-tied codes (argmax 96.7% / 95.1%), exactly like ours, so the test now pins the decode path and reports the prefill pass for information.Greedy (
temperature=0,repetition_penalty=1): 2,000 frames identical tozonos2-cli --greedy; audio within 3 LSB of 16-bit PCM. Streaming equals offline exactly;speaker_embedding_filecloning equals--voice-refcloning exactly; the expert cache equals the resident path exactly; ourencode_reference_onlyembedding has cosine 0.9999997 withspk-encoder-cli's.Quality
Qwen3-ASR-1.7B WER over 4 English prompts (numbers as words), speaker cosine from the ECAPA encoder against the reference clip, CPU:
The audio.cpp TTS number is one take of 16 (seed 2, shortest prompt) that repeated the sentence; the other 15 are word-perfect. The two runtimes share bit-identical logits but use different samplers (upstream Python's vs zonos2.cpp's), so seeded takes differ. A 1,284-character paragraph (7 chunks, Metal) gave 70.5 s of audio and 14.5% WER: one chunk dropped one sentence.
Performance
Apple M3, 16 GB, Q8_0, 14-word sentence; the machine was already swapping during these runs.
disk_expertszonos2-clion the same machine: 25.7 frames/s CPU (4 threads), 47.6 frames/s Metal.Server (CPU,
lazy_load, streaming session): 5POST /v1/audio/speechrequests (3 plain, 2voice_ref, one SSE with 15speech.audio.deltaevents beforespeech.audio.done) all returned 200; peak memory footprint 10.1 GB. Request wall times (91-129 s) were dominated by swap on this machine, so the voice-cache speed-up is not visible in them.Backends tested
CPU and Metal (Apple M3). CUDA and Vulkan untested.
Known limitations
zonos2.disk_experts(about 5 GB, much slower).License
Weights: Apache-2.0 (Zyphra/ZONOS2-GGUF). The runtime was written for audio.cpp and numerically validated against Zyphra/zonos2.cpp.