Skip to content

fix(cosyvoice): match non-CUDA model precision to inference inputs - #2253

Merged
debpalash merged 2 commits into
mainfrom
fix/cosyvoice-cpu-dtype
Sep 20, 2026
Merged

debpalash merged 2 commits into
mainfrom
fix/cosyvoice-cpu-dtype

Conversation

@debpalash

@debpalash debpalash commented Sep 20, 2026 •

Copy link
Copy Markdown
Owner

Summary

CosyVoice can load bf16 LLM weights on a CPU-only host while its token inputs remain float32. Normalize the managed sidecar's LLM, flow and vocoder to float32 when CUDA is unavailable. CUDA precision remains unchanged, and existing models are retained.

Testing

  • Non-CUDA regression fails before the fix and passes after; CUDA dtype preservation is also covered.
  • 17 sidecar tests pass with HF_HUB_OFFLINE=1 and an empty HF cache.

Related to #2096. This repairs the reported dtype mismatch only; dependency installation, truncation and audible quality still require investigation, so it must not close that issue.

Stacked on #2244; retarget to main after that rollup lands. Full CI and review are required before merge.

When CUDA is unavailable, CosyVoice converts the LLM, flow, and vocoder weights to float32 to match float32 token inputs; CUDA precision remains unchanged. This prevents CPU dtype failures while retaining existing models. Tests cover both CUDA dtype preservation and non-CUDA behavior; dependency installation, truncation, and audio quality remain out of scope.

@greptile-apps

greptile-apps Bot commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Retrigger

The PR appears safe to merge with no outstanding merge-changing issues identified.

Summary

Normalizes CosyVoice LLM, flow, and vocoder components to float32 on non-CUDA hosts while preserving CUDA-selected precision, with regression coverage and synchronized documentation.

Reviews (2) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..."

Base automatically changed from fix/reviewed-electron-rollup to main September 20, 2026 13:47
@coderabbitai

coderabbitai Bot commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: debpalash/VoiceStudio/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 62df9f6a-13df-4272-ac3b-d105379ec056

📥 Commits

Reviewing files that changed from the base of the PR and between ba25c46 and ef5331d.

📒 Files selected for processing (4)
  • CHANGELOG.md
  • backend/engines/cosyvoice_subprocess/main.py
  • docs/engines/cosyvoice.md
  • tests/test_cosyvoice_subprocess.py

Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review.


📝 Walkthrough

Walkthrough

CosyVoice now converts its LLM, flow, and vocoder components to float32 when CUDA is unavailable. Tests verify both CUDA paths, and documentation records the precision behavior.

Changes

CosyVoice precision handling

Layer / File(s) Summary
CPU model precision normalization
backend/engines/cosyvoice_subprocess/main.py
_load_model converts the llm, flow, and hift components to floating-point precision when CUDA is unavailable.
Precision behavior validation
tests/test_cosyvoice_subprocess.py, docs/engines/cosyvoice.md, CHANGELOG.md
Tests cover CUDA and non-CUDA dtypes and finite CPU outputs. Documentation and the changelog describe the float32 normalization and retained CUDA precision.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

🚥 Pre-merge checks | ✅ 7 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description includes a summary and testing details, but it omits the required Changes, Type, Checklist, and Release cadence sections from the repository template. Add the missing template sections. List the key changes under Changes, select the applicable Type items, complete the Checklist including the smoke-matrix status, and include the required Release cadence text or confirm that it applies unch…
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 2 files. (2 skipped: 2 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (7 passed)
Check name Status Explanation
Title check ✅ Passed The title uses the required Conventional Commit format with the cosyvoice scope and accurately describes the non-CUDA precision fix. The issue reference is present in the pull request body as `#2096…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Cross-Platform Default Parity ✅ Passed The default loading path changes at backend/engines/cosyvoice_subprocess/main.py:162-169, but it branches on CUDA availability, not on macOS, Windows, or Linux. All non-CUDA hosts use float32, while…
I18n Completeness (21 Locales) ✅ Passed The PR changes only CHANGELOG.md, backend/engines/cosyvoice_subprocess/main.py, docs/engines/cosyvoice.md, and tests/test_cosyvoice_subprocess.py. The authoritative diff contains no changed frontend f…
Local-First Guarantee ✅ Passed The authoritative diff changes only the CosyVoice sidecar precision handling, documentation, changelog, and an in-memory test. The runtime addition imports torch, checks torch.cuda.is_available(),…
Backward Compatibility ✅ Passed No backward-compatibility failure is introduced. The PR changes only the CosyVoice sidecar load path, documentation, changelog, and tests; it changes no database, voice, project, settings, or migratio…
Full details: Description check

Resolution

Add the missing template sections. List the key changes under Changes, select the applicable Type items, complete the Checklist including the smoke-matrix status, and include the required Release cadence text or confirm that it applies unchanged.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 2 files. (2 skipped: 2 unsupported.)

  • Fix all pre-merge checks with AI

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@debpalash
debpalash merged commit a7bc5be into main Sep 20, 2026
15 checks passed
@debpalash
debpalash deleted the fix/cosyvoice-cpu-dtype branch September 20, 2026 15:01
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.

1 participant