Repository navigation
[Engine] Inkling 2 Mini: --layer-split across cards, the loop on the faster card - #227
Open
okada-shogo wants to merge 6 commits into
Open
okada-shogo wants to merge 6 commits into
okada-shogo wants to merge 6 commits into
Conversation
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>
okada-shogo
marked this pull request as ready for review
November 23, 2026 02:11
okada-shogo
added a commit
to okada-shogo/PolyStrata
that referenced
this pull request
Nov 23, 2026
…ss cards, the loop on the faster card Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
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:
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:
--layer-split 6and6,18hung after loading (fixed above).Not run:
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