Repository navigation
[Engine] Inkling 2 on Turing: the expert-tile offsets no longer wait behind expert uploads (same bits) - #280
Merged
Conversation
…y a kernel, not a copy With --prompt-int8 on Turing (expert_tiles_), moe_rows() copied each call's cached-expert offsets (about 1 KB) to the card on the compute stream. A card with one copy engine for uploads ran that copy after the experts already queued for the card (a layer's uncached ones, or with STRATA_INK_PRESTAGE=1 the next layer run's, about 390 MB of IQ4_NL's on an RTX 2070 Super), and the call's launches waited for it, the cached experts' too. copy2() reads the offsets from pinned memory instead, as the row tables already are. Same bits: the same offsets reach the same launches. 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
With
--prompt-int8on Turing,moe_rows()copied each call's cached-expert offsets (about 1 KB, for the experttiles) to the card with
cudaMemcpyAsyncon the compute stream. The RTX 2070 Super uploads through one copyengine, so that small copy ran only after the expert uploads already queued for the card. The call's launches,
including the cached experts' ones, waited for it. This PR hands the offsets to the card with
copy2(), a kernelthat reads them from pinned memory, as the row tables already are.
Same bits: the same offsets reach the same launches.
Prompt tok/s, higher is better.
carried a bounds change since dropped from the PR; alone it measured as noise) on 1a41ff6, no engine change in
between for one card. Both run with
--prompt-int8.--serve, one warm-up request on another 2,048-token prompt, then the measured request.Decode does not run the changed code: −1.1% to −0.2% (table below), within the run-to-run spread.
The gain is larger with #271's
STRATA_INK_PRESTAGE=1. There the next layer run's ~390 MB of experts sit in thecopy queue during a call, and the offsets copy waited behind all of them. On the RTX 2070 Super, #271 + this PR read
an IQ4_NL 2K prompt at 819 tok/s, against 616 with #271 alone (cold first request, 3 runs each).
Related discussion
Found while comparing the stack of our open Inkling PRs with #200 under nsys on the RTX 2070 Super. Each layer
run's first call waited about 30 ms for an H2D of a few hundred bytes, the expert offsets. The copy was issued with
the call's launches but ran only when the expert upload ahead of it in the copy queue was done.
Approach
moe_rows():copy2(h_slot_at_, d_slot_at_, …)in place ofcudaMemcpyAsync(…, cs(st_)).h_slot_at_ispinned. The host fills it after the call's routing wait, as it does the row tables, so the stream order that made
the copy safe also makes the kernel read safe.
expert_tiles_is on, like the othercopy2()uploads of pinned buffers (h_at_,h_r_).expert_tiles_is set only by Inkling 2 on sm_75 with--prompt-int8, so nothing else changes.that is the same as or stronger than before, since the host waits on the next call's routing event.
Validation
Passed
Speed, RTX 2070 Super: the table above.
NAME=eo-e2e2 WARM=…/idsb2048.txt SIDES="M E" ARGS_M=--prompt-int8 ARGS_E=--prompt-int8 FILES="iq4 q2l" REPS=3 bash e2e-nw.sh, 37 of 37 runs rc=0.FILES=iq4 CASES=p2k:2048:1:32768 REPS=4, 9 of 9 runs rc=0.Same tokens: after 8,192 tokens, the 256 greedy tokens of each run are equal across main and this PR (3 runs,
both files). After 302 tokens main differs from itself run to run (placement), so that case says nothing.
Builds of 034399e: CUDA sm_75 (CUDA 12.9) and HIP (gfx1201;gfx1100, ROCm 7.2.4), both rc=0.
Capped and frozen identity:
STRATA_GPU_EXPERTS=600 STRATA_FREEZE_EXPERTS=1,--prompt-int8, prompts of 302,2,048 and 8,192 tokens, 64 greedy tokens,
--top-probs 20, IQ4_NL and UD-Q2_K_XL. The ids and the top-20 lines ofthis PR equal main's in 18 of 18 comparisons (two runs each against main's first; main's second run too).
RTX 2070 Super.
poly_mmq_paths_test --turing-int8on the PR build: PASS.Not run
expert_tiles_, so nothing changes there.Each run (tok/s)
Prompt:
* Not used: that whole process ran slow, its warm-up request too (530 tok/s against 663 in the other runs). IQ4_NL 2K was measured again on its own, 4 rounds:
Decode (256 tokens written after the prompt):
Experts in VRAM at load: 912 to 927 (IQ4_NL), 1,977 or 1,986 (UD-Q2_K_XL); in each round the same for both builds.
Limits
--prompt-int8, inprompts of more than one call. It helps most with
STRATA_INK_PRESTAGE=1.🤖 Generated with Claude Code