Repository navigation
Studio: enable audio input for Gemma 4 GGUFs; default chat model to Qwen3.5-4B-MTP - #6000
Conversation
Audio file upload was disabled for Gemma 4 vision+audio GGUFs (e.g. gemma-4-12b-it-GGUF) even though their mmproj carries an audio encoder (clip.has_audio_encoder, gemma4ua). Two causes: - Audio-input detection only matched Gemma 3n's <audio_soft_token>; Gemma 4 uses <|audio|>, so audio_vlm was never detected. - The GGUF load/status responses hardcoded has_audio_input=False, so the flag was dropped even when audio_vlm was detected (affected Gemma 3n GGUFs too). Changes: - Recognize <|audio|> alongside <audio_soft_token> in the llama-server token probe and the tokenizer-config pattern. - Read clip.has_audio_encoder from the mmproj as an independent, model-agnostic signal (read_mmproj_audio_capability). - Emit the computed has_audio_input on the GGUF load/status responses. - Tests for the new pattern and the mmproj reader.
Switch the auto-loaded chat default and the dataset-analysis helper GGUF from gemma-4-E2B-it to unsloth/Qwen3.5-4B-MTP-GGUF (UD-Q4_K_XL).
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c66418814e
ℹ️ 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".
| is_audio = _gguf_is_audio, | ||
| audio_type = _gguf_audio, | ||
| has_audio_input = False, | ||
| has_audio_input = llama_backend._has_audio_input, |
There was a problem hiding this comment.
Do not advertise GGUF audio before accepting it
When a Gemma 4/Gemma 3n GGUF now returns has_audio_input=true, the frontend will show the audio attachment control and include audio_base64 in /api/inference/chat, but the GGUF generation path still unconditionally returns 400 "Audio input is not supported for GGUF chat models yet." whenever payload.audio_base64 is present. In the loaded/status responses this therefore exposes a capability that is guaranteed to fail for the exact GGUF models this change targets; either the chat path needs to forward audio to llama-server or this flag should remain false until that path is implemented.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Code Review
This pull request introduces support for audio input capability detection in GGUF models, specifically handling Gemma 4's <|audio|> token and parsing the clip.has_audio_encoder boolean metadata from projector files (mmproj). It also updates the default helper model to Qwen3.5-4B-MTP-GGUF and adds corresponding unit tests. The review feedback suggests improving encapsulation by exposing the private _has_audio_input attribute as a public @property on LlamaCppBackend rather than accessing it directly or via getattr in the route handlers.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| self._has_audio_input: bool = False | ||
| self._mmproj_has_audio: bool = False # clip.has_audio_encoder, set at load |
| has_audio_input = getattr(llama_backend, "_has_audio_input", False), | ||
| inference = inference_config, | ||
| requires_trust_remote_code = bool( |
There was a problem hiding this comment.
To preserve encapsulation and maintain consistency with the established design patterns in LlamaCppBackend (which exposes public properties for its internal state, e.g., is_vision, chat_template), avoid accessing the private _has_audio_input attribute directly or via getattr from outside the class. Instead, define a public @property has_audio_input on LlamaCppBackend and use it here.
has_audio_input = llama_backend.has_audio_input,| has_audio_input = False, | ||
| has_audio_input = llama_backend._has_audio_input, | ||
| inference = inference_config, | ||
| requires_trust_remote_code = bool( |
There was a problem hiding this comment.
| has_audio_input = False, | ||
| has_audio_input = getattr(llama_backend, "_has_audio_input", False), | ||
| loading = [], | ||
| loaded = [_display_model_id] if _display_model_id else [], |
There was a problem hiding this comment.
Avoid accessing the private _has_audio_input attribute via getattr from outside the class. Instead, use the public @property has_audio_input on LlamaCppBackend to preserve encapsulation.
| loaded = [_display_model_id] if _display_model_id else [], | |
| has_audio_input = llama_backend.has_audio_input, |
unslothai#6000 added <|audio|> as a second audio_vlm probe next to <audio_soft_token>. The no-match and bicodec simulation fixtures only neutralized the latter, so the fake server's default tokenized <|audio|> to one token and audio_vlm matched early — returning 'audio_vlm' where the tests expect bicodec/None. Map <|audio|> to a multi-token response wherever audio_vlm should fall through.
… `<|audio|>` probe (unslothai#6018) * Studio: fix load_freeze audio-type tests for unslothai#6000 Gemma 4 <|audio|> probe unslothai#6000 extended LlamaCppBackend._detect_audio_type_strict audio_vlm arm to also probe Gemma 4 `<|audio|>` (alongside Gemma 3n `<audio_soft_token>`), but did not update the load_freeze simulation suite (last touched by unslothai#5922). Its "no-match" and "bicodec" fixtures only defeat `<audio_soft_token>`; the unmapped `<|audio|>` probe falls through to FakeLlamaServer 1-token default, so detect_audio_type now returns audio_vlm where these tests expect None / bicodec: - test_functional_equivalence_no_match - test_functional_equivalence_bicodec_match - test_response_shape_matches_pre_fix_for_no_match main push-CI does not run "Repo tests (CPU)" (pull_request-only), so this surfaces in every open PR merge-ref (e.g. unslothai#5940, which is unrelated to audio). Fix: map `<|audio|>` to a 2-token response in the three fixtures that intend a non-audio_vlm result (restoring their original semantics), and add a positive test_functional_equivalence_audio_vlm_match locking in unslothai#6000 new `<|audio|>` detection. Co-Authored-By: Claude Opus 4.8 <[email protected]> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: Claude Opus 4.8 <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
…wen3.5-4B-MTP (unslothai#6000) * Studio: enable audio input for Gemma 4 GGUF models Audio file upload was disabled for Gemma 4 vision+audio GGUFs (e.g. gemma-4-12b-it-GGUF) even though their mmproj carries an audio encoder (clip.has_audio_encoder, gemma4ua). Two causes: - Audio-input detection only matched Gemma 3n's <audio_soft_token>; Gemma 4 uses <|audio|>, so audio_vlm was never detected. - The GGUF load/status responses hardcoded has_audio_input=False, so the flag was dropped even when audio_vlm was detected (affected Gemma 3n GGUFs too). Changes: - Recognize <|audio|> alongside <audio_soft_token> in the llama-server token probe and the tokenizer-config pattern. - Read clip.has_audio_encoder from the mmproj as an independent, model-agnostic signal (read_mmproj_audio_capability). - Emit the computed has_audio_input on the GGUF load/status responses. - Tests for the new pattern and the mmproj reader. * Studio: default chat model and dataset helper to Qwen3.5-4B-MTP Switch the auto-loaded chat default and the dataset-analysis helper GGUF from gemma-4-E2B-it to unsloth/Qwen3.5-4B-MTP-GGUF (UD-Q4_K_XL). * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Summary
Two Unsloth Studio changes:
unsloth/Qwen3.5-4B-MTP-GGUF(UD-Q4_K_XL).1. Gemma 4 audio input
Gemma 4 GGUFs such as
unsloth/gemma-4-12b-it-GGUFship an mmproj with an audio encoder (clip.has_audio_encoder=True, projectorgemma4ua, 128 mel bins), so they accept audio input. Studio still hid the audio upload because of two issues:<audio_soft_token>. Gemma 4 uses<|audio|>, soaudio_vlmwas never detected.has_audio_input=False, dropping the flag even whenaudio_vlmwas detected. This also affected Gemma 3n GGUFs.Fix:
<|audio|>alongside<audio_soft_token>in the llama-server token probe (_detect_audio_type_strict) and the tokenizer-config pattern (_AUDIO_TOKEN_PATTERNS). csm's uppercase<|AUDIO|>stays distinct.clip.has_audio_encoderfrom the mmproj as an independent, model-agnostic signal (read_mmproj_audio_capabilityingguf_metadata.py), reusing the existing header parser so no new dependency is added.has_audio_inputon the backend (token probe OR mmproj audio encoder) and emit it on the GGUF load and status responses.The frontend needs no change; it already gates the audio attach button on
has_audio_input.2. Default model
chat-adapter.ts(auto-loaded chat default) andllm_assist.py(dataset helper) now point tounsloth/Qwen3.5-4B-MTP-GGUF(UD-Q4_K_XL) instead ofgemma-4-E2B-it.Testing
test_audio_token_detection.py(audio_vlm matches<|audio|>, not csm's<|AUDIO|>) andread_mmproj_audio_capabilitycases intest_gguf_metadata.py. All 21 passing.unsloth/gemma-4-12b-it-GGUF(UD-Q4_K_XL) in Studio; the load response now reportshas_audio_input: true,audio_type: "audio_vlm",is_vision: true, and the audio attach button appears.