Expand description
Audio decoder for LFM2.5-Audio: vocoder GGUF loading + weight structures.
Three sub-models loaded from the vocoder GGUF:
- DecoderModel — samples 8 audio codes per frame from LLM embedding
- DepthformerModel — small 6-layer attention-only transformer (backbone of DecoderModel)
- Detokenizer — codes → spectrogram → PCM (not loaded here yet — Phase 5)
Structs§
- Audio
Decoder Weights - All weights for the audio decoder (loaded from vocoder GGUF).
- Codebook
Weights - Per-codebook embedding layer weights.
- Decoder
Config - Configuration for the decoder model (8-codebook sampling).
- Depthformer
Config - Configuration for the depthformer (small transformer inside the decoder).
- Depthformer
Layer Weights - Per-layer weights for one depthformer layer. Uses MmapWeight for GEMV to match ggml’s Q4_0 computation path.
- Depthformer
State - Runtime state for the depthformer (reset per audio frame).
- Detok
Layer Weights - Weights for one detokenizer LFM2 layer.
- Detokenizer
Config - Config for the detokenizer’s LFM2 backbone.
- Detokenizer
State - Runtime state for the detokenizer’s LFM2 backbone.
- Detokenizer
Weights - All detokenizer weights (loaded from vocoder GGUF).
- Istft
Streamer - Stateful streaming inverse STFT (overlap-add) processor.
Traits§
- Audio
Gpu - GPU-accelerated audio backend. Implementations provide Metal or WGPU dispatch for the depthformer (code sampling) and detokenizer (spectrum).
Functions§
- build_
gpu_ audio_ decoder - Try to construct a GPU audio decoder backend for the given vocoder GGUF file.
- build_
hann - Periodic Hann window of length
n_fft:w[n] = 0.5·(1 - cos(2π·n/n_fft)). - build_
idft_ basis - Build the real inverse-DFT basis for the GPU ISTFT.
- depthformer_
forward - Run one forward pass through the depthformer (1 token, n_embd input → n_embd output).
- depthformer_
forward_ inplace - In-place depthformer forward pass directly reading
state.depthformer_in. - depthformer_
forward_ into - In-place depthformer forward pass that avoids allocating a returning Vec.
- detok_
embed_ codes - Embed 8 audio codes into a single vector for the detokenizer. Looks up each code with per-codebook offset, averages across codebooks.
- detokenize_
to_ spectrum - Run the detokenizer: codes → spectrogram frames (before ISTFT).
- embed_
audio_ token - Convert 8 audio codes back into an embedding for feeding to the LLM.
- istft_
to_ pcm - Convert spectrogram frames to PCM audio samples via ISTFT.
- sample_
audio_ frame - Sample one audio frame (8 codes) from an LLM embedding.
- upsample
- Linear interpolation upsample: 1 token → n_up tokens.