Repository navigation
Studio: name FFmpeg when a video GGUF can't decode, and shrink clips with the ffmpeg llama-server uses - #16098
Conversation
llama-server spawns ffprobe and ffmpeg for every clip, but Studio advertised video from /props alone, so a machine without FFmpeg on PATH (most Windows installs) let a clip through and got "Failed to load image or audio file". Gate has_video_input on the tools, pin llama-server to the folder Studio found with --video-ffmpeg-dir, and refuse with a message naming FFmpeg.
…-ffmpeg-dir An older llama-server ignores the env twin and searches PATH, so the video check has to search PATH as well there.
The Windows launch prepends llama-server's own folder to the child PATH, so ffmpeg beside llama-server.exe was found by the child but not by Studio's check, which turned video off.
Main's _video_tools_reachable (PR 16094) now decides whether a GGUF takes video, so the duplicate check in _query_server_n_ctx and the child-PATH search are dropped. Kept: --video-ffmpeg-dir pinned to the folder Studio checked, the clip shrink using that folder, and a 400 naming FFmpeg. The gate no longer reads LLAMA_ARG_VIDEO_FFMPEG_DIR on a build without --video-ffmpeg-dir, which ignores it.
When the tools are only on the child's search path (beside llama-server.exe on Windows) nothing was pinned, so the clip shrink searched Studio's PATH, found nothing and sent the clip unshrunk. The gate's search is now one helper, and a load that keeps video records it for the shrink.
|
Codex review on the fork mirror (LeoBorcherding#651) is clean at |
|
CI clean on the fork mirror (LeoBorcherding#651) at |
|
Review record for #16098, carried over from the mirror it was reviewed on: danielhanchen/unsloth-staging-review#698. Findings are quoted as posted and attributed to the account that posted them. The reactions shown are the triage recorded on the mirror; none were re-applied here. Commits are named as the mirror's, with this PR's equivalent where one was found. Round 1: reviewed mirror
|
…tom-code generate (#16242) Replaces #16101, which GitHub closed when #16096 merged and its base branch was deleted. Same branch, now merged with main; the diff is only this PR's changes. ## What breaks `LiquidAI/LFM3-Omni-2B` (safetensors, custom code) loads as vision-only. The backend logs `is_vision=True ... audio_type=None, audio_type_known=True`, the chat chip says "Vision", and attaching a WAV through "Add photos & files" is refused ("cannot accept audio"), so the prompt goes out text-only and the model says it has no clip. The GGUF of the same model takes audio fine, because llama.cpp reads the vocab. ## Why Audio-input detection fingerprints `added_tokens_decoder` in `tokenizer_config.json` (`<|audio|>` / `<audio_soft_token>` -> `audio_vlm`). LFM3-Omni was saved by transformers 5, whose `tokenizer_config.json` has no `added_tokens_decoder` at all: `<|audio|>` only lives in `tokenizer.json` and in `processor_config.json` (`"audio_token": "<|audio|>"`). So detection read the tokenizer config, found nothing, and answered a definitive "not audio". ## Fix - `processor_config.json` joins the files audio detection reads (local dir, HF cache and Hub), and `classify_audio_tokens` counts a config's `audio_token`. Only the markers the tokenizer patterns already accept route to `audio_vlm`, so Qwen2-Audio's `<|AUDIO|>` stays where it was. - `generate_audio_input_response` needed no change: it goes through `processor.apply_chat_template`, and transformers' base implementation calls the processor with `text=`, `audio=` by keyword, so LFM3's text-first signature is not a problem on this path (the positional issue #16096 fixed was on the image path only). ## Evidence Colab L4 (NVIDIA L4, 22.5 GB), Linux, transformers 5.22.0 latest sidecar (installed through Studio's own upgrade prompt). Same VM, same WAV (2.9 s, macOS `say`: "Hello. The secret word for today is pineapple."), same prompt "What is the secret word in this audio clip?", driven headless with Playwright through the real "Add photos & files" picker. | | before `0782561c9a` | after `a19ca071ed` | |---|---|---| | `/api/models/config` | `audio_type=None`, `has_audio_input=False`, `model_type=vision` | `audio_type=audio_vlm`, `has_audio_input=True` | | chip | Vision | Vision · Audio Input | | attach WAV | refused: "LFM3-Omni-2B cannot accept audio" | attached | | reply | "you haven't provided the audio clip" | "The secret word for today is pineapple." |  | before: attach refused | after: attached | |---|---| |  |  | <details><summary>GIFs of the full flow</summary> Before:  After:  </details> Image chat still works after the change (`/v1/chat/completions` with a red-circle PNG: "Red circle on white background"). ## Tests Three new tests in `studio/backend/tests/test_audio_token_detection.py` (classifier, local checkpoint shaped like the published repo, Hub fetch). Red on `0782561c9a`, green here. Every test file touching `tokenizer_config` / `detect_audio_type` / `audio_tokens` (84 files, Mac M5, Unsloth Studio venv): no new failures. The other failures there are the same on base (mostly MLX trainer tests that can't run on this Mac); `test_memory_estimate::test_a_weightless_probe_never_runs_the_evaluations_its_model_asks_for` failed once in the loaded full run and passes alone. ## Not covered - Windows (the reporter's OS) and Unsloth Desktop: the change is in backend detection, which is platform-independent, but no Windows run. - Spoken-reply (`audio_out`) is untouched; this is audio in, text out. - Seen in passing: with `/v1/chat/completions` non-streaming, LFM3's image answer lands in `reasoning_content` with empty `content`. Separate from this PR. ## Also in this PR (added after review and GPU testing) - **Stop and stop sequences for custom-code `generate`:** LFM3's `generate` rejects `stopping_criteria`, so Stop or a matched stop string ran to `max_new_tokens` while holding the generation lock. Cancellation now goes through the streamer on the text, vision and audio-input paths. Stop strings use the existing text and vision stop-sequence streamers; audio-input stop strings remain unsupported. T4, LFM3-Omni-2B, WAV question cancelled after 8 chunks: the next request waited 80.3 s before, 0.3 s after. - **Export:** an `audio_vlm` checkpoint with a vision tower loads as a VLM for export, so the processor, audio tokenizer and mmproj ship. Gemma 3n/4 exports are byte-identical before and after (G4). - **LoRA defaults:** LFM3's MLP is `w1/w2/w3`, which the default `up_proj/down_proj` targets miss, so every LFM3 repo defaults to `all-linear`. - **LFM3-Audio-2B:** its `audio_token` has no image processor beside it, so it isn't advertised as an audio VLM, and a text-path load whose model has no `generate` is refused by name instead of crashing on the first message (#16128 builds the real chat path). - **Routing:** a custom-code config whose `transformers_version` is only on nested sub-configs (LFM3-Audio-2B) routes by that. Hardware: Colab A100 / G4 / T4 / L4 (NVIDIA, Linux); RX 9060 XT gfx1200 on Linux (chat, LoRA, export); RX 6500 XT gfx1034 on Windows 11 (LFM3-1.7B chat and LoRA); RX 5700 XT gfx1010 loads but LFM3's own Triton conv doesn't compile there (separate fix). ## Related All from the LFM3 report #16054: #16096 (merged: LFM3 load, chat, training and export), the Audio-2B chat PR stacked on this one, #16121 (API `reasoning_content`), #16124 (audio + image training), #16098 (video and ffmpeg), unslothai/unsloth-zoo#2278 (LoRA merge on renamed weights). <!-- lfm3-audio-ui:start --> ### Audio-input UI evidence Before `4f4305ea10c4a9940a2a00f7c4b454a47d6e38fc`, after `1dfec8c3537e3ddda2042eacf6c8f333a157c7da`. The scene runs each side's actual metadata classifier on the same published configuration, supplies that measured capability through an intercepted inference-status response, and opens the real Compare chat attachment menu. Upload audio is absent before and visible after. This proves metadata-derived presentation; no model load or generation runs in this scene.  <!-- lfm3-audio-ui:end --> --------- Co-authored-by: Daniel Han <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Follow-up to #16094 (which closed #16065).
/propsadvertises video, but where llama-server can't find ffmpeg/ffprobe, now gets a 400 naming FFmpeg instead of the generic "cannot take video input".--video-ffmpeg-dirwhen available and receives the running server's prepared loader environment. Otherwise it retains normal executable lookup.--video-ffmpeg-dirignoresLLAMA_ARG_VIDEO_FFMPEG_DIR, and the reachability check follows that behavior. An inconclusive probe preserves the inherited override.supports_video_ffmpeg_diris probed from--help. A confirmed supported build can receive an automatically found folder on POSIX; Windows keeps native application-directory search precedence. Inconclusive probes preserve explicit and inherited overrides.Edge cases run on macOS against a real llama-server with Homebrew ffmpeg: ffmpeg on PATH, no ffmpeg, ffmpeg and ffprobe in different folders, a user's own
--video-ffmpeg-diror env var, and a build without that flag.API Monitor before and after
Merge base
6fe27d2c5versus corrected head19b224260. API Monitor now names llama-server's FFmpeg search path and explains how to correct a configured override. Both sides use independently built Studio installs with the same injected loaded video GGUF state; authentication, the HTTP request, rejection, monitor recording, and frontend rendering are real. This fixture checks the visible error and performs no model inference.The follow-up fixes preserve native Windows executable lookup and application-directory precedence, inherited overrides after an inconclusive help probe, directory whitespace, and the running server's prepared loader environment during preprocessing. Native Windows controls reproduce the earlier lookup and precedence failures; the corrected head keeps both behaviors working.