Repository navigation
Conversation
Graffioh
force-pushed
the
feat/model-swap-engine
branch
from
October 10, 2026 06:54
bf1c31c to
7f06751
Compare
…a shared GPU Load every named model block and pin named requests to its capacity, while unnamed and auto requests retain primary-first balancing. Report OpenAI chat logprobs from raw logits, including tokens substituted by the thinking budget. Load tied-embedding Qwen3.5 models without a separate output head and support the Qwen3.5-9B DFlash drafter. Expose prefill residual streams through POST /v1/hidden_states, with an optional prefix checkpoint for a subsequent chat request. Run eviction and reinstatement on each model's serial worker, retaining host prefix snapshots and rebuilding the layout fixed at load. Swap residency drains overlapping models and admits requests only to the named resident. Keep selected Qwen weights warm, retry cold if necessary, restore displaced models on failure and enforce a shared 30-second failure cooldown. Load and evict initially inactive blocks before loading the resident set, so the models never need to fit together during startup. DeepSeek4 has partial and cold eviction with frozen expert ownership. A partial eviction releases the primary device and keeps the secondary expert tier, streamed cache and host snapshots. Control operations carry an eviction level; the manager evicts a model partially when its secondary devices do not overlap the target, keeps those devices as retained, and cold-evicts a retained or warm-held model whose devices the target needs. One model block may set --expert-device and --peer-access, a later block no longer turns the peer-access opt-in off, and a DeepSeek4 block that would inherit the expert device from the environment is refused. Residency names auto:N devices by the compiled backend and requires --draft-device for a draft, so aliases and unplaced drafts cannot hide a shared GPU. An automatic request that exceeds every resident model's context is rejected instead of waiting for a swap it cannot trigger. On integrated GPUs the DeepSeek4 memory queries are clamped to system RAM and available host memory, so the streamed cache no longer sizes itself from the 1.25 TiB the driver reports without a carve and exhausts host memory. On an R9700 (PCIe Gen5 x16) with a Strix Halo, Qwen 3.8 27B + DFlash2 and DeepSeek V4.1 Flash (ds41-lucebox placement) share the R9700 in one process. DeepSeek V4.1 evicts partially in 2-58 ms and reinstates in 9-14 s without reloading its 90 GiB Strix Halo tier; the 27B reinstates in 7.6-8.4 s and decodes at the same speed afterwards. Ten partial cycles returned the R9700 to the same free memory with identical restored snapshots, and greedy outputs matched across swaps. Earlier on an R9700 over PCIe Gen3 x4, the 27B and Qwen3.5-9B reinstated cold in 5.1 s and 2.1-2.35 s and warm in 5-9 ms, and a 52.7k-token session returned in 2.5 s instead of about 80 s. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Graffioh
force-pushed
the
feat/model-swap-engine
branch
from
October 12, 2026 06:55
7f06751 to
1507f87
Compare
Graffioh
marked this pull request as ready for review
October 12, 2026 06:55
davide221
reviewed
Oct 12, 2026
davide221
left a comment
Contributor
There was a problem hiding this comment.
Code review
Found 1 issue:
- Partial reinstatement silently drops the hybrid F16 verify K/V mode · likely (
server/src/deepseek4/deepseek4_backend.cpp:4150-4151)
Reviewed 1507f877 · 5 candidate issues checked, kept at ≥70% confidence · add the code-review label to review again
Graffioh
force-pushed
the
feat/model-swap-engine
branch
from
October 12, 2026 07:45
408024e to
b379a3f
Compare
Graffioh
force-pushed
the
feat/model-swap-engine
branch
from
October 12, 2026 07:52
b379a3f to
fd4bb6a
Compare
davide221
reviewed
Oct 12, 2026
davide221
left a comment
Contributor
There was a problem hiding this comment.
Code review
No issues found. Checked for bugs and logic errors in the changed code.
Reviewed fd4bb6a0 · 2 candidate issues checked, kept at ≥70% confidence · add the code-review label to review again
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Serve several named models from one
luce_serverprocess and swap models that share a GPU while retaining their host prefix snapshots. A named request drains conflicting residents, runs eviction and reinstatement on each model's serial worker, and then admits work to the requested model. Failed swaps restore displaced models and apply a retry cooldown.--luce-mixinvokes the installed pair/topology launcher before GPU/model initialization, forwarding its options and this engine's executable path. The launcher resolves model blocks, then execs the normal engine/gateway path.LUCE_MIX_LAUNCHERoverrides the launcher on PATH;--print-profileexports the existing engine profiles for reuse. CLI tests verify argument preservation and profile export; the complete handoff was exercised in hardware-detection/dry-run mode.--routing-gateway /path/to/executablestarts and supervises an installed local gateway on POSIX hosts. The gateway serves the requested--host/--port; the engine moves to loopback port 8491 (--routing-engine-portoverrides it). The child receives--engine-url,--host, and--port. Shutdown reaps the gateway, and unexpected child exit stops the engine with failure. Routing policy remains external. See managed launch.--model-routing nameselects a model by the request'smodelfield; omitted/autorequests use resident capacity.--unknown-model reject|primarycontrols alias fallback.--swap-residencysupports Qwen3.5 cold/warm eviction and DeepSeek V4 partial/cold eviction. Partial DeepSeek eviction retains the secondary expert tier and streamed cache; reinstatement preserves expert placement and router biases. Retained devices participate in conflict handling.--swap-keep-weightskeeps selected Qwen weights warm between single-device models.logprobs/top_logprobs./v1/hidden_statesreports selected prefill residual streams and can seed the prefix cache. Out-of-range unsigned layer indices are rejected before signed conversion.The listener owns routing reservations and residency bookkeeping; each model's worker executes
ControlOptransitions; each backend owns device teardown, reconstruction, and retained host snapshots. Startup loads and evicts inactive blocks before loading the resident set.Swapping currently requires the serial worker (
--max-concurrency 1). Qwen eviction requires a supported single-device configuration with host snapshots; DeepSeek eviction requires the supported in-process two-GPU expert placement. Streaming and unsupported backends continue to ignore logprobs. See the design and usage for configuration restrictions and earlier performance measurements.Validation on the current branch, based on
Luce-Org/luceboxmain5740ef0a3:HIP build for
gfx1151;gfx1201passed.ctest -L cpu: 753/753 passed, including gateway lifecycle coverage; the CLI validation suite passed. The unsigned-layer regression failed before the fix and passed afterwards.R9700 Qwen3.8-27B + DFlash2: three cold eviction/reinstatement cycles preserved greedy snapshot continuations with no device-memory growth.
Real HTTP checks with Qwen3.5-0.8B passed in serial, batched, cold-swap, and warm-swap modes: hidden-state readouts, prefix seeding, logprobs, invalid-layer rejection, and identical greedy replies across swaps. Concurrent hidden-state readouts had cosine similarity above 0.998 against the single-request readout (the reference probe's criterion is >0.99).
R9700 + Strix Halo DeepSeek V4.1 + DSpark: ten partial cycles and a cold reload passed. The secondary tier survived partial eviction without re-upload, frozen placement survived environment changes, restored greedy output matched, and primary free memory was identical after the first and last partial eviction.
Managed gateway integration with two Qwen3.5-0.8B slots: engine-owned startup, internal URL forwarding, streamed and non-streamed consultation, eviction/reinstatement, switch back, graceful child reaping, and gateway-failure propagation passed. The installed gateway determines the public API endpoints.
Final review fix: capture
LUCE_DS4_HYBRID_F16_VERIFY_KVat initialization and preserve it through partial and cold reinstatement. The GPU regression now changes the environment after loading and checks the captured mode during restores. Engine and GPU test compilation are checked; this extended GPU case has not run because an unrelated long-running benchmark occupies the machine. Earlier GPU results above predate this extension.