Skip to content

Refactor LFM3 Audio around shared LFM runtimes and weight helpers - #1210

Merged
0xShug0 merged 3 commits into
mainfrom
refactor/lfm-gguf-metadata-01
Nov 5, 2026
Merged

0xShug0 merged 3 commits into
mainfrom
refactor/lfm-gguf-metadata-01

Conversation

@0xShug0

@0xShug0 0xShug0 commented Nov 5, 2026

Copy link
Copy Markdown
Owner

LFM3 Audio currently maintains parallel decoder, encoder, weight-loading, and state-management code alongside the shared LFM framework. This refactor makes it use the shared runtimes, with session-owned cached graphs and explicit state ownership.

  • Consolidate asset loading and reuse framework weight helpers.
  • Share typed GGUF metadata reading with D1-Omni.
  • Reuse the LFM decoder and audio-encoder runtimes, including composed cached decoding for the audio codec.
  • Remove duplicated model-local implementations and clarify generator, prompt, codec, and asset ownership.
  • Keep multiplication-layout policy separate from convolution lowering and make zero attention extent consistently mean the full cache.

Measurements

Main versus this refactor, using Q8_0 packages on RTX 5090 and Ryzen 9 7900X with eight CPU threads. Matched warmed requests were measured in main–refactor–refactor–main order. TTS covers short and approximately 1,000-character passages; the longer passage generates roughly one minute of audio. ASR/S2S inputs are 6–14 seconds.

RTF is the mean warmed request RTF; TTFA measures the first streamed audio received by the client. Peak VRAM is per process, including model loading and reloads. Warmups and reloads are excluded from timing averages.

Offline performance:

Backend Task Main RTF Refactor RTF Main peak MiB Refactor peak MiB
CUDA TTS 0.04568 0.04550 2727 2713
CUDA ASR 0.00804 0.00796 2715 2705
CUDA S2S 0.05567 0.05503 2971 2955
VULKAN TTS 0.07921 0.07567 2140 2124
VULKAN ASR 0.00897 0.00896 2145 2137
VULKAN S2S 0.08642 0.08396 2369 2349
CPU TTS 0.52091 0.50551 — —
CPU ASR 0.13363 0.13164 — —
CPU S2S 0.67312 0.67891 — —

Streaming performance:

Backend Task Main RTF Refactor RTF Main TTFA ms Refactor TTFA ms Main peak MiB Refactor peak MiB
CUDA TTS 0.05218 0.05142 11.2 8.8 2681 2673
CUDA S2S 0.06183 0.06123 54.3 52.5 2935 2921
VULKAN TTS 0.08774 0.08407 22.6 19.2 2078 2069
VULKAN S2S 0.09908 0.09365 67.1 63.2 2330 2312
CPU TTS 0.53795 0.52722 219.1 185.8 — —
CPU S2S 0.69031 0.67339 913.5 899.0 — —

CPU inference uses host memory. Offline TTS peak RSS increased from 2,616 to 2,660 MiB; the other CPU paths stayed around 2.5–2.8 GiB.

Correctness and lifecycle

  • D1: all 36 paired decision outputs match exactly across CUDA, Vulkan, and CPU, including probabilities.
  • LFM3 CUDA/Vulkan: all 120 paired outputs match exactly across offline TTS, ASR, S2S, and streaming TTS/S2S.
  • CPU ASR: all 12 paired transcripts match exactly.
  • Native CPU TTS/S2S sampled audio differs from main, and some S2S replies differ. CPU timings therefore compare independently sampled generations rather than identical token sequences.
  • Independent ASR checks returned 0% WER on all eight short/long CPU TTS outputs across both revisions and offline/streaming modes.
  • CPU F32 TTS/S2S controls have waveform cosine similarity above 0.9999999998, with at most one PCM16 unit of difference; the S2S text matches.
  • All 72 session sequences passed repeated-request, input-switching, and unload/reload checks, with successful server shutdowns. No token-limit truncation was observed.

Consolidate model components, use framework weight stores and cached decoder/encoder runtimes, and remove inference debug code. Adapt component and model tests to the new boundaries.

Validation: git diff --check. This refactor has not been built or tested.
@0xShug0

0xShug0 commented Nov 5, 2026

Copy link
Copy Markdown
Owner Author

@ykhrustalev I did some refactoring to LFM3.0 to reuse the shared LFM runtimes and weight helpers, remove duplicated code, and clarify state ownership. Hopefully I haven’t missed anything important. Please let me know if you spot anything.

A reusable S2S session-management template is next on my roadmap, since we already support several S2S models.

@0xShug0
0xShug0 merged commit db84f67 into main Nov 5, 2026
12 checks passed
@0xShug0
0xShug0 deleted the refactor/lfm-gguf-metadata-01 branch November 5, 2026 18:30
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