Repository navigation
Fix low VRAM mmproj fallback in Studio - #9173
Conversation
|
Codex Review: Didn't find any major issues. Bravo. 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". |
Live issue #9146 verificationTested the original reported path on isolated local Studio installs at:
Observed A/B result
The merge base reproduced the issue: it silently recovered as text-only and rejected the image with the misleading generic error. The PR head retried the projector on CPU, kept vision enabled, reported The labelled composite was visually inspected before publishing. There were no browser request failures. Both exact-SHA installs logged the same five unrelated 404 resource messages. Targeted fork CIFocused Linux run 32133507963 passed on the staged PR tree:
Local production frontend build also passed. Codex remains approved on the current PR head, with no open review findings. The broader upstream matrix is still queued, so this comment does not claim those pending jobs have completed. Hosted fork runners have no CUDA GPU; the real low-VRAM CUDA behavior above was therefore exercised on the local NVIDIA host, while fork CI covered the deterministic regressions and typecheck. |
…d-capabilities test Two frontend suites were red. auto-load-cpu-fallback-toast.test.ts matched the warn-vs-success choice and the message text as substrings of showAutoLoadSuccess. Both moved into loadFallbackNotice, which is the single definition the explicit-load path now shares, so the match went stale. Matching the inline form again would go red on a refactor that changes nothing a user can see, and would stay green if only one of the two load paths kept the behaviour. It now calls loadFallbackNotice and asserts the verdict, and separately asserts the call site delegates to it. queued-model-capabilities.test.ts was red on main before this branch. #9173 added `import { isTextOnlyMmprojFallback } from "./mmproj-fallback"` to image-input-support.ts, which the test imports statically. Extensionless is the right form -- 2314 of the 2367 relative imports under src/ are written that way, and vite and tsconfig's "bundler" mode resolve them -- but the bare node loader does not, and a static import resolves before any registration can run. The test now registers the bundler resolver and imports dynamically, which is what mmproj-fallback.test.ts already does for the same module. Both files reformatted by biome; regex literals hoisted out of the test bodies for useTopLevelRegex. Full frontend suite: 3734 pass, 0 fail. typecheck clean. The 4 biome errors in chat-adapter.ts and use-chat-model-runtime.ts are byte-identical on origin/main.
…argument test_tensor_split_abort_raises_early_to_layer_fallback has been red on main since #9173, which renamed the text-only strip's argument from _last_spawn_cmd to _vision_gpu_cmd. That rename is right: the strip should read the vision GPU command rather than whatever was spawned last, and #9173 refreshes _last_spawn_cmd from the result immediately after. The test was pinned to the old argument name, so a rename with no behavioural content took it down. The failure also misreported itself. `assert raise_idx < src.find(needle)` reads as an ordering check but is two claims at once, and when the landmark is gone it fails with "assert 249423 < -1" -- which says the ordering broke, when what happened is that the landmark moved. Each landmark is now required to exist before it is ordered, and says so. The strip is matched on the call rather than on what is passed to it. What this test is about is that the abort raises BEFORE the projector is discarded (#6659); which command the strip reads from is that code's own business. Checked both ways: removing the strip call from load_model goes red with a message naming the missing landmark, and renaming the argument again stays green.
The mmproj fallback landing added a mmprojFallbackMessage import to chat-adapter.ts. Two repo tests read that file's source: - test_chat_autoload_failure_gate slices autoLoadSmallestModel out of the adapter and runs it, and its own guard fails the whole file when the slice references a name the harness preamble does not define. Add the stub. - test_model_picker_contracts pinned the success toast's description as the literal 'description: cpuFallbackReason'. The mmproj branch now sits ahead of the CPU one, so pin the description expression instead of which fallback is tested first. 71 failures on main, none of them a real regression.
test_tensor_split_abort_raises_early_to_layer_fallback pins the order of two branches in load_model by their source offsets. #9173 renamed the variable handed to _strip_mmproj_args, so the find() of the old spelling returned -1 and the ordering assert compared against it. Pin the call itself and fail loudly when it is no longer reachable.
The harness records every /api/ URL issued during a measured action, then keeps only the count, so the failure reads let 2 /api/ requests reach the network during the measured actions and stops there. It says an interaction paid for a round trip without saying which one, and the reader has to bisect the frontend to learn what the harness already knew and discarded. It now reports the endpoints. Deduplicated and capped at eight, because the case this instrument exists to catch is a request issued once per message, which would otherwise print hundreds of copies of one line. This is why it surfaced now: the step has not run on main since #9173, whose unit test break fails earlier in the same job and short-circuits it. It was last green at 54b6ca4. With the unit tests repaired on this branch the job reaches the step again, and the first thing it needed to say was the one thing it did not.
Frontend CI has been red on main since unslothai#9173. Vite and tsc resolve an extensionless relative import, the node test runner's ESM resolver does not, and queued-model-capabilities.test.ts reaches this module through image-input-support.ts, so the whole file failed to load: ERR_MODULE_NOT_FOUND: Cannot find module '...chat/utils/mmproj-fallback' imported from ...chat/utils/image-input-support.ts Unrelated to this branch and picked up here only because it is one line and this PR cannot show a green frontend check until it lands. 3797 unit tests pass, build and typecheck clean.
…t guard it (#9189) * Repair the two chat auto-load suites that #9173 left red on main #9173 added a vision-projector fallback to the auto-load success toast. Both of the suites that read that code broke on it, and both were green on the commit immediately before (54b6ca4). 72 tests, in two different shapes: 1. tests/studio/test_chat_autoload_failure_gate.py, 71 failures. The harness slices autoLoadSmallestModel verbatim out of chat-adapter.ts and runs it, so anything the slice references must exist in PREAMBLE. mmprojFallbackMessage did not, which is a bare ReferenceError inside the retry loop; the loop catches it and scores it as a failed load, so every scenario fails as a wrong-model assertion. The file's own guard caught this and named the symbol, which is what it was written for after #7699 did the same thing. Stubbed as a function of the reason rather than a copy of the real three-message record. The value only reaches `options.description`, and these scenarios assert on which model loaded, never on toast copy, so copying user-facing strings in here would give them a second home to drift from. 2. tests/studio/test_model_picker_contracts.py, 1 failure. It asserted the literal `description: cpuFallbackReason`, and the mmproj branch went in front of it. The property held; only the spelling moved. Its own comment records this happening once already, when the CPU-fallback branch first appeared, so it now pins the property: the description varies on both fallback reasons and still has an undefined arm for the ordinary path. Scoped to the description EXPRESSION, not the whole helper. `cpuFallbackReason` is also a parameter name in the signature above, so a substring test over the block stays green with the CPU branch deleted outright -- the first cut of this check did exactly that, and mutation caught it. Three mutations verified red: the description no longer driven by any fallback reason, the CPU branch dropped, and the mmproj branch dropped. 4223 passed, 4 skipped. * Say both fallbacks when both fire, not just the projector one Both load paths wrote the toast description as mmprojFallbackReason ? mmprojMessage : cpuFallbackReason ? cpuMessage : undefined so whenever both reasons are set the CPU-fallback sentence is dropped. The user is told "loaded without vision" and never told the model is running on the CPU, which reads as a deliberate, explained degradation rather than an unaccelerated session. The combination is reachable. On a CPU-fallback replay llama_cpp.py preserves _cpu_fallback_reason (it clears it only when not _replaying_cpu_fallback) and resets _mmproj_fallback_reason so the projector can fail again inside that same launch. A low VRAM machine whose Vulkan backend crashed is exactly where the projector then falls back too. loadFallbackNotice() in mmproj-fallback.ts is now the single composition of the title suffix, the description and the degraded flag, and both call sites delegate to it. CPU_FALLBACK_MESSAGE moves there as well, so the two paths cannot describe the same condition differently again. Tests: four combined-case cases in mmproj-fallback.test.ts, verified red against the shipped nested ternary. test_model_picker_contracts.py now asserts the call sites delegate and pass both reasons rather than matching the old inline ternary, and test_chat_autoload_failure_gate.py's stub mirrors the composition so a call site dropping a reason stays detectable. * Repin the CPU-fallback toast test to behaviour, and unbreak the queued-capabilities test Two frontend suites were red. auto-load-cpu-fallback-toast.test.ts matched the warn-vs-success choice and the message text as substrings of showAutoLoadSuccess. Both moved into loadFallbackNotice, which is the single definition the explicit-load path now shares, so the match went stale. Matching the inline form again would go red on a refactor that changes nothing a user can see, and would stay green if only one of the two load paths kept the behaviour. It now calls loadFallbackNotice and asserts the verdict, and separately asserts the call site delegates to it. queued-model-capabilities.test.ts was red on main before this branch. #9173 added `import { isTextOnlyMmprojFallback } from "./mmproj-fallback"` to image-input-support.ts, which the test imports statically. Extensionless is the right form -- 2314 of the 2367 relative imports under src/ are written that way, and vite and tsconfig's "bundler" mode resolve them -- but the bare node loader does not, and a static import resolves before any registration can run. The test now registers the bundler resolver and imports dynamically, which is what mmproj-fallback.test.ts already does for the same module. Both files reformatted by biome; regex literals hoisted out of the test bodies for useTopLevelRegex. Full frontend suite: 3734 pass, 0 fail. typecheck clean. The 4 biome errors in chat-adapter.ts and use-chat-model-runtime.ts are byte-identical on origin/main. * Order the split-axis abort against the mmproj strip, not against its argument test_tensor_split_abort_raises_early_to_layer_fallback has been red on main since #9173, which renamed the text-only strip's argument from _last_spawn_cmd to _vision_gpu_cmd. That rename is right: the strip should read the vision GPU command rather than whatever was spawned last, and #9173 refreshes _last_spawn_cmd from the result immediately after. The test was pinned to the old argument name, so a rename with no behavioural content took it down. The failure also misreported itself. `assert raise_idx < src.find(needle)` reads as an ordering check but is two claims at once, and when the landmark is gone it fails with "assert 249423 < -1" -- which says the ordering broke, when what happened is that the landmark moved. Each landmark is now required to exist before it is ordered, and says so. The strip is matched on the call rather than on what is passed to it. What this test is about is that the abort raises BEFORE the projector is discarded (#6659); which command the strip reads from is that code's own business. Checked both ways: removing the strip call from load_model goes red with a message naming the missing landmark, and renaming the argument again stays green. * Name the endpoints when the heavy-thread harness catches a stray request The harness records every /api/ URL issued during a measured action, then keeps only the count, so the failure reads let 2 /api/ requests reach the network during the measured actions and stops there. It says an interaction paid for a round trip without saying which one, and the reader has to bisect the frontend to learn what the harness already knew and discarded. It now reports the endpoints. Deduplicated and capped at eight, because the case this instrument exists to catch is a request issued once per message, which would otherwise print hundreds of copies of one line. This is why it surfaced now: the step has not run on main since #9173, whose unit test break fails earlier in the same job and short-circuits it. It was last green at 54b6ca4. With the unit tests repaired on this branch the job reaches the step again, and the first thing it needed to say was the one thing it did not. * Skip the playwright harness tests on the module they need, not the package Five tests guard themselves with `pytest.importorskip("playwright")` and then import a harness that does `from playwright.sync_api import Page`. On the Repo tests (CPU) runner the top-level name resolves as a namespace directory with no sync_api inside it, so the guard passes and the import dies with ImportError: cannot import name 'Page' from 'playwright.sync_api' (unknown location) A skip condition reported as a failure, on every branch, for as long as that runner stays that way. It is red on #9202 and #9213 too, neither of which touches any of this. One of the two files already said what the guard was really for: "importing a harness pulls in playwright.sync_api". It now checks that. * Stop the fork-count store asking the server about threads it has never seen Two fixes, both found by the heavy-thread smoke once it could name what it caught. The smoke reported "let 2 /api/ requests reach the network during the measured actions" and, with the endpoints now printed, they were POST /api/chat/threads/__LOCALID_lsQbsDZ/forks A `__LOCALID_` thread has no server record, so that request can only 404, and getThreadForkCounts already maps 404 to the empty map the entry starts as. It is a round trip whose answer is known before it is sent. Not a rounding error. A new chat is in exactly that state, and this store refreshes on CHAT_HISTORY_UPDATED_EVENT, which fires once per streaming chunk, so the first reply in a new chat paid one useless request per debounce window for as long as it streamed. #8992 added the store to stop the chat getting slower as a thread fills; excluding threads the server has never seen is the same intent. thread-ids.ts already had the predicate. Two tests: a local thread must not fetch on subscribe or on a burst of history events, and a saved thread on screen beside it must still refresh -- the guard has to be per thread, not a global off switch. They import the real isAssistantLocalThreadId rather than restating the prefix, so the rule under test cannot drift from the app's. Both go red with the guard removed. Second fix, same job: the playwright skip guard. The previous commit moved it from "playwright" to "playwright.sync_api" and it still failed, because sync_api resolves as a namespace package on that runner too. Only the symbol the harnesses import distinguishes a usable install, so the guard now checks for Page the way the harness does. Verified both ways against a Page-less sync_api: it skips, and it still proceeds when Page is there. Frontend suite 3789 pass, typecheck clean, tests/studio 4237 pass. * Bound and retry the Playwright browser install so a stall is not a silent 30 minutes This step stalls. Three times in one day it sat in apt's download loop until the job's 30-minute timeout killed it, while the sibling shards finished the whole job in 4 to 9 minutes. Twice on #9202 and once on #9189, always the same step. The cost is out of proportion to the cause. GitHub scores a job timeout as "cancelled" rather than a failure, prints no reason, and skips every step after it, so the chat shard reported nothing about the chat surface for what both times turned out to be an infrastructure hiccup that cleared on a plain re-run of the same commit. A per-attempt `timeout` turns the stall into a failure instead of a silent wait, and the retry is what actually recovers. The healthy time is about 2 minutes, so 8 per attempt is 4x headroom and a merely slow mirror will not trip it. timeout-minutes bounds the pair in case `timeout` is outlived by an unkillable child. Same reasoning, and the same wording, as the bounded prime-hf step in studio-mac-ui-smoke.yml. Both install steps in this file, since ui-smoke and ui-indicator run the identical command. Left alone on mac and windows: neither passes --with-deps, so neither has the apt phase this is about, and neither has been observed to stall. * Make the Playwright install retry able to actually recover The bound added in the previous commit worked: the stall became an 8m37s step FAILURE with a complete log instead of a silent 30-minute cancellation, and the log named the cause on the first try. It also showed the retry could not work. playwright shells out to apt-get as root, so terminating the python parent leaves that child alive holding the lock, and attempt 2 died two seconds later with E: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 4578 (apt-get) A retry that cannot succeed is worse than no retry: it buries the real reason under a second, different failure. Attempt 2 now waits for the lock to clear, up to two minutes, and only then takes it -- the holder is our own orphan and the runner is a throwaway. Two smaller things the same log exposed. --kill-after was missing, so a process that ignores SIGTERM would have been waited on forever inside the step bound. And the warning said "did not finish within 8 minutes" about a two-second exit, which sends the next reader looking for a stall that never happened; it now separates timeout's 124/137 from playwright refusing outright, and prints the status. timeout-minutes 18 to 22 to cover two 8-minute attempts plus the lock wait, still inside the job's 30.
* Give the mmproj fallback import its file extension node --experimental-strip-types resolves relative specifiers literally, so the extensionless import added in #9173 fails at import time and takes queued-model-capabilities.test.ts down with it. Before that commit this module had only import type lines, which are erased, so it carried no runtime relative import at all and the test passed. 55 other modules already spell the extension. * Studio: repair the repo tests #9173 left red The mmproj fallback landing added a mmprojFallbackMessage import to chat-adapter.ts. Two repo tests read that file's source: - test_chat_autoload_failure_gate slices autoLoadSmallestModel out of the adapter and runs it, and its own guard fails the whole file when the slice references a name the harness preamble does not define. Add the stub. - test_model_picker_contracts pinned the success toast's description as the literal 'description: cpuFallbackReason'. The mmproj branch now sits ahead of the CPU one, so pin the description expression instead of which fallback is tested first. 71 failures on main, none of them a real regression. * Studio: repair the backend test #9173 left red test_tensor_split_abort_raises_early_to_layer_fallback pins the order of two branches in load_model by their source offsets. #9173 renamed the variable handed to _strip_mmproj_args, so the find() of the old spelling returned -1 and the ordering assert compared against it. Pin the call itself and fail loudly when it is no longer reachable. * Stop the Windows chat UI smoke racing the route Suspense fallback exercise_permission_mode_controls asserts the permission pill visible on the 5s expect default, immediately after the composer mounts. The composer can mount and then drop back behind the root Suspense fallback while the route chunk loads, so the assertion lands on 'Loading...' and gives up. Reproduced on main at aa32c18: same step, same line, aria snapshot '- text: Loading...'. It is Windows-only in practice because the mac smoke wraps the script in a 3-attempt retry and the Windows one does not, so a slow 4-vCPU runner surfaces the race raw. Wait the pill out on the same budget the composer already uses. * Wait the permission pill out at every reload, not just the first The macOS smoke hit the same Suspense race at the second assertion, which the first commit did not cover. Four of the six assertions in this block follow page.reload(wait_until = domcontentloaded), which returns long before the lazy chat chunk resolves, so asserting on expect's 5s default races it by construction rather than only on a slow runner. Route all six through one helper that waits on the composer's budget. Seen on both the Windows and macOS smokes as 'Aria snapshot: - text: Loading...' at playwright_chat_ui.py:135 and :189. * Give the playwright stub every name the harnesses import The CPU test job has no playwright, so tests/studio/test_heavy_thread_measurement_integrity.py puts a stub `playwright.sync_api` into sys.modules at collection time rather than skipping the harness arithmetic along with the browser. That stub defined one name, `sync_playwright`, which is all its own harness imports. sys.modules is session-wide, so the stub is not read only by the file that installs it. Three of the four harnesses import `sync_playwright` alone and were satisfied by it; playwright_strip_ansi_smoke also imports `Page` and `expect`, and got ImportError: cannot import name 'Page' from 'playwright.sync_api' (unknown location) from a stub two files away. `(unknown location)` is the stub itself: a bare ModuleType has no __file__. The two tests that import that harness, test_the_ansi_dump_survives_a_vite_server_that_is_ still_talking and test_an_empty_smoke_base_url_means_unset[playwright_strip_ansi_smoke], failed on it. pytest.importorskip("playwright") does not save them, because by then the stub package is importable. This is pre-existing on main and predates this branch, which never touched either file. It was masked: the same job was failing with 71 other errors, which this PR fixes, so these two were never the reported cause. They belong here because this is the PR that makes the job green. The stub now answers any public name with a callable that raises, so a harness can satisfy its imports without quietly measuring a browser that is not there, and adding an import to a harness cannot break a different file again. Dunders still raise AttributeError, since pytest and inspect probe those and answering them makes the stub look like a package. The install probe also imports off the submodule now: a partial install leaves `playwright` importable while `playwright.sync_api` resolves to an empty namespace, which fails the same way. Verified by blocking playwright in a subprocess to reproduce the CPU job: 2 failed, 104 passed before, 106 passed after, with the two files alone skipping cleanly when the stub is not collected. * Stub the fork-count endpoint the heavy-thread smoke actually requests The heavy-thread browser smoke fails its own harness check on this branch: HARNESS-BROKEN chromium at 25000 chars let 2 /api/ requests reach the network during the measured actions; the timings include a round trip per request Both leaked requests are GET /api/chat/threads/__LOCALID_.../forks, one during seeding and two more inside the measured actions. The smoke page answers a small allowlist of endpoints in-page so no round trip lands in a timed region, and the fork-count entry in that allowlist still matches the per-message endpoint, /threads/{id}/messages/{id}/forks. #8992 replaced it with one per-thread request built by getThreadForkCounts, and the allowlist was not moved with it, so every fork-count GET went to the dev server. fork-count-store refreshes on CHAT_HISTORY_UPDATED_EVENT, which the delete action fires, which is why two of them land inside the measurement rather than only at load. Match the URL the client builds and answer the body the endpoint returns: getThreadForkCounts reads data.counts into a Map, so {"counts":{}} is "no message has forks" and renders no badge. The fixture is unchanged by this: the census at both sizes is identical to the failing run, 3676 and 14285 DOM nodes, 20 and 80 messages, 3216 and 12804 highlighted tokens. Only the round trips are gone. This has been broken repo-wide since #8992 and invisible. On every other open PR the earlier Unit tests step in this job fails on a broken import, so Install Chromium and every Browser smoke step is skipped; this branch is the first job in which they run at all. Compare step outcomes on #9081, Unit tests failure and all smokes skipped, with this branch, Unit tests success and the smokes running. Two things so the next drift costs less. The stray-request failure now names the first three distinct URLs, because it fires in CI where nobody can attach a listener afterwards, and finding this one meant re-running the smoke locally with a print statement patched in. And a unit test now checks the allowlist against the URL chat-api.ts builds, rather than against a string someone remembered to update, so the same drift fails in Dev-server lifecycle tests instead of waiting for a job where the browser smokes get to run. The self-check itself is untouched: still zero tolerated strays, still failing the run. Verified locally on chromium at 25000 and 100000 chars: before, 2 stray requests at each size and exit 1; after, 0 stray requests at each size, 9 stubbed rather than 6, and exit 0. The three smokes the aborted job skipped, settings tab panels, a settings panel that cannot load, and chat stream pacing, all pass locally as well, so nothing further is hiding behind this one.

Summary
--no-mmproj-offloadbefore removing--mmproj.Context
On a low VRAM GPU, loading PaddleOCR-VL with its vision projector can terminate
llama-serverwith exit code-6. Studio previously restarted without the projector and did not explain that vision had been disabled.The recovery order is now:
llama-serversupports the placement flag.Verification
git diff --check: passedCloses #9146