Repository navigation
feat(models): add LFM3-Audio (lfm3_audio) speech in and speech out - #3610
Merged
Merged
Conversation
inureyes
marked this pull request as draft
December 1, 2026 08:48
inureyes
force-pushed
the
feature/issue-3214-lfm3-audio
branch
from
December 1, 2026 08:55
924e6c1 to
b01b2fc
Compare
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
force-pushed
the
feature/issue-3214-lfm3-audio
branch
from
December 1, 2026 09:16
b01b2fc to
e11ad4f
Compare
inureyes
marked this pull request as ready for review
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.
26 tasks
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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/withconfig,features,encoder,depth,sampler,codec,promptandslots, each with a_tests.rs.src/models/lfm3_audio.rs: theLfm3AudioModelwrapper overLfm3Model, implementingLanguageModel(delegating the sequence-state hooks) and the slot-loopSlotModel.ModelType::Lfm3Audio(lfm3_audio) in detection,ALL_MODEL_TYPES, name/family, model metadata, the architecture registry (mlxcel archshows text+audio in, audio out),LoadedModeldispatch,supports_audio_input, the special weight loader and the nonstandard directory loader.Lfm2Model::forward_hidden_with_mask(new hidden-only, 32-key windowed causal path); the depth and codec trunks runLfm3Modelhidden-only; the STFT side addsnemotron_codec::stft::istft_windowed(caller window, no second ISTFT implementation).--system-prompt(alias--sys) for every family; LFM3-Audio--output-audioruns the slot loop instead of the post-hoc Qwen3-Omni path, with--speech-mode auto|audio|interleaved|text; without--output-audiothe generic engine drives text-only generation and stops at<|audio_start|>or<|mixed_start|>.Lfm3AudioProvideron its ownAudioWorkerprovides both directions (transcribe:Perform ASR.orPerform ASR in <language>.;synthesize:Perform TTS in <voice>., defaultAmerican English using a female voice);prepare_request_vlm_embeddingsexpands the audio placeholders for/v1/chat/completionsinput_audio. Startup registers the provider forModelType::Lfm3Audio.docs/supported-models.mdLFM3-Audio entry (task prompts,--speech-mode, defaults, limits) and aNOTICEsection 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 theALL_MODEL_TYPEScompleteness test).cargo fmt --all.LiquidAI/LFM3-Audio-2B-MLX-8biton GB10 undergpu-lock:--audioof the TTS output with--system-prompt "Perform ASR in English."printsHello there!.-p "Hello there!" --system-prompt "Perform TTS in American English using a female voice." --output-audiowrites a 24 kHz WAV (14 frames, 1.12 s) that transcribes back toHello there!.--audioquestion with--system-prompt "Respond with interleaved text and audio." --output-audio --speech-mode interleavedprintsHey! What can I help you with today?and writes 35 frames (2.80 s) whose ASR transcript matches the text.Known gaps
/v1/audio/transcriptions,/v1/audio/speech, chatinput_audio) but were not exercised end-to-end over HTTP here; the CLI drives the same slot loop.-sysis spelled--sysas the alias: clap has no multi-character short flag.mlxcel archreports a singleoutputvalue, so LFM3-Audio showsaudio(its text output is not a separate axis).