Skip to content

[Engine] helper cards given by --expert-cache-device are placement: no auto layer split, no split reorder - #6155

Closed
fri-K wants to merge 1 commit into
Niko1221:mainfrom
gospogied:f-helper-placement
Closed

fri-K wants to merge 1 commit into
Niko1221:mainfrom
gospogied:f-helper-placement

Conversation

@fri-K

@fri-K fri-K commented Nov 17, 2026

Copy link
Copy Markdown

Problem and result
A multi-helper config — gpu: [0, 1, 2] with --expert-cache-device1 auto --expert-cache-device2 auto (RX 9060 XT primary + two RX 6600 expert-cache tiers; gfx1200 + gfx1032 mixed) — is placement, but serve did not know it. #665 made --peer-device suppress the automatic --layer-split auto injection; the expert-cache helper args never got the same treatment, and serve also applied the #1352 speed reorder on top. Before: --layer-split auto was injected anyway and the GPU order rewritten so the fastest card (the gfx1200 primary) landed in the LAST split stage. On this board the first such request hard-crashed the host twice (GPU reset, power-cycle needed). After: helper placement is honored end to end — no injection, no reorder, correct announce line — and check_placement() fails at config-check on contradictory placement (helper args beside an explicit layer_split, --peer-device outside the visible set). Split-only and peer-only configs render byte-identical to before.

cfg = {"gpu": [0,1,2], "backend": "hip",
"args": ["--expert-cache-device1", "auto", "--expert-cache-device2", "auto"]}
pristine v0.2.15: layer_split_of(cfg) = True -> serve injects --layer-split auto + reorders
branch: layer_split_of(cfg) = False | helper_cache_of(cfg) = True
Related discussion
#665 — the peer-vs-split gate this extends to the native multi-helper args; #1352/#1576 — the reorder that misfires here (it assumes split semantics; helper configs are not splits). Bugfix, no behavior change for non-helper configs, so no prior scope agreement sought.

Approach
One gate shared by both injection points, in #665's style: helper_cache_of() recognizes every helper arg (--peer-device, --expert-cache-device1..3); layer_split_of() and ordered_gpus() consult it; check_placement() turns silent misplacement into a config-check error. serve never sets STRATA_PRIMARY_DEVICE, so visible order IS placement — the reorder actively breaks it. No engine-side changes. The mixed gfx1200+gfx1032 board this was validated on is described in the companion gfx1032 PR's docs commit; the two PRs are independent and merge in any order.

Validation
Environment for everything below: one mixed-family production server — Xeon E5-2697 v3, 64 GiB RAM, RX 9060 XT (gfx1200, x16 Gen5) + 2x RX 6600 (gfx1032); Python 3.12 venv, TheRock 7.13.0a20260515 wheels (core + devel + gfx103X_all), no system ROCm. Engine 0.1.60 built from this tree with -DCMAKE_HIP_ARCHITECTURES="gfx1032;gfx1200", native MMQ (sha + BUILD.json attached). Model: Qwen3.8-Flash-Next IQ3_XXS, 262144 ctx, KV int8 / resident 32768, MTP.

Passed:

serve/test_placement_helpers.py (new, 11 cases) against pristine v0.2.15: Ran 11 tests ... FAILED (failures=4, errors=7) — this is the reproduction; same suite on the branch: OK.
python -m unittest serve.test_placement_helpers serve.test_split_fallback serve.test_server serve.test_parallel on the branch: Ran 444 tests ... OK.
Live service on the branch (patched serve + 0.1.60 engine): r4k 6.3 s, 16k 11.8 s, 44k 26.3 s, 90k 57.9 s; marker requests at 120,875 / 151,059 / 181,243 / 211,427 prompt-tokens all answered finish=stop in 89.1 / 102.9 / 131.3 / 150.0 s — 20-25 % faster than the 0.1.59 engine running weeks at the same settings (112.5 / 140.2 / 164.4 / 184.5 s); CE delta 0 and major-fault delta 0 at every stage; effective engine args captured from /proc contain no --layer-split.
The same serve patch carried weeks of production on the 0.1.59 engine before the bump: 524 + 189 soak requests, zero exceptions, zero guard trips, decode expert-cache hit 90.0 %, KV streaming 99.5 % VRAM. (Soak flags with exec-test failures were classified by direct reply inspection as a model-side artifact — the model sometimes returns the prompt's code skeleton — identical rate on the unpatched engine.)
Failed: none observed on the branch. (The pristine 4 failures + 7 errors are the expected reproduction, listed above.)

Not run: CUDA / SYCL / Metal / Windows — no such hardware here; the serve gate is backend-agnostic but only HIP paths were exercised. Subprocess integration test for placement — the new cases are unit-level against serve's arg rendering. Engine CI matrix — this PR touches no engine build files.

Limits
Single host, single model family. Staged layer-split across gfx1200+gfx1032 stays dangerous on this board — this change makes serve stop silently creating it; it does not make the split itself safe. check_placement() rejects helper+explicit-split rather than reconciling it — stricter than a merge, chosen because the merge already proved fatal here.

… reorder (Niko1221#665, Niko1221#1352)

Niko1221#665 made --peer-device suppress the automatic layer split; the native multi-helper
args --expert-cache-device1..3 were left out, so a multi-GPU helper-cache config got
"--layer-split auto" injected AND the Niko1221#1352 speed reorder applied on top.  On a
mixed-family board (RX 9060 XT primary + 2x RX 6600 expert-cache helpers) that silently
demotes the fastest card to the LAST split stage: the first request then staged a split
across families which hard-crashed that host twice (GPU reset, no recovery).  Helper
mode must never be silently converted into a split.

helper_cache_of() covers every helper arg; check_placement() rejects helper placement
beside an explicit "layer_split" and a --peer-device outside the visible set, at config
check; ordered_gpus keeps the config's order when helpers are in play; the startup
announce names helper caches instead of the peer tier.  Plain split and peer configs
render exactly as before.

serve/test_placement_helpers.py: 11 cases incl. the no-reorder regression and the
suppression pair.  On unpatched v0.2.15 the suite fails 4+7 against these cases; the
full serve suite (444 tests, upstream + these) passes on this commit.
---
@fri-K

fri-K commented Nov 19, 2026

Copy link
Copy Markdown
Author

This PR is based on the v0.2.15 tag layout (branch f-helper-placement, single commit 6bd0295) and cannot survive the current main restructure — serve moved to terminal/serve/ and server.py was split into server_parts/ — hence the merge conflicts.

The change has been re-ported onto the current layout as #6324 (branch f-helper-placement-0216, one commit on today's main, mergeable; same commit message and gate design), now also carrying the placement unit tests adapted to the new layout and updated production validation (live on the 0.2.16 stack, engine args verified with no --layer-split injection).

Closing this one in favor of #6324.

@fri-K fri-K closed this Nov 19, 2026
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