Skip to content

feat(models): add LFM3-Audio (lfm3_audio) speech in and speech out - #3610

Merged
inureyes merged 3 commits into
mainfrom
feature/issue-3214-lfm3-audio
Dec 1, 2026
Merged

inureyes merged 3 commits into
mainfrom
feature/issue-3214-lfm3-audio

Conversation

@inureyes

@inureyes inureyes commented Dec 1, 2026

Copy link
Copy Markdown
Member

Closes #3214.

Summary

Adds LFM3-Audio (model_type: lfm3_audio, Lfm3AudioForConditionalGeneration): an LFM3 text backbone that listens through a log-mel front end, three strided convolutions and a 17-layer LFM2 encoder, and speaks by writing frames of 12 codebook codes that a bidirectional MaskGIT depth decoder samples in three passes. The bundled Liquid codec turns frames into 24 kHz audio, and one slot loop interleaves text tokens and speech frames.

What landed

  • src/audio/lfm3_audio/ with config, features, encoder, depth, sampler, codec, prompt and slots, each with a _tests.rs.
  • src/models/lfm3_audio.rs: the Lfm3AudioModel wrapper over Lfm3Model, implementing LanguageModel (delegating the sequence-state hooks) and the slot-loop SlotModel.
  • Registration: ModelType::Lfm3Audio (lfm3_audio) in detection, ALL_MODEL_TYPES, name/family, model metadata, the architecture registry (mlxcel arch shows text+audio in, audio out), LoadedModel dispatch, supports_audio_input, the special weight loader and the nonstandard directory loader.
  • Reuse: the encoder trunk runs Lfm2Model::forward_hidden_with_mask (new hidden-only, 32-key windowed causal path); the depth and codec trunks run Lfm3Model hidden-only; the STFT side adds nemotron_codec::stft::istft_windowed (caller window, no second ISTFT implementation).
  • CLI: --system-prompt (alias --sys) for every family; LFM3-Audio --output-audio runs the slot loop instead of the post-hoc Qwen3-Omni path, with --speech-mode auto|audio|interleaved|text; without --output-audio the generic engine drives text-only generation and stops at <|audio_start|> or <|mixed_start|>.
  • Server: Lfm3AudioProvider on its own AudioWorker provides both directions (transcribe: Perform ASR. or Perform ASR in <language>.; synthesize: Perform TTS in <voice>., default American English using a female voice); prepare_request_vlm_embeddings expands the audio placeholders for /v1/chat/completions input_audio. Startup registers the provider for ModelType::Lfm3Audio.
  • Docs and licensing: docs/supported-models.md LFM3-Audio entry (task prompts, --speech-mode, defaults, limits) and a NOTICE section for the mlx-vlm port and Liquid's Apache-2.0 reference.

Verification

  • cargo test --profile test-fast --features cuda --lib lfm3 -- --test-threads=1: 44 passed, 0 failed, 3 ignored.
  • cargo test --profile test-fast --features cuda --lib variant -- --test-threads=1: 59 passed (includes the ALL_MODEL_TYPES completeness test).
  • cargo fmt --all.
  • Real checkpoint, LiquidAI/LFM3-Audio-2B-MLX-8bit on GB10 under gpu-lock:
    • ASR: --audio of the TTS output with --system-prompt "Perform ASR in English." prints Hello there!.
    • TTS: -p "Hello there!" --system-prompt "Perform TTS in American English using a female voice." --output-audio writes a 24 kHz WAV (14 frames, 1.12 s) that transcribes back to Hello there!.
    • Interleaved: --audio question with --system-prompt "Respond with interleaved text and audio." --output-audio --speech-mode interleaved prints Hey! What can I help you with today? and writes 35 frames (2.80 s) whose ASR transcript matches the text.

Known gaps

  • Numeric parity against mlx-vlm (issue acceptance item on committed logits/speech/audio fixtures) was not produced: mlx-vlm is not installed and Python MLX does not run on this Linux host, so no upstream fixtures could be generated. The unit tests use hand-computed and naive-DFT references instead; the real-checkpoint behavioral checks above pass.
  • The server endpoints are wired (/v1/audio/transcriptions, /v1/audio/speech, chat input_audio) but were not exercised end-to-end over HTTP here; the CLI drives the same slot loop.
  • -sys is spelled --sys as the alias: clap has no multi-character short flag.
  • mlxcel arch reports a single output value, so LFM3-Audio shows audio (its text output is not a separate axis).

