Skip to content

Studio: skip the Keep resident page-lock when the llama-server --help probe is inconclusive - #15833

Merged
danielhanchen merged 5 commits into
mainfrom
studio-mlock-unknown-probe
Oct 28, 2026
Merged

danielhanchen merged 5 commits into
mainfrom
studio-mlock-unknown-probe

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Summary

Follow-up to #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 Studio: emit no legacy load flag when the llama-server --help probe is inconclusive #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.

@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-28T19:12:52.388745Z 6aa939f 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: b5680f48d9

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

Copy link
Copy Markdown
Member Author

The staging backend (Python 3.13, g-r) shard fails three tests in studio/backend/tests/test_gpu_arch_gate_os_matrix_7624.py, all on the --mlock assertion:

  • TestTheForcedCpuLaunchAppliesThePageLock::test_the_masked_child_gets_the_lock (line 2756)
  • TestTheApuRetryRecomputesThePageLock::test_the_respawn_onto_the_apu_gets_the_lock (line 2857)
  • TestTheApuRetryRecomputesThePageLock::test_the_users_own_extra_args_survive_the_recompute (line 2892)
E   assert ('--mlock' in ['.../build/bin/llama-server', '-m', '.../model.gguf', '--port', ...

The whole file passes on main (194 passed), so this comes from the new gating. The fake llama-server in those tests has no --help that lists --mlock, so the probe is inconclusive and the page lock is now skipped. If skipping on an inconclusive probe is the intended behaviour, those tests need a fake binary whose --help advertises --mlock, so they keep proving the forced-CPU and APU-retry paths apply the lock. If the lock should still apply there, the gate is too broad.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 6aa939f4dd

ℹ️ 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 1b3ad97 into main Oct 28, 2026
42 of 54 checks passed
@danielhanchen
danielhanchen deleted the studio-mlock-unknown-probe branch October 28, 2026 19:56
danielhanchen added a commit that referenced this pull request Oct 28, 2026
`Repo tests (CPU, fsdp2)` on #15833's staging run passed every test and
still went red:

```
364 passed, 28 skipped, 80 warnings in 2092.29s (0:34:52)
##[error]Process completed with exit code 124.
```

The shard's pytest step runs under `timeout --signal=INT --kill-after=60
2100`. pytest finished 8 s under that cap, and the cap then fired while
it was exiting.

## Cause

#15291 moved the FSDP2 gloo tests into their own shard at about ten
minutes of runner time. They have grown since, with most of a dozen
FSDP2 PRs merged today adding tests there (#15756, #15748, #15720,
#15709, #15708, #15352, ...). Over the last twenty-odd staging runs this
job took 21 to 38 minutes, so it now sits at its cap on an ordinary
runner. Nothing failed; the shard is simply too big for its timeout.

## Fix

Split the shard in two by file name, balanced on measured time. Per-test
durations on main, summed per file across all 76 files:

| shard | selection | files | tests | measured time |
|---|---|---|---|---|
| `fsdp2` | `tests/test_fsdp2_[!n]*.py tests/test_fsdp2_n[!a]*.py
tests/test_fsdp2_native_[abc]*.py` | 34 | 237 | 1156 s (45%) |
| `fsdp2-native` (new) | `tests/test_fsdp2_native_[!abc]*.py` | 42 | 276
| 1406 s (55%) |
| both together, unchanged total | `tests/test_fsdp2*.py` | 76 | 513 |
2562 s |

`fsdp2` keeps its name, so its check name is unchanged. The step timeout
and job cap are left alone, so each half gets the whole budget.

## Guards

- `tests/test_ci_repo_cpu_shards.py` already fails when a file lands in
no shard or in two. It caught my first draft, which dropped
`test_fsdp2_non_cuda_accelerate_route.py`; hence the `n[!a]` glob.
- A new check, `TestEveryGlobRootMatchesAFile`, fails if a shard glob
matches no test file. bash passes an unmatched glob through literally
and pytest then fails the whole shard on a missing path. Sabotage:
adding `tests/test_fsdp2_zz*.py` to a selection fails it with
`[('fsdp2', 'tests/test_fsdp2_zz*.py')]`.
- `tests/studio/test_backend_ci_parallel_isolation.py` pins the number
of parallel runs, now nine (six repo-root shards).

## Verification

- `tests/test_ci_repo_cpu_shards.py` and
`tests/studio/test_backend_ci_parallel_isolation.py`: 56 passed.
- With `tests/studio/test_cache_budget_discipline.py` added: everything
passes except the guard on my first draft, fixed above.
- `--collect-only` on the two selections gives 237 + 276 = 513, the same
as the old single glob.

The per-file times are from a local `-n 8` run, so the split ratio is
approximate. The first runs of the two new shards will show the actual
runner times.
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