Repository navigation
Studio: restore tensor parallelism for vision/mmproj GGUFs - #6659
Conversation
#6416 disabled --split-mode tensor for any GGUF that ships an mmproj projector to dodge a GGML_ASSERT crash (#6415) seen on an older llama.cpp build with consumer Blackwell (sm_120). The blanket skip silently dropped tensor_parallel=true for every multimodal/MTP GGUF (e.g. Qwen3.6-35B-A3B-MTP); on hardware where the model fits on one GPU the load then collapsed to a single GPU. mmproj + --split-mode tensor works on current builds (verified end to end on B200/sm_100), so the skip was disabling a working configuration. Make the vision skip self-healing per binary: - attempt tensor for vision models by default - skip upfront only on a binary already seen to abort on tensor + mmproj this session (_vision_tensor_split_aborts), recorded when such a launch crashes at startup (_record_vision_tensor_split_abort). Process scoped, so a studio update re-probes the new build. The route-level layer-split fallback stays the net. - add _select_gpus(min_gpus=...) so a downgraded tensor request can keep multiple GPUs instead of collapsing to one (default 1, no behavior change). Add tests/test_tp_vision_regression.py: an AST allowlist guard over the tensor_parallel drop sites (which would have flagged #6416), plus cache and _select_gpus coverage. No GPU required.
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 84e08c63b1
ℹ️ 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 _startup_crashed and self._tensor_parallel and launched_with_mmproj: | ||
| LlamaCppBackend._record_vision_tensor_split_abort(binary) |
There was a problem hiding this comment.
Defer abort caching until tensor retries fail
When a vision tensor launch crashes on the first spawn but is eligible for the existing --fit off retry, this records the binary as --split-mode tensor + --mmproj incompatible before that retry runs. If the retry then succeeds, the binary is still cached as bad, so later vision loads in the same process skip tensor parallelism even though the successful command proved tensor+mmproj can work when --fit is disabled. Record the abort only after the launch path has actually failed all startup retries, or distinguish fit-step crashes from tensor/mmproj aborts.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Good catch, this was real. The first version recorded the abort inside _spawn_and_wait on the very first spawn crash, which on every build (B200 included) is the benign --fit step abort that the --fit off retry then resolves. So the binary got cached as incompatible even though tensor + mmproj works once --fit is disabled, and the next vision load in the same process skipped tensor parallelism.
Moved the record into the post-all-retries failure block, after the --fit off, flash-attn-off and MTP-drop retries have all failed. A load that any of those retries rescues never reaches the record, so the fit-step abort no longer poisons the cache.
Verified with two vision + tensor loads in one backend process: both now stay 4-GPU tensor parallel (the second load used to collapse to a single GPU). Locked in by test_vision_tensor_abort_recorded_only_after_retries_and_signature.
| "llama.cpp build aborted on --split-mode tensor + " | ||
| "--mmproj earlier this session; using layer split." | ||
| ) | ||
| tensor_parallel = False |
There was a problem hiding this comment.
Preserve multi-GPU fallback when disabling tensor
When this cached vision gate fires, tensor_parallel is set to False and the later layer-split GPU selection has no record that the user requested multi-GPU tensor mode; the explicit/file-size paths still call _select_gpus with the default min_gpus=1, and the auto-context path tries one GPU first. On a known-bad binary with multiple GPUs and a model that fits on one card, the documented layer fallback therefore collapses to a single GPU—the same silent downgrade this change is trying to prevent. Keep the original TP intent and pass it into the layer selection (or equivalent) when falling back.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed. When the cached vision gate fires it now preserves the multi-GPU intent instead of letting the layer fallback collapse to one card:
tensor_parallel = False
_layer_min_gpus = max(_layer_min_gpus, len(gpus))_select_gpus gained a min_gpus parameter, and both the explicit and file-size paths now pass min_gpus=_layer_min_gpus, while the auto-context selection starts at range(max(1, _layer_min_gpus), len(ranked) + 1). So a known-bad binary with a model that fits on one card still layer-splits across the GPUs tensor would have used, rather than silently single-GPU-ing it (the same downgrade this PR is preventing).
Covered by test_vision_downgrade_preserves_multi_gpu_intent and the _select_gpus(min_gpus=...) unit tests.
| if _startup_crashed and self._tensor_parallel and launched_with_mmproj: | ||
| LlamaCppBackend._record_vision_tensor_split_abort(binary) |
There was a problem hiding this comment.
Verify the crash is the tensor/mmproj assert
This records the binary as vision-tensor incompatible for any startup crash while tensor and --mmproj are present, including ordinary OOMs, bad user extra args, or MTP/flash-attention crashes that are not caused by the --split-mode tensor + --mmproj assertion. In those cases a failed load poisons the process-wide cache, so subsequent vision models on the same otherwise-capable binary skip tensor parallelism until Studio restarts. Gate this cache update on the specific failure signature (or another confirmed tensor/mmproj-only diagnosis) rather than every nonzero startup exit.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Agreed. The record is now gated on the failure signature rather than any nonzero exit:
if (
self._tensor_parallel
and launched_with_mmproj
and self._is_signal_crash(_crash_rc)
and not self._output_has_nonprojector_diagnostic(out)
):
LlamaCppBackend._record_vision_tensor_split_abort(binary)The #6415 failure is a GGML_ASSERT (SIGABRT), so _is_signal_crash requires a signal/abort rather than a clean nonzero exit, and _output_has_nonprojector_diagnostic excludes OOM, unknown-arch and other diagnosable causes. A bad-user-args failure, an OOM or an MTP/flash-attn crash no longer poisons the process-wide cache. Combined with deferring to after all retries, the cases that a retry would have rescued never reach this point either.
Three fixes from the PR review: - Record a vision-tensor abort only after every startup retry fails. The first version cached the binary on the first spawn crash, which on every build (including capable ones) is the benign --fit step abort that the existing --fit off retry resolves. That poisoned the cache so the next vision load in the same process skipped tensor. Recording now happens at the post-retry failure block (after fit-off, flash-attn-off and MTP-drop), so a binary that actually works is never cached. - Gate the record on the tensor/mmproj crash signature: a hard signal fault (_is_signal_crash) with no non-tensor cause (_output_has_nonprojector_diagnostic excludes OOM and unknown-arch), so an OOM, bad extra args, or MTP/flash-attn crash no longer marks an otherwise capable binary incompatible. - Preserve the multi-GPU request on the cached downgrade. The vision gate now raises _layer_min_gpus to the visible GPU count and threads it through the layer-split GPU selection (_select_gpus min_gpus and the subset loops), so a downgraded tensor request still spreads across GPUs instead of collapsing to a single card the model happens to fit. Verified two vision+tensor loads in one backend process both tensor-split across 4 GPUs (the benign fit abort no longer poisons the cache). Tests updated.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cfde0b1377
ℹ️ 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 ( | ||
| self._tensor_parallel | ||
| and launched_with_mmproj | ||
| and self._is_signal_crash(_crash_rc) | ||
| and not self._output_has_nonprojector_diagnostic(out) | ||
| ): | ||
| LlamaCppBackend._record_vision_tensor_split_abort(binary) |
There was a problem hiding this comment.
Retry layer split before stripping mmproj
When an unprobed binary aborts only for the --split-mode tensor + --mmproj combination, this records the cache entry but then falls through to the existing projector-incompatibility branch below, which strips --mmproj and can successfully load the model text-only. Because load_model then returns success, the route-level tensor→layer fallback is never invoked, so the first vision load on exactly the bad binaries this cache targets loses vision instead of retrying layer split with the projector; only later loads benefit from the cached layer path.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed. The recovery now classifies the tensor + --mmproj GGML_ASSERT separately and raises, so the route-level load_with_tensor_fallback retries --split-mode layer with the projector intact instead of falling through to the projector-incompatibility branch that strips --mmproj and loads text-only:
vision_tensor_split_crash = (
self._tensor_parallel
and launched_with_mmproj
and self._is_signal_crash(_crash_rc)
and not self._output_has_nonprojector_diagnostic(out)
)
if vision_tensor_split_crash:
LlamaCppBackend._record_vision_tensor_split_abort(binary)
self._kill_process()
if vision_tensor_split_crash and not self._cancel_event.is_set():
raise RuntimeError(
"llama-server aborted on --split-mode tensor + --mmproj; "
"retrying with layer split (projector preserved)."
)So the first vision load on a bad binary now keeps vision via layer split, not just the later cached loads. The retry runs tensor-off, so it won't re-enter this path; a genuine projector failure on the layer retry still strips --mmproj text-only as before. Five independent reviewers also flagged this one, so it's the headline fix. Covered by test_tensor_mmproj_abort_retries_layer_split_not_text_only.
| # Honor the multi-GPU request: layer-split across the GPUs | ||
| # tensor would have used, not one card the model happens to | ||
| # fit, so the downgrade doesn't silently single-GPU it. | ||
| _layer_min_gpus = max(_layer_min_gpus, len(gpus)) |
There was a problem hiding this comment.
Base the fallback minimum on usable tensor GPUs
When the cached vision gate fires on a host where some detected GPUs are nearly full, this forces the layer fallback to require every detected GPU even though the tensor path would have filtered unusable devices out via tp_gpus. For example, two sufficiently free GPUs plus one nearly-full GPU can fit as a two-GPU layer split, but min_gpus=len(gpus) makes the later selector either include the nearly-full card or fall back to --fit, turning a viable pinned multi-GPU fallback into an OOM-prone or offloaded launch.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed at the selection layer so it applies to every downgrade path. _select_gpus now caps min_gpus to the count of GPUs with usable VRAM (free minus the headroom reserve, above the per-device layer overhead), so a downgraded multi-GPU request never pulls in a nearly-full card or trips --fit just to satisfy the count:
usable_count = sum(1 for idx, free_mib in ranked if _usable(idx, free_mib) > overhead_mib)
min_gpus = max(1, min(min_gpus, usable_count or 1))The vision gate still passes len(gpus) and the budget path passes len(tp_gpus); the cap inside _select_gpus filters either down to what is actually usable. No effect on the default min_gpus == 1 callers. Covered by test_select_gpus_min_gpus_excludes_unusable_gpu (2 free + 1 nearly-full card -> 2-GPU layer split, not 3).
Related: the pooled-VRAM budget downgrade was also missing the multi-GPU preservation the vision gate had (it flipped tensor_parallel = False without raising _layer_min_gpus), so it could still collapse to one card. That asymmetry is fixed too (_layer_min_gpus = max(_layer_min_gpus, len(tp_gpus))), covered by test_budget_downgrade_preserves_multi_gpu_intent.
| @classmethod | ||
| def _vision_tensor_split_aborts(cls, binary: Optional[str]) -> bool: | ||
| """True if `binary` was seen this session to abort on tensor + --mmproj.""" | ||
| return bool(binary) and binary in cls._vision_tensor_abort_binaries |
There was a problem hiding this comment.
Re-probe binaries after in-app updates
After a tensor/mmproj abort, using the in-app llama.cpp updater swaps the install in place and refreshes freshness caches without restarting the backend, so the binary path remains the same. Because this predicate keys the bad-binary cache only by that path, a reload after a successful update still treats the newly installed binary as incompatible and skips vision tensor parallelism until a full Studio restart; include the install marker/mtime in the key or clear this set after the updater succeeds.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed. The abort cache now keys on (path, mtime) via a helper that mirrors _capability_cache:
@classmethod
def _vision_binary_cache_key(cls, binary):
if not binary:
return None
try:
mtime = int(Path(binary).stat().st_mtime)
except OSError:
mtime = 0
return (binary, mtime)POST /api/llama/update swaps the binary in place (no backend restart) and bumps its mtime, so the new build gets a fresh key and is re-probed instead of inheriting the old one's abort. Covered by test_vision_abort_cache_invalidated_on_binary_mtime_change.
Address the second review round on the vision/mmproj tensor-parallel fix: - Preserve vision on the first load: a --split-mode tensor + --mmproj GGML_ASSERT now raises so the route-level tensor->layer fallback retries layer split with the projector intact, instead of stripping --mmproj and silently loading text-only (which returned success and skipped the fallback, losing vision on the first load until the next cached load). - Symmetric multi-GPU preservation: the pooled-VRAM tensor downgrade now raises _layer_min_gpus from the usable tensor GPUs like the vision downgrade, so it no longer collapses a multi-GPU request to a single card. - Base the layer fallback minimum on usable GPUs: _select_gpus caps min_gpus to the count of cards with usable VRAM, so a downgrade never forces a nearly-full card in (or trips --fit) just to hit the count. - Re-probe after in-app updates: key the per-binary abort cache on (path, mtime) like _capability_cache, so POST /api/llama/update swapping the binary in place (no backend restart) re-probes the new build instead of inheriting the old build's abort. - Bump _layer_min_gpus for a known-bad vision binary independent of the tensor drop, so the route fallback's layer retry (tensor already off) still spreads across GPUs. Adds deterministic non-GPU regression tests for each.
|
Thanks for the second pass. All three points are addressed in
Each has a deterministic non-GPU regression test in Re-verified on 4x B200 that the happy path (a build that does not abort) still tensor-splits: two vision + tensor loads in one backend process both came up Inline replies on each thread below. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 70ca9ada92
ℹ️ 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 effective_is_vision and self._vision_tensor_split_aborts(binary): | ||
| _layer_min_gpus = max(_layer_min_gpus, len(gpus)) |
There was a problem hiding this comment.
Gate cached vision layer minimum on tensor intent
After any prior tensor+mmproj abort records this binary, this guard runs for every later vision load, even when the current request did not ask for tensor parallelism (or explicitly requested layer split). That changes the normal layer path from minimizing GPU count to requiring len(gpus) via _layer_min_gpus, so a small vision model that fits on one card can grab all GPUs simply because an earlier TP attempt failed in the same backend process. Keep this bump tied to a current/retry tensor request rather than the cache alone.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Good catch, fixed in 861f74bca. I'd decoupled this bump from the tensor drop to also cover the route fallback's layer retry, but as you note that made it fire for every later vision load on a recorded-bad binary, so a plain non-tensor vision load that fits on one card would grab every GPU. The bump is now back inside the tensor-drop guard:
if tensor_parallel and effective_is_vision and self._vision_tensor_split_aborts(binary):
...
tensor_parallel = False
_layer_min_gpus = max(_layer_min_gpus, len(gpus))
_restore_after_tensor_downgrade()So it's gated on the current tensor request: a non-tensor vision load minimizes device count as before, and a downgraded tensor request still spreads (capped to usable cards by _select_gpus). The only thing this gives up is the first load's RuntimeError-driven layer retry, which runs tensor-off and so single-GPUs a model that fits on one card; every subsequent tensor-requested load on that cached binary is multi-GPU. Threading the original tensor intent through the route fallback to recover that one first-load case is more plumbing than it's worth. New guard pinned by test_vision_layer_min_gpus_bump_requires_tensor_request.
The cached-vision _layer_min_gpus bump fired for every later vision load on a binary recorded as tensor+mmproj-incompatible, including loads that did not request tensor parallelism. A plain non-tensor vision load that fits on one card would then grab every GPU just because an earlier TP attempt aborted in the same backend process. Re-tie the bump to the current tensor request (back inside the tensor-drop guard), so only a downgraded tensor request preserves the multi-GPU spread; a non-tensor vision load minimizes device count as before.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 861f74bca3
ℹ️ 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 vision_tensor_split_crash and not self._cancel_event.is_set(): | ||
| raise RuntimeError( | ||
| "llama-server aborted on --split-mode tensor + --mmproj; " | ||
| "retrying with layer split (projector preserved)." |
There was a problem hiding this comment.
Preserve GPU count on the first tensor/mmproj fallback
When an unprobed binary hits this tensor+mmproj crash, this raise hands control to the generic tensor fallback, whose retry calls the loader with tensor_parallel=False and an explicit --split-mode layer. Fresh evidence vs the cached-gate fix: that retry bypasses the tensor_parallel and effective_is_vision and self._vision_tensor_split_aborts(binary) block that raises _layer_min_gpus, so a vision model that fits on one card still loads the first successful fallback on a single GPU despite the user's TP request; only later loads benefit from the cache. Carry the original multi-GPU intent into the retry or perform the layer retry where _layer_min_gpus is still available.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 4708d3026. You're right that the generic fallback retry runs tensor-off, so the in-function downgrades couldn't see the original tensor request. Rather than thread state through the shared helper, the GGUF load closure detects the downgrade retry directly (it has both the original toggle and the per-attempt flag) and passes it to the loader:
preserve_multi_gpu_on_layer = bool(request.tensor_parallel and not tensor_parallel)load_model then raises _layer_min_gpus when that's set:
if preserve_multi_gpu_on_layer:
_layer_min_gpus = max(_layer_min_gpus, len(gpus))So the first successful fallback of a fits-on-one-card model spreads across GPUs (capped to usable cards by the selection paths) instead of pinning to one device. It's gated on the actual original tensor request, so a plain non-tensor load is unaffected, and it generalizes to any tensor->layer fallback, not just vision. Covered by test_layer_fallback_retry_preserves_multi_gpu_intent.
| gpus, key = lambda g: _gpu_usable(g, pin_fraction), reverse = True | ||
| ) | ||
| for n_gpus in range(1, len(ranked) + 1): | ||
| for n_gpus in range(max(1, _layer_min_gpus), len(ranked) + 1): |
There was a problem hiding this comment.
Cap auto layer retries to usable GPUs
When the cached vision downgrade raises _layer_min_gpus, this auto-context path starts at that raw count over ranked = gpus; unlike the explicit/file-size paths it bypasses _select_gpus, so the usable-GPU cap added there is not applied. Fresh evidence vs the earlier fixed comment: this loop does not call _select_gpus; with two free GPUs plus one nearly-full GPU and auto context, it only tries a 3-GPU subset including the full card (and the 4096 retry below does the same), so a viable 2-GPU layer split can become an OOM-prone launch or fall back to --fit.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Good catch, this path does bypass _select_gpus so the usable-GPU cap I added there didn't reach it. The auto-context loops now derive a capped minimum and start from it:
_auto_min_gpus = max(
1,
min(
_layer_min_gpus,
sum(1 for g in ranked if _gpu_usable(g, pin_fraction) > 0) or 1,
),
)
for n_gpus in range(_auto_min_gpus, len(ranked) + 1):
...Both the native-context loop and the 4096 retry below use _auto_min_gpus, so two free GPUs plus one nearly-full card now try a 2-GPU subset rather than only a 3-GPU subset that includes the full card. Covered by test_auto_context_layer_loops_capped_to_usable_gpus.
| vision_tensor_split_crash = ( | ||
| self._tensor_parallel | ||
| and launched_with_mmproj | ||
| and self._is_signal_crash(_crash_rc) | ||
| and not self._output_has_nonprojector_diagnostic(out) |
There was a problem hiding this comment.
Avoid caching bare projector crashes as tensor aborts
This still records the binary on any signal crash with no non-projector diagnostic while tensor and --mmproj are present; fresh evidence against the earlier signature fix is that the projector fallback immediately below uses the same bare-signal predicate for projector incompatibility. If a corrupt or too-new projector SIGSEGVs independently of split mode, the layer retry may strip --mmproj, but the binary remains cached as tensor/mmproj-incompatible and later compatible vision models skip tensor parallelism until restart. Record the cache only after confirming the tensor/mmproj assert rather than this overlapping bare-crash condition.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed. The record (and the layer-retry raise) no longer share the bare-signal predicate with the projector-incompat branch; they now require the ggml assert marker:
@staticmethod
def _is_tensor_split_assert(output: str) -> bool:
text = (output or "").lower()
return "ggml_assert" in text or "ggml_abort" in text
vision_tensor_split_crash = (
self._tensor_parallel
and launched_with_mmproj
and self._is_signal_crash(_crash_rc)
and self._is_tensor_split_assert(out)
and not self._output_has_nonprojector_diagnostic(out)
)The #6415 crash is a GGML_ASSERT abort, and stderr is merged into the captured output (stderr=subprocess.STDOUT, which the existing OOM / projector matchers already rely on), so the marker is present for the real case. A corrupt or too-new projector that bare-SIGSEGVs independent of split mode no longer matches, so it isn't cached as tensor/mmproj-incompatible and isn't sent through the tensor layer retry; it falls to the existing projector-incompat branch (text-only) as before. Covered by test_is_tensor_split_assert_marker and test_vision_tensor_abort_requires_assert_marker_for_record_and_raise.
Third review round on the vision/mmproj tensor-parallel fix: - Preserve multi-GPU on the first tensor->layer fallback. The route-level retry runs tensor-off, so the in-function downgrades can't see the original tensor request and a fits-on-one-card model loaded the first successful fallback on a single GPU. The GGUF load closure now passes preserve_multi_gpu_on_layer (the toggle asked for tensor, this attempt is layer) and load_model raises _layer_min_gpus for it, so the downgrade still spreads across GPUs. - Cap the auto-context layer loops to usable GPUs. They bypass _select_gpus, so a raised _layer_min_gpus could force a nearly-full card into the subset (or trip --fit). They now start from _auto_min_gpus, capped to the GPUs with usable VRAM. - Confirm the tensor/mmproj assert before caching. Recording (and the layer-retry raise) now require the ggml assert marker via _is_tensor_split_assert, not the bare-signal predicate shared with the projector-incompat branch, so a corrupt or too-new projector that SIGSEGVs independent of split mode is no longer cached as tensor/mmproj-incompatible. Adds deterministic non-GPU regression tests for each.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4708d3026e
ℹ️ 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".
| preserve_multi_gpu_on_layer = bool( | ||
| request.tensor_parallel and not tensor_parallel | ||
| ), |
There was a problem hiding this comment.
Preserve multi-GPU fallback for all tensor requests
When tensor mode is enabled via llama_extra_args (--split-mode tensor) or inherited LLAMA_ARG_SPLIT_MODE=tensor, load_with_tensor_fallback still retries with tensor_parallel=False, but this hint stays false because it only checks the UI field. In that fallback path load_model leaves _layer_min_gpus at 1, so a model that fits on one card collapses to a single GPU despite an effective tensor request, which is the regression this patch is trying to avoid for extra/env-driven tensor users.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 58d8c17b8. You're right, keying the hint off request.tensor_parallel alone missed extra/env-driven tensor. The hint now uses the same _effective_tensor_parallel check the fallback keys its retry on, comparing the overall request against the current attempt:
preserve_multi_gpu_on_layer = bool(
_effective_tensor_parallel(extra_llama_args, request.tensor_parallel)
and not _effective_tensor_parallel(attempt_extra_args, tensor_parallel)
)So tensor via the toggle, --split-mode tensor in extras, or an inherited LLAMA_ARG_SPLIT_MODE=tensor env all count: the retry forces --split-mode layer, which makes the second term False, so the hint is True exactly on the downgrade retry and load_model keeps the multi-GPU spread. Covered by test_fallback_hint_uses_effective_tensor_request_not_just_toggle.
| _layer_min_gpus, | ||
| sum(1 for g in ranked if _gpu_usable(g, pin_fraction) > 0) or 1, |
There was a problem hiding this comment.
Cap auto fallback to GPUs that can pay layer overhead
In the auto-context layer path, this cap counts any card with positive usable VRAM as eligible. For a tensor-to-layer fallback with _layer_min_gpus=len(gpus), a nearly-full GPU with only a few MiB free still keeps _auto_min_gpus high; the subsequent pool-budget check can pass because other GPUs dominate the pool, and Studio then exposes that nearly-full GPU to llama.cpp even though layer split reserves a fixed per-device overhead for every selected GPU. This can make the preserved multi-GPU fallback OOM on hosts with one busy card; mirror _select_gpus and require usable VRAM to exceed the per-device overhead before counting the card.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed. The cap now mirrors _select_gpus and requires usable VRAM to exceed the per-device layer overhead, not just be positive:
_pipeline_overhead_mib = _pipeline_overhead_bytes / (1024 * 1024)
_auto_min_gpus = max(
1,
min(
_layer_min_gpus,
sum(
1
for g in ranked
if _gpu_usable(g, pin_fraction) > _pipeline_overhead_mib
)
or 1,
),
)_pipeline_overhead_bytes is the same per-device cost the explicit/file-size paths pass to _select_gpus, so a nearly-full GPU with only a few MiB free no longer counts toward _auto_min_gpus and isn't exposed to llama.cpp where it would OOM on its reserved layer-split overhead. Covered by test_auto_context_layer_loops_capped_to_usable_gpus.
…e cap Fourth review round on the vision/mmproj tensor-parallel fix: - Preserve multi-GPU fallback for all tensor requests, not just the UI toggle. Tensor can also be requested via --split-mode tensor in extra args or an inherited LLAMA_ARG_SPLIT_MODE=tensor env; the fallback retries those too, so the preserve_multi_gpu_on_layer hint now keys off _effective_tensor_parallel (the same check the fallback uses), comparing the overall request against the current attempt instead of only request.tensor_parallel. - Cap the auto-context layer fallback to GPUs that can pay the per-device layer overhead. The cap counted any card with positive usable VRAM, so a nearly-full GPU with a few MiB free stayed eligible and could be exposed to llama.cpp and OOM. It now mirrors _select_gpus: a card counts only if usable VRAM exceeds the per-device pipeline overhead. Adds deterministic non-GPU regression tests for both.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 58d8c17b86
ℹ️ 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".
| text = (output or "").lower() | ||
| return "ggml_assert" in text or "ggml_abort" in text |
There was a problem hiding this comment.
Narrow the tensor/mmproj crash signature
When a tensor vision launch aborts with any unrelated GGML_ASSERT/GGML_ABORT while --mmproj is present (for example a corrupt GGUF/projector or another llama.cpp invariant), this helper returns true, so the failure path records the binary and later compatible vision models in the same process skip tensor parallelism. Fresh evidence vs the earlier fix: the marker accepts every ggml assert/abort, not the specific tensor/mmproj warmup assertion. Match the actual #6415 assertion text, or otherwise prove the assertion is split-mode-specific, before caching and raising.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in a9d9aa01d. I pulled the exact assertion from #6415:
ggml-backend-meta.cpp:541:
GGML_ASSERT(src_ss[0].axis != GGML_BACKEND_SPLIT_AXIS_0) failed
The split-axis enum is inherent to tensor splitting, so the marker now requires it rather than accepting any ggml assert/abort:
text = (output or "").lower()
if "ggml_assert" not in text and "ggml_abort" not in text:
return False
return "split_axis" in text or "ggml-backend-meta" in textSo an unrelated invariant a corrupt GGUF or projector trips with --mmproj present no longer matches, isn't cached, and isn't sent through the tensor layer retry. I kept it slightly broader than the literal file:line (split-axis token OR the ggml-backend-meta scheduling file) so a minor reword still matches; if a future build changed it entirely, the worst case is re-crash-then-fall-back each load (vision preserved via layer split), which is safer than poisoning the cache for other models. Covered by test_is_tensor_split_assert_marker.
| # Set by the route-level tensor->layer fallback on its retry (which runs | ||
| # tensor-off): the user requested multi-GPU tensor mode, so keep that | ||
| # intent on the layer split instead of pinning a fits-on-one-card model to | ||
| # a single device. Capped to usable GPUs by the selection paths. | ||
| preserve_multi_gpu_on_layer: bool = False, |
There was a problem hiding this comment.
Persist the layer-preserve hint for respawns
When a tensor→layer fallback succeeds with this new hint, load_model stores _last_load_kwargs from _pending_load_kwargs, which does not include preserve_multi_gpu_on_layer; _respawn_if_dead later replays only that snapshot via self.load_model(**kwargs). For a downgraded model that fit on one card, any mid-session respawn after the llama-server dies loses the hint, leaves _layer_min_gpus at 1, and silently comes back single-GPU despite the original tensor request. Include the hint in the replay snapshot, or derive it from the forced layer retry, so recovery preserves the same GPU placement.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Good catch, real bug. The hint is now part of the replay snapshot so _respawn_if_dead keeps the placement:
_pending_load_kwargs = {
...
"extra_args": list(extra_args) if extra_args is not None else None,
"preserve_multi_gpu_on_layer": preserve_multi_gpu_on_layer,
}On a successful downgrade the snapshot already carries --split-mode layer and tensor_parallel=False, which alone would leave _layer_min_gpus at 1 on the respawn; including the hint makes load_model(**snapshot) raise _layer_min_gpus again, so a fits-on-one-card model comes back multi-GPU after a mid-session llama-server death instead of silently single-GPU. Covered by test_layer_preserve_hint_replayed_on_respawn, and test_gguf_reload_inheritance still passes.
Fifth review round on the vision/mmproj tensor-parallel fix: - Narrow the tensor/mmproj crash signature. _is_tensor_split_assert matched any GGML_ASSERT/GGML_ABORT, so an unrelated invariant a corrupt GGUF or projector trips with --mmproj present could be cached as tensor/mmproj-incompatible. It now matches the specific #6415 warmup assertion (GGML_ASSERT(src_ss[0].axis != GGML_BACKEND_SPLIT_AXIS_0) in ggml-backend-meta), whose split-axis signature is inherent to tensor splitting. A reworded future assert just re-crashes-then-falls-back (vision preserved via layer split) instead of poisoning the cache for other models. - Persist the layer-preserve hint for respawns. A successful tensor->layer fallback committed _last_load_kwargs without preserve_multi_gpu_on_layer, so _respawn_if_dead replayed only --split-mode layer + tensor_parallel=False and a mid-session respawn of a fits-on-one-card model came back single-GPU. The hint is now in the replay snapshot, so recovery keeps the multi-GPU placement. Adds deterministic non-GPU regression tests for both.
|
@codex review |
|
Codex Review: Didn't find any major issues. What shall we delve into next? 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". |
Make the comments and docstrings added by this PR succinct: collapse the multi-line block comments in llama_cpp.py / inference.py to one or two lines, trim the verbose test docstrings (the names and assert messages already carry the intent), and shorten the module docstring. No code changes; verified comment-only with scripts/comment_tools.py check --strip-docstrings.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f3f5e014ab
ℹ️ 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 "ggml_assert" not in text and "ggml_abort" not in text: | ||
| return False | ||
| # split_axis (the enum) / ggml-backend-meta (its file): split-mode specific. | ||
| return "split_axis" in text or "ggml-backend-meta" in text |
There was a problem hiding this comment.
Require split-axis marker before caching aborts
Fresh evidence versus the earlier narrowing is the or "ggml-backend-meta" branch here: any GGML_ASSERT/GGML_ABORT from that source file now satisfies _is_tensor_split_assert, even when the message is a different scheduler/projector/model invariant rather than the GGML_BACKEND_SPLIT_AXIS_* warmup assert. On a vision launch with --mmproj, that causes _record_vision_tensor_split_abort to cache the whole binary as tensor/mmproj-incompatible, so later compatible vision models in the same process skip tensor parallelism until the cache is invalidated. Match the split-axis token/assert text itself rather than the file name alone.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in dfd359093. You're right, ggml-backend-meta holds many asserts, so the file-name branch was too broad. The marker now requires the split-axis token itself:
text = (output or "").lower()
if "ggml_assert" not in text and "ggml_abort" not in text:
return False
return "split_axis" in textThe #6415 warmup assert is GGML_ASSERT(src_ss[0].axis != GGML_BACKEND_SPLIT_AXIS_0), so split_axis (the GGML_BACKEND_SPLIT_AXIS_* enum) is present for the real case and unique to it. A different invariant from the same file (e.g. GGML_ASSERT(buf != NULL)) no longer matches, so it isn't cached as tensor/mmproj-incompatible. Added a regression case for exactly that (an unrelated ggml-backend-meta assert -> False) in test_is_tensor_split_assert_marker.
_is_tensor_split_assert also accepted any GGML_ASSERT/GGML_ABORT from ggml-backend-meta, but that file holds many asserts, so an unrelated scheduler/projector/model invariant on an --mmproj launch could cache the binary as tensor/mmproj-incompatible and make later compatible vision models skip tensor parallelism. Match the GGML_BACKEND_SPLIT_AXIS_* token itself (unique to the #6415 warmup assert), not the source file name.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dfd359093c
ℹ️ 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".
| (), | ||
| {"__init__": lambda s, **kw: None, "__enter__": lambda s: s, "__exit__": lambda s, *a: None}, | ||
| ) | ||
| sys.modules.setdefault("httpx", _httpx_stub) |
There was a problem hiding this comment.
Avoid leaking the httpx stub into later tests
When this test module is collected before any test imports the real httpx package, setdefault installs this lightweight stub into sys.modules even if httpx is available but not imported yet. That stub then persists for the rest of the pytest process; later provider/HF tests that import httpx or huggingface_hub.errors can receive a module missing APIs such as HTTPError/Response, causing collection or runtime failures in shards/targeted runs. Import the real package first and only assign a fallback stub on ImportError, as the neighboring llama_cpp helper tests do.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 138f80f9f. Switched the httpx stub to the real-first pattern the neighboring helper tests (test_compute_buffer, test_mtp_vram_budget) use:
try:
import httpx as _httpx_real # noqa: F401
except ImportError:
_httpx_stub = _types.ModuleType("httpx")
... # incl. HTTPError / RequestError / Response
sys.modules["httpx"] = _httpx_stubSo when real httpx is installed the module is left untouched, and the stub only fills in when httpx is genuinely missing. Verified the leak is gone: after importing this test module, httpx resolves to the real package (Response present, real __file__), not the stub; and running this file together with a provider/HF test in one process passes. The loggers/structlog stubs stay as setdefault, matching the neighbors.
The regression module stubbed httpx via sys.modules.setdefault, which installs the lightweight stub even when real httpx is present but not yet imported. The stub then persists for the whole pytest process, so provider/HF tests collected later (importing httpx or huggingface_hub.errors) got a module missing HTTPError/Response. Mirror the neighboring llama_cpp helper tests: import real httpx first and only fall back to a stub on ImportError.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 138f80f9fc
ℹ️ 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".
| sys.modules.setdefault("loggers", _loggers_stub) | ||
| _structlog_stub = _types.ModuleType("structlog") | ||
| _structlog_stub.get_logger = lambda *a, **k: __import__("logging").getLogger("stub") | ||
| sys.modules.setdefault("structlog", _structlog_stub) |
There was a problem hiding this comment.
Avoid leaking logger stubs across test modules
When this module is collected before a test that imports loggers.handlers or uses the real structlog APIs, these setdefault calls can leave non-package/lightweight stubs in sys.modules for the rest of the pytest process; for example, a later from loggers.handlers import ... resolves against this stub and fails with 'loggers' is not a package. Mirror the httpx fix here by importing the real modules first and only installing fallback stubs on ImportError, or keep the stubs scoped via monkeypatch so mixed-file shards are not order-dependent.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 5ac65536d. Mirrored the httpx fix for both structlog and loggers: import the real module first and only install a lightweight stub on ImportError, so neither shadows the real package (or the loggers.handlers submodule) for tests collected later in the same process. Verified the regression file coexists with the httpx/arg suites in one process (310 passed) and that a later from loggers.handlers import ... resolves against the real package.
|
Indeed #6416 fixed the wrong thing. The crash is Why it crashes (gemma-4-12b's global layers are MQA:
It's the head axis being length 1, not strictly The restore works: gemma-3-27b loads tensor-split across both GPUs here where #6416 collapsed it to one card. Two things on the self-heal though:
|
… per model The self-heal recorded the --split-mode tensor abort only in the post-retry failure block, after the flash-attn-off retry. But SPLIT_MODE_TENSOR requires flash_attn, so the flash-off retry can't run tensor and its output no longer carries the warmup split-axis assert (ggml-backend-meta :541). The record therefore never fired on the real reproducer and the crash loop repeated on every load (reported by oobabooga on #6659). Latch instead on the first spawn that shows the signal crash + split-axis marker: record it, kill the process, and raise straight to the route's layer fallback, skipping the futile flash-attn/MTP retry ladder for this crash. The crash is a tensor-split geometry limit (e.g. MQA n_head_kv=1 splitting to GGML_BACKEND_SPLIT_AXIS_0), not a vision/mmproj property: it reproduces without --mmproj and even single-GPU tensor. So drop the vision/mmproj scoping, rename _vision_tensor_* -> _tensor_split_*, and key the session cache on (binary, mtime, model) rather than (binary, mtime) so one model's abort no longer skips tensor for every other model on the same build. Regression tests updated to pin the early-spawn record, the per-model cache, and that an unrelated ggml-backend-meta assert is not treated as the marker.
|
Thank you, this is a precise root cause and both self-heal fixes are in now (
Since the crash reproduces without |
|
@codex review |
The same-model guard on the preserve carry-forward compared only model_identifier, which is variant-agnostic for HF repos. A later load of the same repo with a different gguf_variant (which already bypassed dedupe on the variant mismatch) was treated as the same model, so a request that omits tensor settings inherited the prior variant's preserved intent and forced multi-GPU layer placement for a quant that never requested tensor. Also require the loaded hf_variant to match for HF repos (local direct-file loads already differ by model_identifier path). Added a regression test for the variant guard.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dccc50339f
ℹ️ 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 _same_model_loaded and config.gguf_hf_repo: | ||
| _same_model_loaded = (llama_backend.hf_variant or "").lower() == ( | ||
| config.gguf_variant or "" | ||
| ).lower() |
There was a problem hiding this comment.
Compare local GGUF path before carrying tensor intent
Fresh evidence beyond the prior HF-variant fix: this guard only checks variants for config.gguf_hf_repo, but local directory loads can also keep the same model_identifier while request.gguf_variant selects a different config.gguf_file. After variant A has a preserved tensor→layer fallback, loading variant B from the same local directory with tensor settings omitted leaves _same_model_loaded true and carries preserve_multi_gpu_on_layer=True, forcing B into a multi-GPU layer placement even though B never requested tensor; compare llama_backend.gguf_path to config.gguf_file for local GGUFs before carrying the intent.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Good catch, fixed in 9e3bf5571. My prior fix only checked the variant for config.gguf_hf_repo, but a local directory holding multiple GGUF variants keeps one variant-agnostic model_identifier (the directory) while config.gguf_file selects the file, so variant B could inherit variant A's preserved tensor->layer fallback and be forced onto multi-GPU.
The same-model guard now mirrors _already_in_target_state's identity logic instead of the HF-only shortcut: match by resolved path when both sides have a local file, else by HF variant.
if _same_model_loaded:
if config.gguf_file and llama_backend.gguf_path:
try:
_same_model_loaded = (
Path(llama_backend.gguf_path).resolve()
== Path(config.gguf_file).resolve()
)
except OSError:
_same_model_loaded = False
else:
_same_model_loaded = (llama_backend.hf_variant or "").lower() == (
config.gguf_variant or ""
).lower()For HF loads config.gguf_file is unset at this point (the download happens in load_model), so the else branch keeps the variant check; local directory/direct-file loads take the path branch. Updated the regression test to assert both the path and variant comparisons are present.
…sor intent A local directory holding multiple GGUF variants keeps one variant-agnostic model_identifier (the directory) while config.gguf_file selects the file, so the same-model guard let variant B inherit variant A's preserved tensor->layer fallback and forced B onto multi-GPU. Mirror _already_in_target_state's identity logic: match by resolved path when both sides have a local file, else by HF variant. #6659
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9e3bf55714
ℹ️ 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 self._layer_preserves_tensor_intent and not _effective_tensor_parallel( | ||
| extra_args, tensor_parallel | ||
| ): |
There was a problem hiding this comment.
Keep implicit tensor-off loads dedupable
When a preserved tensor→layer fallback is already loaded, this backend fast path treats any effective tensor-off request as a tensor drop. In the HF auto-pick or local-directory flows where the route-level already-loaded guard is not entered unless request.gguf_variant is set or the identifier is a direct .gguf, an identical /load with tensor settings omitted reaches _already_in_target_state() and returns False every time, forcing a full reload even though the user did not explicitly drop tensor intent. Pass the explicit-drop decision into this guard or account for preserve_multi_gpu_on_layer so implicit same-settings loads can still dedupe.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Good catch, fixed in 9b21fd432. The backend _already_in_target_state mirror was broader than the route's carry-forward: it forced a reload on any effective tensor-off request once a tensor->layer fallback was preserved. In the HF auto-pick / local-directory flows the route-level already-loaded guard isn't entered (it needs request.gguf_variant set or a direct .gguf identifier), so an identical /load with tensor settings omitted reached this guard and returned False every time, churning a full reload even though the user never dropped tensor intent.
The guard now takes the route's preserve_multi_gpu_on_layer decision (already computed and passed into load_model), which is True for an implicit same-settings reload that carries the intent forward and False for an explicit drop. So it only reloads on an explicit drop; implicit loads dedupe:
if (
self._layer_preserves_tensor_intent
and not _effective_tensor_parallel(extra_args, tensor_parallel)
and not preserve_multi_gpu_on_layer
):
return FalseExtended test_already_in_target_state_reloads_on_tensor_off_after_fallback to assert the implicit case (preserve_multi_gpu_on_layer=True) dedupes while the explicit drop still reloads.
…allback The backend _already_in_target_state mirror forced a reload on ANY effective tensor-off request once a tensor->layer fallback was preserved. In the HF auto-pick / local-directory flows the route-level dedup is skipped, so an identical /load with tensor omitted reached this guard and reloaded every time even without an explicit drop. Thread the route's preserve_multi_gpu_on_layer decision in so only an explicit drop reloads; implicit carry-forward dedupes. #6659
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9b21fd432e
ℹ️ 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".
| _same_model_loaded = ( | ||
| llama_backend.is_loaded | ||
| and (llama_backend.model_identifier or "").lower() | ||
| == (model_identifier or "").lower() | ||
| ) |
There was a problem hiding this comment.
Compare preserved fallback against the normalized model id
When the user loads an HF GGUF by shorthand (no slash), ModelConfig.from_identifier prefixes it to unsloth/..., and that normalized config.identifier is what load_model stores on llama_backend.model_identifier. This guard compares the loaded backend to the raw model_identifier returned from the request, so a later context-only reload of the same shorthand model after a tensor→layer fallback is treated as a different model; _carry_preserved_tensor_intent then does not set the preserve hint and the layer reload can collapse back to a single GPU. Compare against config.identifier (or normalize before this check) so same-model reloads preserve the fallback intent.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8fa3837cba
ℹ️ 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".
| _explicit_tensor_drop = ( | ||
| "tensor_parallel" in _fields_set or request.llama_extra_args is not None | ||
| ) and not _effective_tensor_parallel(request.llama_extra_args, request.tensor_parallel) |
There was a problem hiding this comment.
Do not treat unrelated extras as tensor drop
When a preserved tensor→layer fallback is loaded, a later same-model reload that only changes unrelated pass-through args (for example adding --top-k 20) but omits the tensor field hits this predicate because request.llama_extra_args is not None. That disables _carry_preserved_tensor_intent, so the subsequent preserve_multi_gpu_on_layer hint is false and a fitting model can collapse back to a single GPU even though the user did not explicitly turn tensor off or set a non-tensor --split-mode; only an explicit tensor field change or split-mode override should count as the drop.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Good catch, fixed in e658a9e5c. The explicit-drop predicate used request.llama_extra_args is not None, so any pass-through extra (e.g. --top-k 20) on a same-model reload that omitted the tensor field counted as a drop, disabled _carry_preserved_tensor_intent, and collapsed a fitting model back to one GPU even though the user never turned tensor off or set a non-tensor --split-mode.
A drop now requires an explicit tensor_parallel field change or a real --split-mode/-sm override (detected via parse_split_mode_override), not just the presence of extras. I pulled the decision into a shared helper so the already-loaded dedup (_request_matches_loaded_settings) and the load carry-forward use identical logic:
def _is_explicit_tensor_drop(request: LoadRequest) -> bool:
fields_set = getattr(request, "model_fields_set", set())
explicit = "tensor_parallel" in fields_set or (
parse_split_mode_override(request.llama_extra_args) is not None
)
return explicit and not _effective_tensor_parallel(
request.llama_extra_args, request.tensor_parallel
)So an unrelated extra still reloads if it genuinely differs from the stored extras (to apply it), but that reload now carries the preserved multi-GPU layer placement instead of collapsing. An explicit tensor_parallel=False or --split-mode layer still drops as before. Added a truth-table test for the helper (including the --top-k case) plus a check that both readers route through it.
The explicit-drop test treated request.llama_extra_args is not None as a drop, so a same-model reload that merely added an unrelated pass-through arg (e.g. --top-k 20) without touching the tensor field or --split-mode disabled the carry-forward and collapsed a fitting model back to one GPU. A drop now requires an explicit tensor_parallel field change or a non-tensor --split-mode override, via a shared _is_explicit_tensor_drop helper used by both the already-loaded dedup and the load carry-forward so the two readers agree. #6659
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e658a9e5c7
ℹ️ 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".
| explicit = "tensor_parallel" in fields_set or ( | ||
| parse_split_mode_override(request.llama_extra_args) is not None | ||
| ) |
There was a problem hiding this comment.
Treat cleared tensor extras as an explicit drop
When tensor intent came only from llama_extra_args (for example --split-mode tensor) and that load falls back to a preserved layer split, a later request that explicitly sends llama_extra_args=[] but omits tensor_parallel is trying to clear the extra-driven tensor request. This predicate returns false because the cleared list has no split-mode override, so _carry_preserved_tensor_intent keeps preserve_multi_gpu_on_layer=True and the reload stays pinned across multiple GPUs instead of returning to normal layer selection; count an explicit clear of previously tensor/split-mode-driven extras as a drop, while still allowing unrelated extras like --top-k to carry the intent.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Good catch, fixed in 5250f91c7. When tensor intent was extras-driven (--split-mode tensor) and fell back to a preserved layer split, an explicit llama_extra_args=[] (omitting tensor_parallel) had no split-mode override, so _is_explicit_tensor_drop returned false and the carry-forward kept preserve_multi_gpu_on_layer=True, pinning the model multi-GPU instead of returning to normal layer selection.
The helper now also counts an explicit empty-list clear as a drop, while an unrelated extra (--top-k) or inherit (None) still carries:
explicit = (
"tensor_parallel" in fields_set
or parse_split_mode_override(extras) is not None
or ("llama_extra_args" in fields_set and extras is not None and not extras)
)
return explicit and not _effective_tensor_parallel(extras, request.tensor_parallel)The extras is not None part keeps the inherit convention (llama_extra_args=None means inherit, not clear), so only an explicit [] drops. Both readers (the already-loaded dedup and the load carry-forward) go through the shared helper, so they stay in agreement. Extended the truth-table test with the [] case.
When tensor intent was extras-driven (--split-mode tensor) and fell back to a preserved layer split, a later request that explicitly clears extras (llama_extra_args=[]) but omits tensor_parallel left the empty list with no split-mode override, so the carry-forward kept the model pinned multi-GPU instead of returning to normal layer selection. _is_explicit_tensor_drop now also counts an explicit empty-list clear as a drop, while an unrelated extra (--top-k) or inherit (None) still carries the preserved intent. #6659
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 09a651c06c
ℹ️ 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".
| explicit = ( | ||
| "tensor_parallel" in fields_set | ||
| or parse_split_mode_override(extras) is not None | ||
| or ("llama_extra_args" in fields_set and extras is not None and not extras) |
There was a problem hiding this comment.
Gate empty extras drops on prior tensor extras
When the preserved tensor→layer fallback came from the Tensor Parallelism toggle rather than llama_extra_args, a later settings/API request that only clears extras (llama_extra_args=[] while omitting tensor_parallel) still hits this branch because every empty extras list is treated as an explicit tensor drop. That disables _carry_preserved_tensor_intent for the reload and passes preserve_multi_gpu_on_layer=False, so a fitting model can collapse from the preserved multi-GPU layer placement even though the request did not clear the tensor toggle; make the empty-list case depend on the stored/inherited extras actually containing a tensor split mode, or on an explicit tensor field change.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 5b4a8f718, together with the sibling echo finding. You're right that an unconditional empty-list drop was wrong. I went a step further than gating on the stored extras: a tensor->layer fallback always stores --split-mode layer (the retry forces it via strip_split_mode_only(...) + ["--split-mode","layer"]), never a tensor split mode, so the stored/inherited extras can never contain a tensor split to wipe -- an empty clear can never legitimately drop tensor intent. So _is_explicit_tensor_drop no longer treats an empty clear (or the bare tensor_parallel field) as a drop at all; it drops only on an explicit non-tensor --split-mode override. That keeps the preserved multi-GPU placement for a toggle-driven fallback while still honoring a deliberate --split-mode change. Truth-table test updated to assert llama_extra_args=[] is not a drop.
| "tensor_parallel" in fields_set | ||
| or parse_split_mode_override(extras) is not None | ||
| or ("llama_extra_args" in fields_set and extras is not None and not extras) | ||
| ) | ||
| return explicit and not _effective_tensor_parallel(extras, request.tensor_parallel) |
There was a problem hiding this comment.
Preserve fallback when Studio resends tensor=false
Fresh evidence from the current Studio callers is that the load payload is not sparse: use-chat-model-runtime.ts and shared-composer.tsx always include tensor_parallel, and after a fallback the response is copied back into tensorParallel as false. In that normal context/settings reload path, model_fields_set contains tensor_parallel even though the user did not deliberately turn off the original tensor request, so this predicate disables _carry_preserved_tensor_intent and the reload can collapse the preserved multi-GPU layer placement to one GPU; distinguish a UI-reflected false from an actual toggle change before treating it as a drop.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Good catch, and thanks for digging into the actual callers -- confirmed in 5b4a8f718. The Studio frontend always sends tensor_parallel and copies the /load response's resolved value back into tensorParallel (use-chat-model-runtime.ts, shared-composer.tsx, chat-adapter.ts), and the response returns llama_backend.tensor_parallel (the post-fallback false) on purpose so the toggle reflects the fallback. So after a fallback model_fields_set carries tensor_parallel=false on every ctx/settings reload even though the user never changed it, and keying the drop on the field collapsed the preserved multi-GPU placement.
Since the backend can't distinguish that echo from a deliberate toggle-off (both arrive as false), I dropped the field as a drop signal entirely. _is_explicit_tensor_drop now drops only on an explicit non-tensor --split-mode override (the one unambiguous "place it differently" directive the UI doesn't auto-send):
def _is_explicit_tensor_drop(request: LoadRequest) -> bool:
override = parse_split_mode_override(request.llama_extra_args)
return override is not None and override.strip().lower() != "tensor"So a bare tensor_parallel=false echo dedupes and keeps multi-GPU; tensor_parallel=true / --split-mode tensor re-engage tensor; an explicit --split-mode tensor wins over a contradictory tensor_parallel=false (the more specific placement directive). Updated the regression tests (test_tensor_off_echo_preserves_multi_gpu_fallback, truth-table) to lock in the echo-preserves behavior.
The Studio frontend always sends tensor_parallel and copies the /load response's resolved value back into its state, so after a tensor->layer fallback every ctx/settings reload carries tensor_parallel=false even though the user never changed it. Keying the drop on the field (or on an empty extras clear) collapsed the preserved multi-GPU placement on the next reload. A fallback also always stores --split-mode layer, never a tensor split mode, so a clear never wipes tensor intent. _is_explicit_tensor_drop now drops only on an explicit non-tensor --split-mode override; the bare field echo, an empty clear, an unrelated extra, and inherit all keep the preserved placement, and --split-mode tensor / tensor_parallel=true re-engage tensor. #6659
|
@codex review |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces self-healing tensor-parallelism fallback logic and multi-GPU preservation for llama.cpp model loading. Instead of blanket-disabling tensor parallelism for vision models, the backend now dynamically records split-axis geometry aborts per binary and model, falling back to layer-split mode while preserving the multi-GPU intent (preventing silent single-GPU collapse). It also updates the inference routes to carry forward this preserved intent across same-model reloads (such as context-only changes) unless an explicit tensor drop is requested. Finally, a comprehensive suite of regression tests has been added to verify these behaviors. No review comments were provided, so I have no additional feedback to offer.
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.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5b4a8f7185
ℹ️ 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".
| _same_model_loaded = ( | ||
| llama_backend.is_loaded | ||
| and (llama_backend.model_identifier or "").lower() | ||
| == (model_identifier or "").lower() |
There was a problem hiding this comment.
Preserve fallback intent after model ID normalization
When callers use a shorthand GGUF id such as Qwen..., ModelConfig.from_identifier() normalizes it before _common_load_kwargs loads/stores config.identifier, but this check compares the loaded backend against the pre-normalized model_identifier. On a settings/context reload of the same model after a tensor→layer fallback, _same_model_loaded becomes false, so _carry_preserved_tensor_intent is not applied and a model that should remain spread across GPUs can collapse back to a single-GPU layer load. Compare against the resolved config.identifier (or the same value passed to load_model) here.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Good catch, fixed in 28b620409. ModelConfig.from_identifier normalizes the id (adds the unsloth/ prefix for a shorthand, resolves repo-id case) before _common_load_kwargs stores config.identifier into the backend, but the same-model guard compared the raw pre-normalized model_identifier. So a ctx/settings reload using the shorthand made _same_model_loaded false, dropped _carry_preserved_tensor_intent, and could collapse the preserved multi-GPU layer placement to one GPU.
The guard now compares the resolved config.identifier (the exact value passed to load_model and stored as llama_backend.model_identifier), keeping it symmetric with _already_in_target_state:
_same_model_loaded = (
llama_backend.is_loaded
and (llama_backend.model_identifier or "").lower()
== (config.identifier or "").lower()
)Note the early dedup precheck higher up still compares the raw id because it runs before config is resolved, but a mismatch there only skips the dedup short-circuit and falls through to a full reload -- and that reload now preserves the placement via this fixed guard, so there's no collapse (just, at worst, one redundant reload for a shorthand id). Updated the same-model guard regression test to assert it keys on config.identifier.
The same-model guard for the carry-forward compared the raw request id, but ModelConfig.from_identifier normalizes it (adds the unsloth/ prefix for a shorthand, fixes repo-id case) before load_model stores config.identifier. So a ctx/settings reload using the shorthand id missed the match, dropped _carry_preserved_tensor_intent, and could collapse a preserved multi-GPU layer placement to one GPU. Compare against config.identifier (what the backend stores), keeping it symmetric with _already_in_target_state. #6659
* Studio: GPU memory dropdown — llama.cpp --fit on and manual gpu-layers/cpu-moe * Studio: simplify GPU memory changes (reuse ParamSlider, GPU_LAYERS_ALL, loadedGpuMemoryFields helper) * Studio: GPU picker — choose which GPUs a GGUF model loads on (gpu_ids) * Studio: simplify GPU picker (share /api/system fetch, validate gpu_ids) * Studio: GPU picker review fixes (gate relative indices, no cross-model leak, validate, types) * Studio: group GPU controls under a collapsible GPU section * Studio: GPU feature review fixes (fix fit-ctx test, behavior-test the floor, comment accuracy) * Studio: make GPU a top-level settings section (not nested under Model) * Studio: flatten GPU controls into the Model section, group by GPU/context/generation * Studio: move GPU Memory to the bottom of Model with its dependent controls beneath it * Studio: move GPU Memory below Tensor Parallelism and GPUs below GPU Memory * Studio: tighten GPU Memory and GPU Layers tooltip copy * Studio: fix fit-mode context slider track-click, restore GPU Memory tooltip, shorten fit dropdown label * Studio: GPU Memory tooltip one mode per line, briefer * Studio: note HIP_VISIBLE_DEVICES (ROCm) in the GPUs picker tooltip * Studio: narrow the GPU Memory dropdown to fit the shortened label * Studio: use 'llama.cpp --fit' in the GPU Memory tooltip for consistency * Studio: allow Tensor Parallelism in Manual GPU mode * Studio: graduated MoE-on-CPU offload (--n-cpu-moe) replacing the all-or-nothing toggle * Studio: size the MoE-offload slider for staged (deferred-load) models * Studio: share one GGUF header walk for the context-length and MoE-count readers * Studio: size the GPU Layers slider for staged models (one staged-header read) * Studio: move Tensor Parallelism below the GPUs picker * Studio: GPU split (--tensor-split) per-GPU model share in Manual mode * Studio: tolerate whitespace in GPU split input, move it below GPU Layers * Studio: rename the GPU split control to "Split ratio" * Studio: Split ratio sends explicit even input; fix blank=free-VRAM (not even) copy * Studio: tighten llama.cpp --fit VRAM margin with --fit-target 512 * Studio: GPU memory review fixes (rollback re-baseline, single-GPU TP gate, accurate copy) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Studio: move Split ratio below MoE Layers on CPU * Studio: address PR review (fix GPU-info hydration race, share fit context-length across load paths) * Studio: address codex review (manual single-GPU TP guard, GPU-aware spec defaults in fit/manual, GGUF-only context/preference) * Studio: address codex review round 2 (gpu_present seed, single-GPU tensor-split guard, staged manual-knob reset, strip inherited offload flags) * Studio: address codex review round 3 (strip inherited --n-cpu-moe, CPU-fallback warning in Manual mode) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Studio: address codex review round 4 (preserve pinned fit context across a later Apply) * Studio: address codex review round 5 (honor GPU picker for diffusion GGUFs, clear fit pin on cross-model switch) * Studio: preserve the pending GPU Memory mode when staging a model * Studio: pin diffusion GPU device order and reset GPU-memory state for diffusion loads * Studio: address codex review round 6 (fit-Auto rollback context, preserve manual non-tensor split modes, persist GPU mode on load not select) * Studio: persist the applied GPU Memory mode, not the requested one (skip diffusion loads) * Studio: replace Manual-mode split-ratio field with per-GPU layer sliders * Studio: clarify per-GPU layer split hint for tensor-parallel mode * Studio: address codex review round 7 (allow GGUF gpu_ids past the legacy guard, replay GPU-memory fields on respawn) * Studio: address codex review round 8 (size the validate preflight like the load in fit mode, across both load paths) * Studio: skip the training-OOM guard for llama.cpp --fit GGUF loads (they spill to RAM) * Studio: drop the now-redundant compare-path validate sizing (the --fit guard skip makes it moot) * Studio: address codex review round 9 (keep the training guard for fit loads, forward gpu_ids to validate, strip inherited manual tensor-split) * Studio: address codex review round 10 (gate GPU-memory adoption on is_gguf, record manual knobs only in Manual mode) * Studio: handle diffusion GGUFs symmetrically in the GPU Memory controls (preserve the standing mode preference, hide the inapplicable mode/TP controls) * Studio: remember the GPU Memory settings per model * Studio: consolidate --fit mode and Manual mode into a single Manual mode * Studio: preserve the per-GPU layer split across GPU Layers changes * Studio: trim overly long GPU Memory comments * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * address GPU memory config review comments * trim redundant GPU memory tests * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Reconcile manual-mode TP drops with the #6659 drop-site invariants * Preserve quantized KV in manual --fit, charge GGUF companions in full, reconcile GPU pick on load * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Clear stale GPU baseline on non-GGUF loads so it can't read as dirty * Fix no-context-shift test for the conditional -c flag * Credit manual GPU-layer offload for cached HF GGUFs * Reset per-model load knobs on GGUF quant switch * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Strip inherited tensor-split when manual ratio is cleared * Match auto-load validation to safetensors placement * Reset editable manual knobs after Auto GGUF loads * Record a single device for diffusion GPU picks * Reset per-model GPU knobs before applying saved settings * Address review comments * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Guard manual tensor splits and keep remembered context on auto-load * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Snapshot compare knobs, seed splits from free VRAM, flag zero-offload loads * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Exempt CPU-only loads from the guard floor and harden compare and reseed paths * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Reach full offload from the layers slider and charge extras drafters in the guard * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Warm the GPU device cache before pick reconciles and disable staged GPU controls * Align the training guard with inherited extras, spec mode, and compare targets * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Hide GPUs from companion-less zero-offload loads * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Size diffusion picks per device, own manual offload flags, reject XPU picks * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Drop tensor flags at zero layers and exempt CPU-pinned drafters * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Allowlist the zero-layer tensor parallel drop site * Keep validate and load guards on the same extras and refresh stale baselines * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Drop mismatched manual tensor splits before launch * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Gate XPU picks on the real backend field and harden split and hydration paths * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Weight full GPUs as zero, clamp split shares, and refine the zero-layer mask gate * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Carry fit context across mode changes and align drafter and picker gates * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Catch variant switches, uncached diffusion repos, and text-only mmproj skips * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Check companions on the first device and size native and remote zero-layer loads * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Replace the training guard's precise VRAM modeling with a conservative bound * Baseline context pins on non-GGUF hydration and reprobe list-seeded staged GGUFs * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Size manual splits by their largest share and preserve resolved context from Default * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Default-deny unsized required companions and price KV at the effective cache dtype * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Reserve MTP draft KV and MLA target-copy in the training guard * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Size tensor-parallel loads per device and show GPU controls for native GGUFs * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Reserve MTP overhead for uncached remote GGUFs and the mmproj runtime factor * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Drop the training-coexistence VRAM estimation this PR added * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Gate remembered load settings to GGUF picks * Lock the remaining load-time controls during a staged load * Clear the stale native-path token on compare loads * Drop a stale guard reference from the zero-offload masking comment * Seed GPU baselines from the rollback response and drop never-emitted offload flags * Match validate's training guard to load and keep the native reload token * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Trim verbose GPU-memory comments * Thread the variants header walk off the event loop, honor device pins on zero-offload, and hold staged GPU edits * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Honor manual placement and classify pinned zero-offload loads * Close diffusion admission and status hydration gaps * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Check the actual diffusion GPU during training * Align staged baselines and manual reload dedupe * Fix GGUF placement and rollback state * Harden manual GGUF placement boundaries * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Remove unused resolve_tensor_parallel import in llama_cpp.py The name is used only in llama_server_args.py, routes/inference.py, and tests, not in llama_cpp.py; the unused hoisted import trips the import-hoist verifier in the source-lint CI job. * Fix diffusion GPU dedup and training guard for non-numeric device tokens The diffusion runner drives only its single lowest device and the backend records that one device (self._gpu_ids = [sorted(gpu_ids)[0]]), but the reload dedupe compared it against the full requested list, so a multi-GPU pick that resolves to the same device forced a needless reload. Normalize the request the same way for a loaded diffusion model in both _already_in_target_state and the route _request_matches_loaded_settings. The chat-during-training coexistence guard called int() on the single-device token and hard-rejected when it could not parse. A non-numeric token (a CUDA UUID / MIG handle) now sizes against the whole visible pool like the GGUF guard instead of falsely blocking the load, and an empty token (a CPU-only runner such as a CPU diffusion GGUF) is allowed outright since it uses no GPU VRAM. * Tighten comments added by the GPU memory config changes * Harden GGUF placement from independent review: VRAM sizing, diffusion TP reset, tensor_split validation - Training coexistence guard: a single-device runner pinned through an unresolvable UUID/MIG token was sized against the aggregate visible-VRAM pool, so a load could pass on capacity it cannot use and then OOM active training. Size against the worst-case visible device (min free) instead, keeping the guard's documented default-deny contract. The empty-token (CPU-only runner) allow path is unchanged. - Diffusion startup: _start_diffusion_server now resets self._tensor_parallel to False alongside the other placement resets. A prior tensor-parallel chat load (process killed but not fully unload-reset) otherwise left /status misreporting tensor parallelism and made an identical diffusion re-Apply reload against the stale state. - tensor_split: reject negative / non-finite / all-zero splits up front. They were dropped at launch but still compared raw in the reload dedupe, so an identical Apply reloaded indefinitely. - Tests: the shared httpx stub was incomplete and, installed via setdefault before real httpx loaded, broke a combined pytest run (collection errors on httpx.Response). Import the real installed httpx instead. * [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> Co-authored-by: danielhanchen <[email protected]> Co-authored-by: danielhanchen <[email protected]>
* Studio: GPU memory dropdown — llama.cpp --fit on and manual gpu-layers/cpu-moe * Studio: simplify GPU memory changes (reuse ParamSlider, GPU_LAYERS_ALL, loadedGpuMemoryFields helper) * Studio: GPU picker — choose which GPUs a GGUF model loads on (gpu_ids) * Studio: simplify GPU picker (share /api/system fetch, validate gpu_ids) * Studio: GPU picker review fixes (gate relative indices, no cross-model leak, validate, types) * Studio: group GPU controls under a collapsible GPU section * Studio: GPU feature review fixes (fix fit-ctx test, behavior-test the floor, comment accuracy) * Studio: make GPU a top-level settings section (not nested under Model) * Studio: flatten GPU controls into the Model section, group by GPU/context/generation * Studio: move GPU Memory to the bottom of Model with its dependent controls beneath it * Studio: move GPU Memory below Tensor Parallelism and GPUs below GPU Memory * Studio: tighten GPU Memory and GPU Layers tooltip copy * Studio: fix fit-mode context slider track-click, restore GPU Memory tooltip, shorten fit dropdown label * Studio: GPU Memory tooltip one mode per line, briefer * Studio: note HIP_VISIBLE_DEVICES (ROCm) in the GPUs picker tooltip * Studio: narrow the GPU Memory dropdown to fit the shortened label * Studio: use 'llama.cpp --fit' in the GPU Memory tooltip for consistency * Studio: allow Tensor Parallelism in Manual GPU mode * Studio: graduated MoE-on-CPU offload (--n-cpu-moe) replacing the all-or-nothing toggle * Studio: size the MoE-offload slider for staged (deferred-load) models * Studio: share one GGUF header walk for the context-length and MoE-count readers * Studio: size the GPU Layers slider for staged models (one staged-header read) * Studio: move Tensor Parallelism below the GPUs picker * Studio: GPU split (--tensor-split) per-GPU model share in Manual mode * Studio: tolerate whitespace in GPU split input, move it below GPU Layers * Studio: rename the GPU split control to "Split ratio" * Studio: Split ratio sends explicit even input; fix blank=free-VRAM (not even) copy * Studio: tighten llama.cpp --fit VRAM margin with --fit-target 512 * Studio: GPU memory review fixes (rollback re-baseline, single-GPU TP gate, accurate copy) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Studio: move Split ratio below MoE Layers on CPU * Studio: address PR review (fix GPU-info hydration race, share fit context-length across load paths) * Studio: address codex review (manual single-GPU TP guard, GPU-aware spec defaults in fit/manual, GGUF-only context/preference) * Studio: address codex review round 2 (gpu_present seed, single-GPU tensor-split guard, staged manual-knob reset, strip inherited offload flags) * Studio: address codex review round 3 (strip inherited --n-cpu-moe, CPU-fallback warning in Manual mode) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Studio: address codex review round 4 (preserve pinned fit context across a later Apply) * Studio: address codex review round 5 (honor GPU picker for diffusion GGUFs, clear fit pin on cross-model switch) * Studio: preserve the pending GPU Memory mode when staging a model * Studio: pin diffusion GPU device order and reset GPU-memory state for diffusion loads * Studio: address codex review round 6 (fit-Auto rollback context, preserve manual non-tensor split modes, persist GPU mode on load not select) * Studio: persist the applied GPU Memory mode, not the requested one (skip diffusion loads) * Studio: replace Manual-mode split-ratio field with per-GPU layer sliders * Studio: clarify per-GPU layer split hint for tensor-parallel mode * Studio: address codex review round 7 (allow GGUF gpu_ids past the legacy guard, replay GPU-memory fields on respawn) * Studio: address codex review round 8 (size the validate preflight like the load in fit mode, across both load paths) * Studio: skip the training-OOM guard for llama.cpp --fit GGUF loads (they spill to RAM) * Studio: drop the now-redundant compare-path validate sizing (the --fit guard skip makes it moot) * Studio: address codex review round 9 (keep the training guard for fit loads, forward gpu_ids to validate, strip inherited manual tensor-split) * Studio: address codex review round 10 (gate GPU-memory adoption on is_gguf, record manual knobs only in Manual mode) * Studio: handle diffusion GGUFs symmetrically in the GPU Memory controls (preserve the standing mode preference, hide the inapplicable mode/TP controls) * Studio: remember the GPU Memory settings per model * Studio: consolidate --fit mode and Manual mode into a single Manual mode * Studio: preserve the per-GPU layer split across GPU Layers changes * Studio: trim overly long GPU Memory comments * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * address GPU memory config review comments * trim redundant GPU memory tests * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Reconcile manual-mode TP drops with the unslothai#6659 drop-site invariants * Preserve quantized KV in manual --fit, charge GGUF companions in full, reconcile GPU pick on load * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Clear stale GPU baseline on non-GGUF loads so it can't read as dirty * Fix no-context-shift test for the conditional -c flag * Credit manual GPU-layer offload for cached HF GGUFs * Reset per-model load knobs on GGUF quant switch * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Strip inherited tensor-split when manual ratio is cleared * Match auto-load validation to safetensors placement * Reset editable manual knobs after Auto GGUF loads * Record a single device for diffusion GPU picks * Reset per-model GPU knobs before applying saved settings * Address review comments * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Guard manual tensor splits and keep remembered context on auto-load * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Snapshot compare knobs, seed splits from free VRAM, flag zero-offload loads * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Exempt CPU-only loads from the guard floor and harden compare and reseed paths * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Reach full offload from the layers slider and charge extras drafters in the guard * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Warm the GPU device cache before pick reconciles and disable staged GPU controls * Align the training guard with inherited extras, spec mode, and compare targets * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Hide GPUs from companion-less zero-offload loads * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Size diffusion picks per device, own manual offload flags, reject XPU picks * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Drop tensor flags at zero layers and exempt CPU-pinned drafters * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Allowlist the zero-layer tensor parallel drop site * Keep validate and load guards on the same extras and refresh stale baselines * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Drop mismatched manual tensor splits before launch * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Gate XPU picks on the real backend field and harden split and hydration paths * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Weight full GPUs as zero, clamp split shares, and refine the zero-layer mask gate * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Carry fit context across mode changes and align drafter and picker gates * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Catch variant switches, uncached diffusion repos, and text-only mmproj skips * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Check companions on the first device and size native and remote zero-layer loads * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Replace the training guard's precise VRAM modeling with a conservative bound * Baseline context pins on non-GGUF hydration and reprobe list-seeded staged GGUFs * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Size manual splits by their largest share and preserve resolved context from Default * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Default-deny unsized required companions and price KV at the effective cache dtype * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Reserve MTP draft KV and MLA target-copy in the training guard * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Size tensor-parallel loads per device and show GPU controls for native GGUFs * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Reserve MTP overhead for uncached remote GGUFs and the mmproj runtime factor * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Drop the training-coexistence VRAM estimation this PR added * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Gate remembered load settings to GGUF picks * Lock the remaining load-time controls during a staged load * Clear the stale native-path token on compare loads * Drop a stale guard reference from the zero-offload masking comment * Seed GPU baselines from the rollback response and drop never-emitted offload flags * Match validate's training guard to load and keep the native reload token * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Trim verbose GPU-memory comments * Thread the variants header walk off the event loop, honor device pins on zero-offload, and hold staged GPU edits * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Honor manual placement and classify pinned zero-offload loads * Close diffusion admission and status hydration gaps * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Check the actual diffusion GPU during training * Align staged baselines and manual reload dedupe * Fix GGUF placement and rollback state * Harden manual GGUF placement boundaries * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Remove unused resolve_tensor_parallel import in llama_cpp.py The name is used only in llama_server_args.py, routes/inference.py, and tests, not in llama_cpp.py; the unused hoisted import trips the import-hoist verifier in the source-lint CI job. * Fix diffusion GPU dedup and training guard for non-numeric device tokens The diffusion runner drives only its single lowest device and the backend records that one device (self._gpu_ids = [sorted(gpu_ids)[0]]), but the reload dedupe compared it against the full requested list, so a multi-GPU pick that resolves to the same device forced a needless reload. Normalize the request the same way for a loaded diffusion model in both _already_in_target_state and the route _request_matches_loaded_settings. The chat-during-training coexistence guard called int() on the single-device token and hard-rejected when it could not parse. A non-numeric token (a CUDA UUID / MIG handle) now sizes against the whole visible pool like the GGUF guard instead of falsely blocking the load, and an empty token (a CPU-only runner such as a CPU diffusion GGUF) is allowed outright since it uses no GPU VRAM. * Tighten comments added by the GPU memory config changes * Harden GGUF placement from independent review: VRAM sizing, diffusion TP reset, tensor_split validation - Training coexistence guard: a single-device runner pinned through an unresolvable UUID/MIG token was sized against the aggregate visible-VRAM pool, so a load could pass on capacity it cannot use and then OOM active training. Size against the worst-case visible device (min free) instead, keeping the guard's documented default-deny contract. The empty-token (CPU-only runner) allow path is unchanged. - Diffusion startup: _start_diffusion_server now resets self._tensor_parallel to False alongside the other placement resets. A prior tensor-parallel chat load (process killed but not fully unload-reset) otherwise left /status misreporting tensor parallelism and made an identical diffusion re-Apply reload against the stale state. - tensor_split: reject negative / non-finite / all-zero splits up front. They were dropped at launch but still compared raw in the reload dedupe, so an identical Apply reloaded indefinitely. - Tests: the shared httpx stub was incomplete and, installed via setdefault before real httpx loaded, broke a combined pytest run (collection errors on httpx.Response). Import the real installed httpx instead. * [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> Co-authored-by: danielhanchen <[email protected]> Co-authored-by: danielhanchen <[email protected]>
…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.
…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.
Four structural tests on main describe the shape of `load_model`, and this branch changes that shape in three places. None of the properties they guard is affected; each test is updated to point at where the thing it checks now lives, and each new call site is named rather than having a count quietly raised. `test_every_pooled_caller_says_so` counted five callers passing an absolute pool budget. There are six: the arch-crash retry re-fits against the narrowed pool the respawn actually reaches, using its own `_pool_budget_mib`, so it is pooled and marks itself. `TestSplitRateRecheckAfterSelection::test_wired_into_every_call_site` counted four `split_extra_bytes` sites and says in its own comment that a fifth has to come and declare its context. It does: the per-candidate re-selection that re-runs `_select_gpus_split_aware` against a total reduced by the host-pinned discount, over proved-discrete GPUs only. It prices at `effective_ctx`, the same context as the sibling selection it mirrors, and matches the suite's `_cc_split_extra(<name>)` rule. Both `test_tp_vision_regression` cases assert the auto-context enumeration starts at `_auto_min_gpus` by matching `range(_auto_min_gpus, len(ranked) + 1)`. That loop moved into `_ranked_candidate_subsets(ranked, _auto_min_gpus)`, so the floor is now the argument rather than the bound. They assert the call and the helper's `range(min_count, ...)` instead. The check that actually guards #6659, that the raw `_layer_min_gpus` is not used uncapped, is untouched. 329 tests pass across the three files.
Summary
#6416("skip tensor-parallel for vision models") disabled--split-mode tensorfor any GGUF that ships an mmproj projector, to avoid aGGML_ASSERTcrash (#6415) seen on an older llama.cpp build with consumer Blackwell (RTX 5050/5070 Ti, sm_120). The side effect: a user'stensor_parallel=trueis silently dropped for every multimodal/MTP GGUF, and on hardware where the model fits on one GPU the load then collapses to a single GPU.Repro on
unsloth/Qwen3.6-35B-A3B-MTP-GGUFUD-Q8_K_XL, 4x B200,tensor_parallel=true:The mmproj +
--split-mode tensorcombination works on current builds (verified end to end on B200/sm_100, including image input), so the blanket skip is now disabling a working configuration.Change
Make the vision skip self-healing per binary instead of unconditional:
--split-mode tensor+--mmprojthis session (_vision_tensor_split_aborts). A binary is recorded (_record_vision_tensor_split_abort) when such a launch crashes at startup, so a genuinely incompatible build pays the crash once and then takes the fast layer-split path (the#6415behavior, scoped to where it is actually needed). The cache is process scoped, sounsloth studio updatere-probes the new build.load_with_tensor_fallback(tensor to layer retry on crash) is unchanged and remains the safety net._select_gpus(min_gpus=...)so a downgraded tensor request can keep multiple GPUs rather than collapsing to one (defaultmin_gpus=1, no behavior change).Tests
New
studio/backend/tests/test_tp_vision_regression.py(no GPU, deterministic):tensor_parallel = Falsesite inload_model. A new silent drop reason fails the test, which is exactly what would have flagged#6416at review time (its parent had 2 drop sites;#6416added the third)._select_gpus(min_gpus=...)behavior.Per-file runs (this suite stubs
sys.modules, so files run in isolation):test_tensor_parallel77,test_tp_vision_regression11,test_gpu_selection54,test_mtp_vram_budget128,test_compute_buffer19,test_llama_server_args226,test_llama_cpp_context_fit61, all passing.Notes
Follow-up (not in this PR): thread
min_gpusinto the layer-split downgrade path so a build that genuinely aborts also spreads across GPUs instead of one. Capable builds get a real tensor split, so this only affects the bad-build fallback; themin_gpushook and its unit test are already in place.