Skip to content

omnivoice: fix CPU voice cloning (non-contiguous residual into ggml_sub in the audio tokenizer) - #1212

Merged
0xShug0 merged 1 commit into
0xShug0:mainfrom
ahmednabilfawzy89-cmyk:fix-omnivoice-cpu-residual-layout
Nov 5, 2026
Merged

0xShug0 merged 1 commit into
0xShug0:mainfrom
ahmednabilfawzy89-cmyk:fix-omnivoice-cpu-residual-layout

Conversation

@ahmednabilfawzy89-cmyk

Copy link
Copy Markdown
Contributor

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_bct starts as transpose_btc_to_bct(...), which is a ggml_permute view. On the first RVQ pass it goes straight into ggml_sub as 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, because ggml_sub's result is contiguous.

This is the same bug class as #936 (Fish DAC: CPU ggml_sub / ggml_div on 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 used audiocpp_server with 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.

16 steps unpatched CPU patched CPU Vulkan (RX 7900 XT)
CAM++ similarity 0.405 0.841 0.836
nearest speaker = the right one 2/8 8/8 8/8
WER 0.103 0.033 0.03–0.04
CER 0.049 0.011
takes with a bad head 8/24 0/24

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, and perf_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

…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]>
@0xShug0
0xShug0 merged commit 2878322 into 0xShug0:main Nov 5, 2026
7 checks passed
@0xShug0

0xShug0 commented Nov 5, 2026

Copy link
Copy Markdown
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!

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.

2 participants