Repository navigation
[Engine] Inkling 2 Mini: --layer-split across cards, the loop on the faster card - #227
Conversation
…ss cards, the loop on the faster card Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
f5e9ee2 to
67d9e08
Compare
|
This one is not merged and the rest of the batch is in main now. I found a bug when I test it on two cards with --layer-split auto and greedy decoding, and --top-probs off. The first token is correct, but every tokens after it is 0. If I turn on --top-probs 5, then the tokens are exactly same as one card. All the checks in the PR have --top-probs on, so they didn't catch this bug. Could you fix this and rebase it to main? |
…ss cards, the loop on the faster card Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> # Conflicts: # docs/models/inkling.md # engine/src/poly/inkling2.cpp # terminal/data/settings-register.json
67d9e08 to
74d7fcb
Compare
|
Correction to my last comment, the token 0 bug isn't in this PR, it's been in main since 967620e, and a greedy run on a layer split reads the wrong card's logits. LFM2.5 on main shows the same thing. Sorry about blaming your split. I fixed it on main in 3d28e5c and with that your split gives the same tokens as one card in our checks, at the auto split and at layer 6, with and without --top-probs |
74d7fcb to
611fa2f
Compare
|
Just saw your message, let me confirm |
A card of a split runs a run of the 24 layers, and the loop's twelve (6 to 17) stay on one card: next_layer() runs them again for a later pass, so a card starts at layer 1 to 6 or 18 to 22. layer_starts() takes a range no card starts inside: a number given inside it is refused with a message, and "auto" takes the nearer of its ends by the layers' bytes. Engine::open() gives that range only for inkling2_loop; the other families pass none. Inkling 2 keeps its residual streams and the loop's bank beside r_ (carry_rows()), so a hand-off now carries them too: hand_on() and step() copy them behind the rows of r_ (carry_out(), 64.5 KB a token with r_), and the next card copies them back in run() and step() (carry_in()). carry_rows() is 0 for every other family, so their hand-off and one-card paths are unchanged. The input's norm loads on the card with layer 0 and the output's mix query on the card with the output; one card loads both at layer 0 as before. --draft-model stays on one card (its features are three layer runs' inputs, which may be another card's). Ported from our engine's --layer-split for Inkling (okada-shogo/PolyStrata inkling2 9fe4fee), adapted to VecSzn's 24-layer engine with next_layer(). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Inkling 2 Mini runs layers 6 to 17 three times a token: 36 of its 48 layer runs. The plain "auto" shares layers by free VRAM and puts the loop wherever the bytes fall. On a fast and a slow card, with the server's "faster card last" order (#1352), that gives the slow card the loop: on an RTX 5080 + RTX 4060 Ti 16 GB the estimate is 12.6 ms a token where the loop on the 5080 is 5.7 ms. split_plan.hpp estimates a token's time for every legal start of the second card and both device orders. Dense weights are read once a run, expert_used_count/expert_count of the experts once a run, the output once a token. Each card caches its most-run experts first and reads the rest on the CPU. The cards run in turn, so the times add. layer_starts() takes the fastest layout when it is at least 3% faster than the plain one, and open() may then swap which device takes the first layers. Cards within 5% of each other's bandwidth (the server's #1760 rule), cards whose bandwidth is not known (HIP, Metal) and every other family keep the plain layout and order. Bandwidth is the peak memory clock times the bus width; STRATA_POLY_CARD_GBS=a,b overrides it. "auto" now probes devices in turn when STRATA_POLY_CARDS asks for more parts than there are devices (it failed there before), so the choice can be tried on one card. poly_split_plan_test checks the choice on made-up cards, no GPU needed. The idea of keeping the looped core on the faster card is cobra91's and kuraneko1's (Strata PR #6506, their two-card Inkling 2 layout); this is our own code for a plain layer split. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tools/check's docs step and tools/test_settings_register.py failed: the engine reads STRATA_POLY_CARD_GBS (each card's bandwidth for --layer-split auto) and it was not in terminal/data/settings-register.json. Add its entry as python tools/settings_register.py writes it, with status research, owner poly and a note, and leave every other entry as it was (as fd20bfc did). A research setting is not listed in docs/SETTINGS.md, so that page is not touched. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ixed yet) The two-parts-on-one-card runs (STRATA_POLY_CARDS=2, CPU experts) gave the one-card tokens and top-20 probabilities for splits 3, 18 and 20, but splits 6 and 6,18 never produced a token (worker threads spinning). Say so in docs/models/inkling.md, and that 18 is the cut to use for now. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… layer keeps the pass layer_head() set the loop's pass to 0 at the card's first layer. When a card starts at layer 6, the loop's first layer, each later pass came back to that layer and set the pass to 0 again, so the loop never ended (--layer-split 6 and 6,18 hung after loading). Such a card now keeps the pass there; next_layer() leaves it 0 after the last pass. One card (first layer 0) runs as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… RTX 2070 Super's speeds Drop the known-bug note (b32a413 fixes the hang at layer 6). Say that --layer-split has run on two RTX 2070 Super 8 GB (vast.ai): every split gave one card's tokens and top-20 probabilities with the experts on the CPU, and with the experts in VRAM split 18 wrote 51.0 tok/s and split 6 48.5 where one card wrote 37.0 (IQ4_NL, 302 + 256, mean of 3 runs). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
poly_layer_split_picks_test (by hand, needs the model and a card; STRATA_POLY_CARDS lets one card run the parts) writes greedy tokens on one card and split, with the token picked on the card (eval_picks(), picked(): no --top-probs) and from the logits, and wants the same ids. It covers main's 3d28e5c (VecSzn: a split's greedy token from its last card); before that fix the split picked on the card wrote 0 after the first token. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
611fa2f to
2e05830
Compare
|
It was merged into main and poly_layer_split_picks_test didn't build on windows because MSVC doesn't have setenv, so it's using _putenv_s now like main.cpp does (80190a3) |
Rebased onto main 5c83833 (2026-11-24).
--top-probsoff on a split: VecSzn found that greedy decoding with--top-probsoff wrote 0 after the first token. The bug was main's (since 967620e) and main fixed it in 3d28e5c. This PR now only adds a test for it,poly_layer_split_picks_test.Problem and result
For machines with two or more GPUs.
--layer-splitnow works with Inkling 2 Mini, as it does for the otherstrata-poly models. Main refuses it (inkling2.cpp: "runs on one card"). Opt-in: one card without
--layer-splitrunsthe same code as before.
or at layer 18 to 22.
"auto"knows the loop and each card's memory bandwidth. On two unequal cards it puts the loop on the faster card,in either card order. Equal cards (within 5%) get the plain layout.
Speed on two RTX 2070 Super 8 GB (rented, PCIe 3.0 x16 each), IQ4_NL, experts in VRAM, a 302-token prompt, 256 tokens
written,
--kv fp16, in tokens per second (tok/s), higher is better. Mean of 3 runs. "One card" is device 0 without--layer-split; "two cards" is this PR with the--layer-splitin the Measure column.Prompt tok/s, higher is better:
--layer-split 18(second card from layer 18)--layer-split 6(second card from layer 6)--layer-split autoDecode tok/s, higher is better:
--layer-split 18(second card from layer 18)--layer-split 6(second card from layer 6)--layer-split autoNo split mode was slower than one card. Split 6 is about one card's speed on the prompt (+1.2%) and faster in
decode. It holds fewer experts in VRAM than 18, because its first card has only 6 layers to fill. On two equal
cards
autotakes the same layout as 18, so the gap between them on the prompt (+14.3% and +8.6%) is not a layoutchange. It is not explained yet: auto ran right after split 6 in each round, and split 18 right after one card.
Identity: every split gives exactly one card's tokens and top-20 probabilities. That means 302 + 64 and 2048 + 16
tokens, greedy,
--top-probs 20,--kv fp16, every expert on the CPU (--no-gpu-experts, so no expert cachediffers), with the same md5 of the output. "Parts on one card" = an RTX 2070 8 GB running the split's parts in turn
(
STRATA_POLY_CARDS); "two cards" = the two RTX 2070 Super. SAME = the same as this branch on one card, which is thesame as main:
--layer-split 3--layer-split 6--layer-split 18--layer-split 20--layer-split 6,18(three parts)--layer-split auto--layer-split auto, bandwidths forced to 900 and 300 GB/s--layer-split auto, bandwidths forced to 300 and 900 GB/s (loop moves to device 1)--layer-split 6, devices in order 1, 0--layer-split 18, devices in order 1, 0Each run (tok/s)
Prompt tok/s, higher is better, each run:
--layer-split 18--layer-split 6--layer-split autoDecode tok/s, higher is better, each run:
--layer-split 18--layer-split 6--layer-split autoExperts in VRAM, as logged at load: one card 993 (device 0) and 994 (device 1) of 3,072, 4.8 GiB. Split 18 and auto
1,187 of 2,304 (layers 0 to 17, 5.0 GiB) + 721 of 768 (layers 18 to 23, 4.8 GiB). Split 6: 768 of 768 (3.2 GiB) +
807 of 2,304 (4.0 GiB). The rounds went one card device 0, device 1, split 18, 6, auto, three times.
Related discussion
Split out of #200, as the maintainer asked there:
#200 (comment)
Independent of the other split PRs (based on main, not stacked).
Approach
The split (placement only)
layer_starts()takes a range no card may start inside (onlyinkling2_looppasses one:loop.start,loop.end).A number inside it is refused;
"auto"snaps to the nearer end by bytes.r_(carry_rows());carry_out()/carry_in()copy them with the rows of
r_inhand_on(),step()andrun().carry_rows()is 0 for every other family.--draft-model(DSpark) stays on one card."auto" on unequal cards (placement only)
split_plan.hpp(header only) estimates a token's time for every legal cut and both card orders from file sizes andpeak bandwidth (peak memory clock x bus width;
STRATA_POLY_CARD_GBS=a,boverrides it; HIP and Metal report 0, sothey get the plain layout).
STRATA_POLY_CARDSabove the device count,"auto"probes the devices in turn (before: "invalid device").estimate, not a measurement.
Fix: a card that starts at layer 6 ran the loop forever (b32a413)
Inkling2::layer_head()set the loop's passpass_to 0 at the card's first layer (if (il == lo_) pass_ = 0;).next_layer()runs the loop again by going from layer 17 back to 6 withpass_ + 1. On a card whose first layer is 6,every return to 6 set
pass_to 0 again, so the card never left the loop (--layer-split 6and6,18hung afterloading). Now the reset is skipped when the card's first layer is the loop's first:
if (il == lo_ && il != core_start_).next_layer()already setspass_back to 0 after the last pass, so each callstill starts at pass 0. One card (first layer 0) runs the same code as before.
Validation
Passed:
--top-probsoff at 2e05830 (main's 3d28e5c fix), Bazzite RTX 2070 8 GB (sm_75), parts on one card (STRATA_POLY_CARDS=2), sm_75;86 build, fp16 KV:poly_layer_split_picks_test MODEL SPLIT 32: splits auto and 6, IQ4_NL and UD-Q2_K_XL: 4 of 4 PASS.strata-polyidentity, IQ4_NL, 302 + 64 tokens: splits 6 and auto, each with--top-probs 20(ids + top lines) and off (ids), vs one card: 5 SAME, 0 DIFF, 0 timeouts.--top-probsoff with our earlier fix (611fa2f, same change as main's), Bazzite RTX 2070 8 GB (sm_75), parts on one card (STRATA_POLY_CARDS), CUDA 12.9, sm_75;86 build,--no-gpu-experts, fp16 KV:poly_layer_split_picks_test MODEL SPLIT 32(greedy ids on one card and split, picked on the card and from the logits): splits auto, 6, 18,6,18, IQ4_NL and UD-Q2_K_XL. The build before the fix FAILs all 8 (split, picked on the card:2567,0,0,0,...), the fix PASSes all 8.strata-polyidentity against one card with--top-probs 20, with--top-probs 20(ids + top lines) and with--top-probsoff (ids): 302 + 64 tokens on both files (splits 3, 6, 18, 20,6,18, auto, auto with bandwidths 300,900) and 2048 + 16 on IQ4_NL (6, 18, auto): 37 SAME, 0 DIFF, 0 timeouts. Before the fix, split auto with--top-probsoff: DIFF (150060,0,0,...).poly_split_plan_testok;tools.test_settings_register8 OK;tools/check --only docs6 of 6;terminal/toolstest_setup*.py1368 OK, 1 skipped.Xeon E5-2630 v4, 40 threads, 62 GB). Main d1f711e and this branch b32a413, both built there with CUDA 12.9.86,
sm_75. Identity (table above): 24 SAME, 0 DIFF, 0 timeouts (each run capped at 600 s), 0 runs failed. Speed: the
15 runs above, all rc=0.
STRATA_POLY_CARDS=2/3), RTX 2070 8 GB (sm_75), b32a413 vs one card, vs thebranch before the fix and vs main: 44 SAME, 0 timeouts, 49 runs rc=0 (table above).
poly_split_plan_test(no GPU):split_plan_test: ok. Equal cards keep the plain cut and order, unequal pairs get theloop on the fast card in both orders, only legal starts are taken, and a change happens only where it is 3% faster.
strata-polyat this branch's head.python3 tools/check --only docs: 6 of 6.Failed:
--top-probsoff wrote 0 after the first token.--layer-split 6and6,18hung after loading (fixed above).Not run:
--layer-splitwith--kv q8_0(main's [Engine] Inkling 2: --kv q8_0, an 8-bit attention cache without FP8 hardware #214).make the Q2 loop file (
q2_to_loop.py: noggufmodule in its venv). UD-Q2_K_XL ran only as parts on one card.STRATA_POLY_CARD_GBS). cobra91 was asked to try his RTX 5080 +RTX 4060 Ti.
--layer-split 10and23.__ldcs/__ldcg, fixed by [Engine] build Inkling 2's DSpark screen on HIP #206).Limits
differently on the card and on the CPU, so a split's tokens can differ from one card's, as with any cache size.
The identity runs keep every expert on the CPU for that reason.
"auto"'s choice on unequal cards is an estimate from file sizes and peak bandwidth, not measured yet."auto".STRATA_POLY_CARD_GBSis set.card). That is only the one-card test mode.
--batchon Inkling 2): both PRs edit the sameneed(opt_.layer_split.empty())line. Whichever landssecond should keep
--batchand--layer-splitapart on Inkling 2 (need(opt_.batch == 0 || !split_, ...)) untilthat pair is tested.
Credits: keeping the looped core on the fast card is cobra91's and kuraneko1's idea (Strata PR #6506); the code here
is our own, adapted from our
--layer-splitin #200.🤖 Generated with Claude Code