Repository navigation
fix(custom-model): warn when parallel llama.cpp slots leave too little context per request - #658
opticon454 wants to merge 4 commits into
Conversation
|
Thanks @opticon454 for this, and for the measurement in #641. This PR records each llama.cpp model's parallel slot count during discovery and warns before a Claude launch when the context split across those slots leaves less than 40K tokens per request. The slot-count side is solid: The This means a default llama-swap model (auto slots, Also needed:
One wording point: with an explicit Once those are in, this is ready to merge. |
|
Thanks @Ark0N, all four items and the wording point are in the new commit (rebased on current master first). The
Wording: the dialog now reads "'s N tokens of context are split across S parallel server slots, about X each." The old |
8e11742 to
c5a4602
Compare
`node_modules/` with a trailing slash matches directories only, so a worktree that links node_modules to a shared install shows the link as untracked and a plain `git add` commits it. Two PR heads did (#658, #662), which also broke checking them out next to a real install. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
Thanks @opticon454 for turning this round so quickly. One thing in the new commit ( It got in because master's The symlink also stopped my review checkout of that head, which is why the rework has not had its review yet. It runs once the new head is up. |
…e context per request llama-server runs several parallel slots (four by default on the build measured) that share one context pool, and Claude Code sends concurrent requests: the main session plus every parallel subagent, each carrying about 40K tokens of its own system prompt and tools. Measured against a real llama-swap server, four simultaneous 40K-token requests against a 4-slot ~131K pool all failed with HTTP 500 "Context size has been exceeded"; the same requests against one slot all succeeded. The existing 40K floor check only looked at the total context, so it never warned. Discovery now also records each loaded model's slot count, read from an explicit --parallel/-np in the launch command or, when the command states none (the server chooses), from /props total_slots. When /props is probed its n_ctx is recorded separately and used only to divide the context across the slots, because a launch command's --fit-ctx is just the auto-fitter's floor: a small model on a large card was measured at 262,144 against a floor of 65,536, and dividing the floor would warn about a server with plenty of room. modelContextLengths still comes from the launch command, unchanged. The in-app warning explains the shared-slot case and the fix (--parallel 1, or a context large enough for every slot). Documented in the Custom Model Endpoints page and Troubleshooting.
…launch command, per-slot /props context is not divided again
c5a4602 to
d53144e
Compare
|
Thanks @Ark0N, and sorry about that: I share one install between my worktrees through a symlink and |
|
Thanks @opticon454 for the quick rework, and for cleaning up the symlink. This PR records each llama.cpp model's parallel slot count during discovery and warns before a Claude launch when the context split across those slots leaves less than 40K tokens per request. All four items and the wording point are in: Please fix:
Small ones (fine in the same commit, or I fix them at merge time):
Once 1 and 2 are in, this is ready to merge. I will squash it on merge, so the commit that briefly carried the |
…, remember a non-2xx /props per launch command
|
Thanks @Ark0N, both items and the small ones are in the new commit.
Small ones: Typecheck, lint and the custom-model, session and quick-start tests pass locally (277). |
|
Thanks @opticon454 for the third round, and for the measurements behind it. This PR records each llama.cpp model's parallel slot count during discovery and warns before a Claude launch when the context split across those slots leaves less than 40K tokens per request. Both items from the last round are in and tested. An explicit One sentence went stale with that change, and I will fix it at merge time:
One note for later, outside this PR: the injected I will squash this on merge, so the |
…e context per request (#658) Squash of PR #658. Discovery records each llama.cpp model's parallel slot count (from --parallel/-np, or /props total_slots when the launch command states none), and a Claude launch warns when the context split across those slots leaves less than 40K tokens per request. An explicit --parallel beside a /props context records a slot count of 1, so a later round overwrites an earlier count, and a non-2xx /props is remembered per launch command while a network error is retried. Merge-time fix by the maintainer: the architecture-invariants sentence on the explicit --parallel case now says it records a slot count of 1. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
Merged and shipped in 1.44.0, squashed into one commit (33d697a) as promised, so the At merge I fixed the one stale sentence in The note from the review still stands as a follow-up if you want it: the injected |
What
A custom llama.cpp model whose parallel slots leave too little context per request now gets an in-app warning that names the fix.
Why
llama-server runs several parallel slots (four by default on the build measured) that share one context pool. Claude Code sends concurrent requests: the main session plus every parallel subagent, each carrying about 40K tokens of its own system prompt and tools. Measured against a real llama-swap server, four simultaneous 40K-token requests against a 4-slot ~131K pool all failed with HTTP 500 "Context size has been exceeded"; the same requests against one slot all succeeded. The existing 40K floor check only looked at the total context, so it never warned.
How
--parallel/-npin the launch command, or, when the command states none (the server chooses), from/propstotal_slots./propsis probed itsn_ctxis recorded separately and used only to divide the context across the slots. A launch command's--fit-ctxis just the auto-fitter's floor (a small model on a large card was measured at 262,144 against a floor of 65,536), so dividing the floor would warn about a server with plenty of room.modelContextLengthsstill comes from the launch command, unchanged.--parallel 1, or a context large enough for every slot.Tests
test/custom-model-slot-awareness.test.ts(new), plus cases incustom-model-endpoint-rediscovery,custom-model-run-menu-uiandroutes/session-custom-model. Changeset included.Fixes #641