Skip to content

Reduce shared WavLM memory usage for MioCodec, MioTTS, and MeanVC2 - #954

Merged
0xShug0 merged 1 commit into
mainfrom
perf/wavlm-memory
Oct 17, 2026
Merged

0xShug0 merged 1 commit into
mainfrom
perf/wavlm-memory

Conversation

@0xShug0

@0xShug0 0xShug0 commented Oct 17, 2026

Copy link
Copy Markdown
Owner

Summary

Use gallocr unconditionally for the shared WavLM encoder instead of allocating storage for every context tensor. This lets non-overlapping intermediates reuse memory without changing model math or introducing an opt-in setting.

  • Preserve persistent position bias and all requested hidden-layer outputs across graph executions.
  • Create and upload masks only for the normalization/attention paths that consume them.
  • Release captured CUDA graph resources before freeing an allocator.
  • Keep existing session-owned graph caching and reuse.

One framework source file changes. No model-local, public-option, spec, kernel, or build changes.

A/B Results

Baseline: main 977dc40a. Debug builds (-O3 -g), RTX 5090 / Ryzen 9 7900X, eight threads. Existing MioCodec/MioTTS original GGUFs and MeanVC2 FP32. Sequential runs using the existing CLI path-test tool, conda qwen3-tts, --log, and 20 ms process memory sampling.

Backend Model Peak Memory Before (MiB) Peak Memory After (MiB) Warm RTF Before Warm RTF After
CUDA MioCodec 4,108 1,748 0.00605 0.00546
CUDA MioTTS 6,598 5,660 0.10596 0.10341
CUDA MeanVC2 4,776 2,192 0.03692 0.03662
Vulkan MioCodec 3,466 1,168 0.01741 0.01126
Vulkan MioTTS 5,973 5,034 0.11277 0.10976
Vulkan MeanVC2 4,182 1,599 0.05697 0.05065
CPU MioCodec 3,797 1,493 0.17578 0.11774
CPU MioTTS 6,494 5,556 1.86485 1.83905
CPU MeanVC2 4,462 1,881 0.21633 0.15403

GPU memory is sampled process peak VRAM; CPU memory is sampled peak RSS. Peaks cover the entire session. Warm RTF aggregates inference wall time/output duration after excluding the first warmup request. No measured performance regression; small timing differences are not statistical speedup claims.

Correctness And Lifecycle

Each model was tested in one session with a short warmup, a normal request, an exact repeat, a changed shorter reference/input, and a longer reference/input. MioTTS additionally changes the reference recording without changing its length, exercising a reused WavLM graph on a reference-cache miss. Audio lengths span 1.6, 3.2, and 5.95 seconds.

  • CPU and Vulkan: all 32 output WAVs are byte-identical to baseline.
  • CUDA MeanVC2: all five output WAVs are byte-identical.
  • CUDA MioCodec/MioTTS: output lengths match; worst waveform RMSE is 2.632e-7, minimum cosine similarity is 0.99999999999399. This is not byte-exact parity. Baseline CUDA repeated requests already show comparable tiny waveform variation (RMSE 2.437e-7 / 1.611e-7).
  • No non-finite samples, missing outputs, duration changes, or new repeat/changing-length failures in the final candidate.

Plapre is not included in this validation. These are focused C++ allocation A/B checks, not new Python parity or ASR evaluations.

@0xShug0
0xShug0 merged commit 03d1b46 into main Oct 17, 2026
6 checks passed
@0xShug0
0xShug0 deleted the perf/wavlm-memory branch October 17, 2026 23:13
cunba-ai pushed a commit to cunba-ai/audio.cpp that referenced this pull request Oct 28, 2026
…en3 one-pass voicing, voxcpm2 step graphs, f5 CUDA constants, WavLM, cosyvoice3 NPU)

Upstream commits 9464bbe..a8f9858 (9):
- perf(qwen3_tts): opt-in voicing chunked text in one decoder pass (0xShug0#910)
- server: default_session_options for configured and UI-loaded models (0xShug0#944)
- Kitten TTS 2 BF16/Q8/Q4 GGUF support (0xShug0#947)
- perf(voxcpm2): size step graphs by the request, not max_length (0xShug0#950)
- fix(f5_tts): free evicted graphs' staged CUDA constants (0xShug0#953)
- feat(cosyvoice3): flow DiT estimator on the Rockchip NPU (0xShug0#951)
- refactor(f5_tts): drop unused raw DiT weight store (0xShug0#956)
- WavLM memory reduced with graph allocation (0xShug0#954)
- server: voice presets carry request options (0xShug0#942)

# Conflicts:
#	src/framework/modules/speech_encoders/wavlm_encoder.cpp
#	src/models/qwen3_tts/session.cpp
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