Repository navigation
Studio: add mmproj load toggle for GGUF vision models - #5954
Imagineer99 wants to merge 137 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds a toggle to enable or disable loading the mmproj vision projector for GGUF vision models, allowing users to run vision-capable models as text-only to save VRAM. The changes span backend model loading logic, API models, frontend state management, and the chat settings UI. The review feedback suggests adding the state setter setPendingImages to the dependency array of a useEffect hook in shared-composer.tsx to comply with React's exhaustive-deps linting rule.
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.
|
mmproj doesn't go well with MTP. So we gotta at least warn people when they are unknowingly choosing both. |
yeah valid point, will add warning/toast |
Resolve the composer tools-menu conflict and warn when Vision Projector is combined with MTP speculative decoding.
# Conflicts: # studio/backend/routes/inference.py # studio/frontend/src/features/chat/chat-settings-sheet.tsx # studio/frontend/src/features/chat/hooks/use-chat-model-runtime.ts
…le-resolve # Conflicts: # studio/backend/core/inference/llama_cpp.py # studio/backend/models/inference.py # studio/backend/routes/inference.py # studio/frontend/src/features/chat/chat-settings-sheet.tsx # studio/frontend/src/features/chat/hooks/use-chat-model-runtime.ts # studio/frontend/src/features/chat/shared-composer.tsx # studio/frontend/src/features/chat/stores/chat-runtime-store.ts # studio/frontend/src/features/chat/types/api.ts
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5fda53a25a
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…ggle # Conflicts: # studio/frontend/src/features/chat/chat-settings-sheet.tsx # studio/frontend/src/features/chat/stores/chat-runtime-store.ts
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d702b7c5cc
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
Tested this end-to-end on the latest commit (now synced with Setup: RTX 5060 Ti (16 GB), Results, all working:
On the MTP point @Datta0 raised, the warning toast shows when both are selected, and it stays advisory (it does not block). With MTP and the projector both on, image input still worked in my run, so the warning correctly flags the risky combo without preventing valid use. The frontend also typechecks clean ( |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 45160d5fff
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 695d18999b
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@codex review |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9c283942c7
ℹ️ 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".
| if requested_load_mmproj != bool(llama_backend.load_mmproj): | ||
| return False |
There was a problem hiding this comment.
Reset projector state for diffusion loads
When a Diffusion GGUF is loaded after a vision GGUF that was running text-only, _start_diffusion_server() resets many runtime flags but never assigns _load_mmproj. This new comparison therefore sees the stale false from the previous model against the default load_mmproj=true on an identical diffusion /load or Apply, so the already-loaded check misses and unnecessarily tears down/restarts the diffusion runner. Either reset _load_mmproj on the diffusion path or skip this projector comparison for diffusion models.
Useful? React with 👍 / 👎.
| if resolved is None: | ||
| load_kwargs["load_mmproj"] = load_mmproj |
There was a problem hiding this comment.
Preserve projector state on resolved idle reloads
With OpenAI auto-switch enabled, an idle-unloaded model is normally requested again by its known model id, so resolve_local_gguf() succeeds and this resolved is None branch is skipped. In that case the stashed load_mmproj=false is not included in load_kwargs, LoadRequest defaults it back to true, and a vision model that was freed in text-only mode is reloaded with the projector anyway, losing the saved effective load and the memory/download savings. Carry the stashed projector state when the resolved target matches the last unloaded model, or persist it in the auto-switch override.
Useful? React with 👍 / 👎.
| const effectiveVisionProjector = ownRemembered | ||
| ? (ownConfig.visionProjectorEnabled ?? true) | ||
| : compareLoadKnobs.visionProjectorEnabled; |
There was a problem hiding this comment.
Default compare panes to loading the projector
When a compare pane has no remembered config, this falls back to the currently loaded model's projector toggle instead of the per-model default. If the active model was intentionally loaded text-only, comparing against a different unsaved vision GGUF sends load_mmproj=false, so that pane is loaded without vision support and image prompts are rejected even though the selected model's default setting should load the projector. Use the default true for unremembered pane configs, matching the normal model-switch reset.
Useful? React with 👍 / 👎.
| speculativeType: speculativeType ?? "auto", | ||
| specDraftNMax: specDraftNMax ?? null, | ||
| tensorParallel: tensorParallel ?? false, | ||
| visionProjectorEnabled, |
There was a problem hiding this comment.
Include projector state in the sidebar remount key
This adds the projector toggle to the active loaded config, but the active sidebar's configSignature() still omits visionProjectorEnabled while ModelConfigPage snapshots loadedConfig with useState(resolveInitial). If a sidebar reload asks to turn the projector on but the backend falls back to load_mmproj=false (missing/incompatible mmproj), the store updates to false but the page does not remount, leaving the switch showing the stale requested value until some other setting changes.
Useful? React with 👍 / 👎.
| @@ -5452,12 +6157,18 @@ def load_model( | |||
| # Common | |||
| model_identifier: str, | |||
| is_vision: bool = False, | |||
| load_mmproj: bool = True, | |||
There was a problem hiding this comment.
Honor the projector toggle in the load marker
This new parameter is honored by the route-level Hub-download gate, but load_model is decorated with _with_gguf_load_marker, which still recomputes require_mmproj from only is_vision and extras. For an HF vision GGUF loaded with load_mmproj=false while another download for the repo is active, the route can allow a cached text-only load but the decorator rejects it as if the uncached mmproj were still required. Include load_mmproj in the decorator's require_mmproj calculation so text-only loads are not blocked by unrelated projector downloads.
Useful? React with 👍 / 👎.
| backend.model_identifier, | ||
| getattr(backend, "hf_variant", None), | ||
| advertised, | ||
| bool(getattr(backend, "load_mmproj", True)), |
There was a problem hiding this comment.
Check projector state before restoring idle KV
Adding the projector state to the idle identity does not protect the saved slot KV because restore_kv_resume() never compares manifest['identity'], and _slot_launch_fingerprint() does not include _load_mmproj or the emitted --mmproj state. After an idle unload saves KV for a vision load, a manual reload of the same GGUF with the projector toggled the other way can still pass the GGUF/fingerprint checks and restore KV from the incompatible multimodal/text-only session. Include the projector state in the restore validation before applying the saved slots.
Useful? React with 👍 / 👎.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a4dc23ea5a
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| requested_load_mmproj = _effective_load_mmproj( | ||
| request.load_mmproj, | ||
| effective_extra, | ||
| ) | ||
| if not llama_backend.is_diffusion and requested_load_mmproj != bool(llama_backend.load_mmproj): |
There was a problem hiding this comment.
Strip inherited no-mmproj when enabling projector
When a same-model Apply/reload omits llama_extra_args, effective_extra is rebuilt from the previous load's stored extras, so a hidden inherited --no-mmproj makes this new load_mmproj=true request resolve back to false and the route can return already_loaded instead of ever retrying with the projector enabled. Fresh evidence in this target tree is that the new comparator feeds inherited effective_extra directly into _effective_load_mmproj; only explicit extra args should keep overriding the first-class toggle, while inherited mmproj-disable flags need to be stripped when the UI sends the projector setting.
Useful? React with 👍 / 👎.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9be0d6baa7
ℹ️ 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".
| requested_load_mmproj = bool(load_mmproj and not extra_args_disable_mmproj(extra_args)) | ||
| if bool(getattr(self, "_load_mmproj", True)) != requested_load_mmproj: |
There was a problem hiding this comment.
Skip mmproj comparison for diffusion loads
When the live GGUF is a diffusion runner, _start_diffusion_server records _load_mmproj = False, but duplicate load_model calls still arrive with the default load_mmproj=True. This backend fast path is meant to catch /load calls that raced past the route-level dedupe, so concurrent duplicate loads of the same diffusion model now miss the fast path, kill the healthy diffusion process, and start it again. Gate this comparison to non-diffusion/vision llama-server loads, matching the route-level matcher.
Useful? React with 👍 / 👎.
| if stashed_load_mmproj is not None: | ||
| load_kwargs["load_mmproj"] = stashed_load_mmproj |
There was a problem hiding this comment.
Reject image auto-switch when stashed projector is off
When an idle-unloaded vision GGUF was stashed with load_mmproj=False, an OpenAI image/audio request naming that model reaches this path and reloads it text-only. The earlier require_vision guard only probes whether the target has an mmproj file, so it treats the target as vision-capable and allows the expensive load, after which the request is rejected because the active backend is not vision. If require_vision is true and the matching stash says the projector is disabled, reject before calling _load_model_impl instead of loading a model that cannot serve the request.
Useful? React with 👍 / 👎.
| "speculativeType", | ||
| "specDraftNMax", | ||
| "tensorParallel", | ||
| "visionProjectorEnabled", |
There was a problem hiding this comment.
Bump the per-model config schema for projector state
This adds a persisted load-affecting field while keeping the stored schema at version 1. If a user saves a model as text-only in this build and later opens the same settings with an older v1 client, that client will not hit the future-version guard; it will accept the record, drop the unknown visionProjectorEnabled field on save, and silently re-enable the projector. Store this under a new schema version so older clients refuse to rewrite configs they cannot preserve.
Useful? React with 👍 / 👎.
|
@codex review |
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2c6af0eba5
ℹ️ 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".
| const effectiveVisionProjector = ownRemembered | ||
| ? (ownConfig.visionProjectorEnabled ?? true) | ||
| : true; |
There was a problem hiding this comment.
Use the send-time projector setting in compare loads
In compare mode, this hard-codes unremembered GGUF panes to load with load_mmproj: true. If the user has disabled Vision Projector in the current runtime settings but has not remembered a per-model config, the compare send path ignores the value already captured in compareLoadKnobs.visionProjectorEnabled and re-enables/downloads the mmproj for that pane, reintroducing the VRAM/context pressure the toggle was meant to avoid. Fall back to the send-time snapshot when ownRemembered is false.
Useful? React with 👍 / 👎.
| if is_vision and not effective_mmproj_requested: | ||
| env.pop("LLAMA_ARG_MMPROJ", None) | ||
| env.pop("LLAMA_ARG_MMPROJ_AUTO", None) |
There was a problem hiding this comment.
Drop projector URL env when disabling mmproj
When Vision Projector is disabled, this strips LLAMA_ARG_MMPROJ and LLAMA_ARG_MMPROJ_AUTO from the child environment but leaves LLAMA_ARG_MMPROJ_URL intact. On hosts that set the URL form of the projector flag, the llama-server process can still receive an explicit mmproj URL even though Studio reports load_mmproj=false and skipped the projector sizing/download path; clear the URL env alongside the file-path env to make the toggle authoritative.
Useful? React with 👍 / 👎.
|
@codex review |
|
Codex Review: Didn't find any major issues. 🎉 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |

Summary
Addresses #5825
Vision-capable GGUF models currently auto-load
mmproj, even when the user only wants text inference. This can increase VRAM usage, reduce usable context, and conflict with setups where users want to avoid the vision projector.--mmproj