Repository navigation
omnivoice: fix CPU voice cloning (non-contiguous residual into ggml_sub in the audio tokenizer) - #1212
Merged
0xShug0 merged 1 commit intoNov 5, 2026
Conversation
…tokenizer encoder On the CPU backend, the first ggml_sub in HiggsAudioV2EncoderGraph's RVQ loop reads residual_bct (a ggml_permute view from transpose_btc_to_bct) as if it were contiguous, so every codebook after the first is computed from a wrong residual. The reference voice is encoded wrong and voice cloning on CPU loses the speaker. Same bug class as 0xShug0#936. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Owner
|
@ahmednabilfawzy89-cmyk Good catch and thanks for the fix. Tested on two CPUs: one CAM++ is from 0.2 to 0.9, another is from 0.28 to 0.87. WER reminas the same or become better. PR merged! |
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.
Problem
OmniVoice voice cloning on the CPU backend loses the reference speaker. The same request on Vulkan sounds right; on CPU the output sounds like a different person, the WER is higher, and words from the reference sample sometimes leak into the start of the take.
Cause
In
HiggsAudioV2EncoderGraph(src/models/omnivoice/audio_tokenizer.cpp),residual_bctstarts astranspose_btc_to_bct(...), which is aggml_permuteview. On the first RVQ pass it goes straight intoggml_subas src0. The CPU binary op reads src1 by stride but src0 as if it were contiguous, so the first residual is wrong. Every codebook after the first is then computed from that bad residual, and the reference voice is encoded wrong. Later passes are fine, becauseggml_sub's result is contiguous.This is the same bug class as #936 (Fish DAC: CPU
ggml_sub/ggml_divon a non-contiguous input).Fix
One line: pass
ensure_contiguous(ctx, residual_bct)as the first operand. This changes outputs on CPU only, and it does nothing to the result on backends that already handle the view.Validation (runtime, not just code reading)
Tested on v0.9.3 (41c1f8f), where the line is identical (this PR applies it to
main, line 1970). Linux x64 (Xeon Platinum 8270), CPU build with the release flags (-DENGINE_ENABLE_NATIVE_CPU=OFF -DENGINE_ENABLE_CPU_ALL_VARIANTS=ON, no CUDA/Vulkan). The unpatched build first reproduced the release binary's WAV bit-identical, so this line is the only difference. I usedaudiocpp_serverwith OmniVoice voice cloning: 8 speakers × 3 Arabic lines = 24 jobs, seed 7. Speaker similarity is CAM++ cosine to the reference sample; WER/CER come from Whisper on the same jobs.At 8 steps: CAM++ 0.405 → 0.829, WER 0.253 → 0.086, bad heads 13/24 → 1/24. Generation time did not change measurably.
Things I ruled out first (one variable each): the HTTP server vs the CLI, q8 vs f16 weights, threading (1 thread gives the same result),
mem_saver, andperf_mode=off. The CPU-vs-Vulkan difference followed the backend alone.Limits: one seed, one CPU (Linux x64), and the scoring was done by models, not by people listening. I haven't run it on Windows or macOS.
🤖 Generated with Claude Code