@inureyes
inureyes marked this pull request as draft December 1, 2026 08:48
@inureyes
inureyes force-pushed the feature/issue-3214-lfm3-audio branch from 924e6c1 to b01b2fc Compare December 1, 2026 08:55
@inureyes inureyes added the status:done Completed label Dec 1, 2026
Add LFM3-Audio as ModelType::Lfm3Audio: a log-mel front end, three strided convolutions, a 17-layer LFM2 encoder and projector feed an LFM3 backbone, and one slot loop interleaves text tokens with 80 ms speech frames sampled by a bidirectional MaskGIT depth decoder and decoded by the bundled Liquid codec.

- New src/audio/lfm3_audio modules (config, features, encoder, depth, sampler, codec, prompt, slots) with unit tests, and the src/models/lfm3_audio.rs wrapper.
- Registration in detection, ALL_MODEL_TYPES, model metadata, the architecture registry, LoadedModel dispatch, the special weight loader and the nonstandard directory loader.
- CLI: --system-prompt (alias --sys), --speech-mode, and an LFM3-Audio --output-audio slot-loop path beside the unchanged Qwen3-Omni one.
- Server: Lfm3AudioProvider for /v1/audio/transcriptions and /v1/audio/speech, plus chat input_audio embeddings.
- docs/supported-models.md and NOTICE.

Verification: the lfm3 and registry unit tests pass; on LiquidAI/LFM3-Audio-2B-MLX-8bit the CLI transcribes its own TTS output back to "Hello there!" and produces an interleaved text+speech turn. Numeric parity against mlx-vlm was not generated (Python MLX does not run on this Linux host).
@inureyes
inureyes force-pushed the feature/issue-3214-lfm3-audio branch from b01b2fc to e11ad4f Compare December 1, 2026 09:16
@inureyes
inureyes marked this pull request as ready for review December 1, 2026 09:18
@inureyes
inureyes merged commit b468c96 into main Dec 1, 2026
32 of 36 checks passed
@inureyes
inureyes deleted the feature/issue-3214-lfm3-audio branch December 1, 2026 09:18
inureyes added a commit that referenced this pull request Dec 1, 2026
## Problem

`main` at `b468c9628` fails two of the cheap consistency gates that every PR runs:

- `make verify-env-var-docs`: `MLXCEL_ENGRAM_OFFLOAD`, read in `src/models/deepseek_v41.rs:137`, is neither documented on `docs/environment-variables.md` nor allowlisted. Introduced by #3603.
- `make verify-used-by`: `create_causal_mask_with_window_full` (`src/lib/mlxcel-core/src/utils.rs`) has an unaccounted caller, `src/audio/lfm3_audio/encoder.rs`. Introduced by #3610.

Both are documentation-side omissions; the code is correct. Either one alone would fail the contract gate of any PR that runs them, so every in-flight PR inherits a red gate it did not cause.

## Change

- Document `MLXCEL_ENGRAM_OFFLOAD` next to `MLXCEL_PLE_IO` and `MLXCEL_PLE_CACHE_BYTES`, the existing entries for external n-gram table handling. It is an operator-facing load switch, not an internal diagnostic, so documenting it is the right fix rather than allowlisting it.
- Name the LFM3-Audio encoder in the `Used by:` roster of `create_causal_mask_with_window_full`.

## Verification

```
make verify-env-var-docs    # PASS
make verify-used-by         # PASS
```

Both were confirmed failing on a pristine `origin/main` worktree before the change, and pass after it. No Rust behavior changes.
@inureyes inureyes added arch:hybrid Hybrid attention stack (linear/sliding/full or attention+SSM interleave) area:models Model architectures, weights, loading, metadata modelsize:small 4-bit checkpoint <= 10GB; fast iteration, safe for smoke tests modeltype:audio Audio or speech model priority:medium Medium priority type:enhancement New features, capabilities, or significant additions labels Dec 1, 2026
inureyes added a commit to Jaeyeong-CHOI/mlxcel that referenced this pull request Dec 1, 2026
The audio guard scan added for lablup#3574 covers every test file under src/audio, but LFM3-Audio (lablup#3610) landed on main afterwards with 32 unguarded tests, so the merged tree failed audio_gpu_modules_take_mlx_test_guard_before_touching_arrays. The codec, depth, encoder, prompt, sampler and slots tests build MLX arrays and now take mlx_test_guard first. config_tests.rs and features_tests.rs only parse JSON and run the CPU mel front end, so they join the reviewed CPU-only list instead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch:hybrid Hybrid attention stack (linear/sliding/full or attention+SSM interleave) area:models Model architectures, weights, loading, metadata modelsize:small 4-bit checkpoint <= 10GB; fast iteration, safe for smoke tests modeltype:audio Audio or speech model priority:medium Medium priority status:done Completed type:enhancement New features, capabilities, or significant additions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(models): add LFM3-Audio (lfm3_audio) speech in and speech out

1 participant