Studio: decide diffusion routing before the SWA resolver#6299
Merged
Conversation
Loading a DiffusionGemma GGUF could fail with "llama-server failed to start. Check that the GGUF file is valid" while llama-diffusion-cli ran the same model fine. _read_gguf_metadata set self._is_diffusion after calling _resolve_swa_pattern, both inside one try/except. The resolver reaches into transformers/HF, which can raise for an architecture transformers does not know (diffusion-gemma); the shared except then swallowed it and left _is_diffusion False, so the model was routed to plain llama-server instead of the diffusion runner. It only reproduced where the SWA pattern was not already cached/inline. Set _is_diffusion right after the KV parse loop (before the resolver) so a resolver error can no longer drop the routing, and skip the resolver for diffusion models, which do not use Studio's SWA pattern.
for more information, see https://pre-commit.ci
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates the _read_gguf_metadata method in llama_cpp.py to determine whether a model is a diffusion model earlier in the metadata parsing process. It also skips the sliding window attention (SWA) resolver for diffusion models to prevent potential exceptions on architectures that the resolver does not recognize. There are no review comments to assess, so no feedback is provided.
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.
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.
Problem
Loading a DiffusionGemma GGUF in Studio could fail with
llama-server failed to start. Check that the GGUF file is valid, even thoughllama-diffusion-cliruns the same model fine._read_gguf_metadataassignedself._is_diffusionafter calling_resolve_swa_pattern, both inside onetry/except. The resolver reaches into transformers/HF, which can raise for an architecture transformers does not know (diffusion-gemma). When it raised, the sharedexceptswallowed it and left_is_diffusionFalse, so the model was routed to plain llama-server (which cannot serve a block-diffusion GGUF) instead of the diffusion runner. It only reproduced on hosts where the SWA pattern was not already cached or inline in the GGUF.Fix
_is_diffusionright after the KV parse loop (it only needsarch/canvas_seen), before the resolver, so a resolver error can no longer drop the diffusion routing.Verification
Monkeypatching
_resolve_swa_patternto raise on a real DiffusionGemma GGUF:_is_diffusionis now True (was False), the resolver is invoked 0 times, and the remaining metadata (context_length, chat_template, reasoning, tools) is still read. No change for non-diffusion models.