Skip to content

Unsloth Studio: train and export LFM3-Audio-2B (LoRA, merged 16-bit, GGUF) - #16973

Merged
danielhanchen merged 16 commits into
unslothai:mainfrom
LeoBorcherding:up/lfm3-audio2b-train-export
Nov 7, 2026
Merged

danielhanchen merged 16 commits into
unslothai:mainfrom
LeoBorcherding:up/lfm3-audio2b-train-export

Conversation

@LeoBorcherding

Copy link
Copy Markdown
Collaborator

LFM3-Audio-2B can now be trained in Unsloth Studio, chatted with after training, and exported as a LoRA, a merged 16-bit model, and a GGUF.

What was broken

step error before cause
Train failed to build the first training batch ... TokenizersBackend has no attribute tokenizer training loaded the default model class, which builds the bare LFM3-Audio backbone with no output head and returns a tokenizer instead of the audio processor
Export same bare model, no processor export had no path for an audio-input model without vision
GGUF Model Lfm3AudioForConditionalGeneration is not supported llama.cpp converts LFM3-Audio (ggml-org/llama.cpp#31257) only from the config layout the model was released with (lfm / encoder / depthformer). Saving through transformers writes a different layout (text_config / audio_encoder_config / depth_config), so the converter no longer recognizes it

Changes

  • Training (core/training/trainer.py): an audio model with no vision tower loads through AutoModelForMultimodalLM, the same rule Chat already uses. Gemma 3n/4 and LFM3-Omni have vision and keep the default load. That class is used only when the vision check gives a definite "no"; if the check fails to read the config, the default load is kept. The training collator also keeps LFM3-Audio's audio placeholder tokens out of the loss (they live on the processor, not the tokenizer).
  • Export (core/export/export.py): the same rule, so LoRA and merged exports include the processor, feature extractor and the audio_tokenizer/ codec.
  • Saving (unsloth/save.py): before GGUF conversion, the saved config.json is replaced with the base model's released one, read at the exact commit that was loaded. A LoRA merge doesn't change the architecture, so it describes the same weights. If the vocabulary was resized, the saved config is kept. A merged 16-bit save, local or pushed to the Hub, also writes the released layout, so the folder can be converted later without its base.

Merged 16-bit export needs unslothai/unsloth-zoo#2278, which maps the weight names this model renames on load.

Results

Colab A100 40GB, Linux, transformers 5.22.1, unsloth-zoo 9e9eed301a (#2278), at the earlier commits listed. Toy dataset: 24 spoken questions in 2 voices, every answer <<A2B-TAG>> SLOTH-7 ~Q9, with 3 held-out questions.

step commit result
Train before (LoRA r16, 40 steps) 7add506 TokenizersBackend has no attribute tokenizer
Train after 7bd474b completed, loss 8.654 to 0.003
Chat on the LoRA, held-out clips 7bd474b 3/3 trained answer (API key caller, see notes)
Export LoRA 7bd474b ok, adapter plus processor files and audio_tokenizer/
Export merged 16-bit 7bd474b ok, 16 s
Reload merged with plain transformers 7bd474b 3/3 trained answer
Reload LoRA with plain transformers + PEFT on the base 7bd474b 3/3 trained answer
Export GGUF q8_0 before 7bd474b Model Lfm3AudioForConditionalGeneration is not supported
Export GGUF q8_0 after f6915aa ok, model GGUF plus mmproj, 65 s
Unsloth Studio's llama-server on that GGUF, held-out clips f6915aa 3/3 trained answer
LFM3-Omni-2B train, same data (regression) f6915aa completed, loss 8.447 to 3.045 over 20 steps, default load

Not run on a GPU: the later commits ca03702 (read the base config at the loaded commit), 96a36c0 and 89aa016 (merged saves keep the released layout), and the vision-check fallback.

Tests

New tests in test_audio_vlm_train_load.py, test_audio_vlm_completion_masking.py, test_export_audio_vlm_loads_as_vision.py and tests/saving/test_lfm3_audio_gguf_config.py: 139 passed on macOS CPU, together with the existing save routing and Hub destination tests.

Notes

  • Unsloth Studio's chat adds a date line before the system prompt. A tiny 40-step adapter trained on the exact prompt doesn't fire through that, so the chat row went through an API key, which keeps the prompt as sent. This PR doesn't change that.
  • AutoProcessor.from_pretrained(<LoRA export>) fails with Can't find 'adapter_config.json': the LFM3 processor loads its codec from a subfolder, and transformers then mistakes the export's adapter file for its own. All the files are present; load the processor from the base model instead.
  • Not tested: LoRA-to-GGUF conversion for LFM3-Audio, a GGUF made from a merged 16-bit folder, and Gemma 3n/4 on a GPU (unit tests only).

An audio_vlm model with no vision tower (LFM3-Audio-2B) loaded for training
through the default FastModel class, which builds the bare Lfm3AudioModel
with no LM head and returns a tokenizer, so the first batch failed with
"TokenizersBackend has no attribute tokenizer". It now loads through
AutoModelForMultimodalLM, the same rule Chat uses, and gets its processor.
The audio VLM collator also masks placeholder ids the processor holds
(LFM3-Audio's audio_token_id), not only the tokenizer's (Gemma 3n).
Export loaded an audio_vlm checkpoint without vision on the text path, the
bare Lfm3AudioModel with no LM head and no processor, so the merged and
LoRA exports could not carry the feature extractor or audio tokenizer. It
now loads through AutoModelForMultimodalLM like Training and Chat.
llama.cpp converts LFM3-Audio (ggml-org/llama.cpp#31257) only from the
release config.json layout (lfm / encoder / depthformer), matched by an
hparams loader. The checkpoint's remote config class saves text_config /
audio_encoder_config / depth_config instead, so a merged LFM3-Audio failed
with "Model Lfm3AudioForConditionalGeneration is not supported". A LoRA
merge leaves the config as released, so the GGUF conversion now reads the
base's own config.json; resized embeddings keep the saved one.
The base config lookup resolved config.json at the repo's default revision,
so a base loaded from another revision could hand the converter a config
from a different commit. The loaded config's _commit_hash now pins it.
…sion probe

is_vision_model reads a transient probe failure as False, so an image-capable
audio VLM (Gemma 3n / 4, LFM3-Omni) could have been sent to
AutoModelForMultimodalLM by a flaky read. Training and export now ask
is_vision_model_checked before leaving the default load, and an inconclusive
answer keeps it.
@LeoBorcherding

Copy link
Copy Markdown
Collaborator Author

Codex review on the fork mirror (LeoBorcherding#783) found no major issues at afbb877269, this PR's head: result.

…dio takes the multimodal load

The sidecar AutoConfig probe can't run LFM3-Audio's repo code, so is_vision_model_checked
answered unknown on every load and training and export fell back to the bare backbone.
danielhanchen added a commit that referenced this pull request Nov 7, 2026
…t is 26.04 (#16987)

## Summary

`Chat UI Tests (chat)` and `Loaded-models indicator (cross-browser)` are
red on main (run 42338613438) and on #16986, #16984 and #16973, all in
the same step:

```
Image: ubuntu-26.04
Version: 20261101.186.1
...
engines that will not start: webkit: TargetClosedError
system libraries are missing, installing them
...
engines that will not start: webkit: TargetClosedError
##[error]Process completed with exit code 1.
```

`ubuntu-latest` is being moved to the ubuntu-26.04 image. Playwright
1.64.1's WebKit build exits at launch there, and `playwright
install-deps` does not fix it, so the browser probe in "Install
Playwright browsers" fails before any test runs. Chromium and Firefox
start fine. The last green runs of the same jobs ran on ubuntu-24.04
(for example 42319231838, 42313662909, 42311916438, all today), so the
image is the only thing that changed. As the rollout reaches more jobs,
every Linux job that drives WebKit will hit this.

## Change

- `studio-ui-smoke.yml`: `ui-smoke` (Chat UI Tests) and `ui-indicator`
(Loaded-models indicator) run on `ubuntu-24.04`.
- `studio-composer-compatibility.yml` and `studio-inline-images.yml`:
the `ubuntu-latest` matrix leg runs on `ubuntu-24.04` through `runs-on:
${{ matrix.os == 'ubuntu-latest' && 'ubuntu-24.04' || matrix.os }}`. The
matrix value is unchanged, so the check names (`Composer (ubuntu-latest,
browsers)`, `Inline images (ubuntu-latest)`) stay the same; macOS and
Windows legs are untouched.
- Each pin carries a comment to move back once WebKit starts on 26.04.
- `tests/studio/test_webkit_jobs_skip_ubuntu_latest.py`: finds every
workflow job whose steps or matrix mention WebKit, resolves the images
it lands on (a plain `runs-on`, `matrix.os`, or the mapped form above),
and fails if any of them is `ubuntu-latest`. A job counts when its steps
or matrix mention Playwright and `webkit` as a whole word, so a file
name like this test's does not. It also checks it still sees the four
jobs above, so it cannot pass by finding nothing.
- `workflow-trigger-lint.yml`: the new guard runs in that job too, since
it is the one job without a paths filter
(`test_workflow_guards_run_unfiltered.py` requires this of every
workflow-reading guard), so a PR that only edits workflows still meets
it.

## Testing

| | guard test |
|---|---|
| this branch | passes |
| main's three workflow files with this test | fails, naming
`studio-composer-compatibility.yml::composer`,
`studio-inline-images.yml::images`, `studio-ui-smoke.yml::ui-smoke`,
`studio-ui-smoke.yml::ui-indicator` |

The new test plus `tests/studio/test_workflow_guards_run_unfiltered.py`,
`test_ui_shard_engines.py`,
`test_indicator_browsers_run_in_parallel.py`,
`test_playwright_suites_run_in_ci.py`,
`test_chat_ui_shards_cover_everything.py` and
`tests/security/test_lint_workflow_triggers.py`: 240 passed.

End to end, the same probe on the two images:

| | probe before install-deps | probe after install-deps | job |
|---|---|---|---|
| main, `ubuntu-26.04` (run 42338613438) | webkit: TargetClosedError |
webkit: TargetClosedError | failed |
| this PR, `ubuntu-24.04` | webkit: TargetClosedError | all three
engines launch | `Loaded-models indicator (cross-browser)` passed |
@danielhanchen danielhanchen self-assigned this Nov 7, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-07T14:19:44.001009Z 46b9197 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: 46b9197adc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Nov 7, 2026
@LeoBorcherding

Copy link
Copy Markdown
Collaborator Author

Pushed 011550216a. A Colab A100 run showed the previous head afbb877269 didn't fix LFM3-Audio-2B. Its vision check deferred to a sidecar probe that can't run LFM3-Audio's custom code, so it answered "unknown" on every load. Training and export then fell back to the old load and failed with the original errors. The check now reads the vision tower straight from config.json. Gemma 3n/4 and LFM3-Omni declare vision_config there and LFM3-Audio doesn't. A config that can't be read still keeps the default load. Tests added in tests/test_audio_vlm_vision_checked.py.

On that A100, the commit before the broken one (e767e3b0e0) trained, chatted and exported LoRA, merged 16-bit and GGUF, all 3/3 on held-out clips. A GPU rerun at this head is still to come, and the body will be updated with it.

Codex review on the fork mirror (LeoBorcherding#788) found no major issues at 011550216a, this PR's head: result.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants