Skip to content

Studio: emit no legacy load flag when the llama-server --help probe is inconclusive - #15828

Merged
danielhanchen merged 2 commits into
mainfrom
studio-load-mode-caps-false-negative
Oct 28, 2026
Merged

danielhanchen merged 2 commits into
mainfrom
studio-load-mode-caps-false-negative

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Summary

When the llama-server --help capability probe fails (a timeout on a busy machine, a nonzero exit, or empty output), supports_load_mode comes back False. apply_load_mode_policy read that as "this build predates --load-mode" and fell back to the legacy spellings (--no-mmap, --mlock). Current upstream llama.cpp removed those flags, so the server exits with error: invalid argument: --no-mmap and /api/inference/load returns 500.

Seen in a Studio run against upstream llama-server: one load logged Load mode: --no-mmap and failed. The same model on the same binary logged Load mode: --load-mode none on every other run and loaded fine. The failing launch was also missing --kv-unified, --metrics, --fit-ctx and the video flags, and dropped to --parallel 1. That is what an empty capability catalogue looks like. The smaller fit estimate in that run (0.5 GB vs 1.2 GB) comes from the same cause: one slot instead of four.

Changes

  • llama_server_args.load_mode_support(caps) returns True when --load-mode is listed, False only when a successful probe returned a non-empty catalogue without it, and None otherwise.
  • apply_load_mode_policy takes supports_load_mode=None to mean unknown and emits no load flag, so llama-server uses its default. A build that positively lacks --load-mode still gets the legacy spellings.
  • The three launch call sites in llama_cpp.py that reach apply_load_mode_policy now pass load_mode_support(server_caps). apply_model_memory_policy treats None the same as False, so nothing else changes.

The Model Memory "keep resident" path (--mlock) still falls back to the legacy flag when support is unknown. I left it alone here because it also drives the memory state bookkeeping.

Tests

New studio/backend/tests/test_load_mode_caps_unknown.py: policy with unknown support, plus end to end with fake binaries that fail --help, print nothing, list only the old flags, or list --load-mode. It fails 8 of 9 cases on main and passes on this branch. Across test_server_tuning_flags.py, test_load_mode_fit_matrix.py, test_model_memory_settings.py, test_launch_flags_are_capability_gated.py, test_llama_cpp_placement.py and test_ctx_checkpoint_host_budget.py, the failing IDs match on main and on this branch. Five test_llama_cpp_placement.py drafter and header-scan tests already fail on main and are unrelated.

A failed or empty llama-server --help probe reported supports_load_mode=False,
which made apply_load_mode_policy fall back to --no-mmap / --mlock. Newer
llama.cpp builds removed those flags and exit on them, so a probe timeout on a
busy machine turned into a hard load failure. load_mode_support() now returns
None for an inconclusive probe and the policy then emits nothing.
@danielhanchen danielhanchen self-assigned this Oct 28, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-28T17:05:21.338746Z 52d46ef Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: 52d46ef7bc

ℹ️ 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".

@danielhanchen
danielhanchen merged commit 987731e into main Oct 28, 2026
29 of 47 checks passed
@danielhanchen
danielhanchen deleted the studio-load-mode-caps-false-negative branch October 28, 2026 17:47
meefs pushed a commit to meefs/unsloth that referenced this pull request Oct 28, 2026
… probe is inconclusive (unslothai#15833)

## Summary

Follow-up to unslothai#15828. That PR stopped `apply_load_mode_policy` from
emitting `--no-mmap` / `--mlock` when the `llama-server --help` probe is
inconclusive, but the Model Memory "Keep model in GPU memory" path still
did. With an empty capability catalogue, `apply_model_memory_policy`
read `supports_load_mode` as `False` and emitted the legacy `--mlock`.
Current upstream llama-server has removed that spelling and exits on it,
so a probe timeout under load still turned into a failed load whenever
Keep resident was on and the weights sat in host RAM. The `--fit on`
retry had the same fallback inline.

## Changes

- New `keep_resident_lock_flags(support)` in `llama_server_args.py`:
`--load-mode mmap+mlock` when `--load-mode` is listed, `--mlock` when a
successful probe shows it is missing, nothing when support is unknown.
`apply_model_memory_policy` and the `--fit on` retry both use it. When
nothing is emitted, the user's extras are left untouched.
- New `keep_resident_lock_applicable(host_resident, support)`: a lock is
only owed on a build we could spell it for. The initial launch, the
`--fit on` retry and the arch-crash retry use it for
`_memory_mlock_applicable`, so the reload hint and the duplicate-load
comparator do not ask for an mlock this launch skipped (no reload loop
on a build whose probe keeps failing).
- Every remaining `bool(server_caps.get("supports_load_mode"))` in
`llama_cpp.py` now goes through `load_mode_support(server_caps)`. That
covers the memory policy call, the DirectIO gate and the two Metal
demand-paged embedding estimates. The estimates now model the same
command line the launch builds. Before, they assumed the legacy flag on
an unknown build even after unslothai#15828 stopped emitting it.

Builds with `--load-mode`, and builds whose probe positively lacks it,
get the same flags and bookkeeping as before.

## Tests

`test_load_mode_caps_unknown.py` gets new cases: the lock spelling for
each probe outcome, a typed `--mlock` kept on an unknown build, fake
binaries that fail `--help` or print nothing producing no lock and no
reload demand, and a source check that no launch site reads the raw cap.
On main, 9 of them fail; on this branch they pass.

Across `test_load_mode_caps_unknown.py`,
`test_model_memory_settings.py`, `test_load_mode_fit_matrix.py`,
`test_server_tuning_flags.py`,
`test_launch_flags_are_capability_gated.py`,
`test_llama_cpp_placement.py` and
`test_metal_explicit_context_guard.py`, the only other failures are the
same five `test_llama_cpp_placement.py` drafter and header-scan tests
that already fail on main.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant