Skip to content

[Engine] Inkling 2 on Turing: the expert-tile offsets no longer wait behind expert uploads (same bits) - #280

Merged
VecSzn merged 1 commit into
simplexai-labs:mainfrom
okada-shogo:port/expert-offsets
Nov 23, 2026
Merged

VecSzn merged 1 commit into
simplexai-labs:mainfrom
okada-shogo:port/expert-offsets

Conversation

@okada-shogo

@okada-shogo okada-shogo commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Problem and result

With --prompt-int8 on Turing, moe_rows() copied each call's cached-expert offsets (about 1 KB, for the expert
tiles) to the card with cudaMemcpyAsync on the compute stream. The RTX 2070 Super uploads through one copy
engine, 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 kernel
that 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.

  • Setup: RTX 2070 Super 8 GB (PCIe 3.0 x16), Ryzen 5 3600XT. main = 6d59254; this PR alone (measured as 0c33a37bc, which also
    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.
  • Method: fp16 KV, --serve, one warm-up request on another 2,048-token prompt, then the measured request.
  • Rounds alternate the order of the two builds (main first, then this PR first, and so on).
  • Mean of 3 runs (IQ4_NL 2K: of 4 runs in a re-run of that case alone; see "Each run").
Card Model Measure main (tok/s) this PR alone (tok/s) Change
RTX 2070 Super 8 GB IQ4_NL prompt 302 276.9 278.7 +0.6%
RTX 2070 Super 8 GB IQ4_NL prompt 2K 612.9 663.2 +8.2%
RTX 2070 Super 8 GB IQ4_NL prompt 8K 885.4 909.1 +2.7%
RTX 2070 Super 8 GB UD-Q2_K_XL prompt 302 312.1 314.9 +0.9%
RTX 2070 Super 8 GB UD-Q2_K_XL prompt 2K 722.1 723.4 +0.2%
RTX 2070 Super 8 GB UD-Q2_K_XL prompt 8K 741.3 740.9 0%

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 the
copy 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 of cudaMemcpyAsync(…, cs(st_)). h_slot_at_ is
    pinned. 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.
  • Unconditional where expert_tiles_ is on, like the other copy2() 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.
  • One file, 3 lines. An independent review found no issue: same bytes, the same direction, and a reuse guarantee
    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.
    • IQ4_NL 2K again on its own: the same with FILES=iq4 CASES=p2k:2048:1:32768 REPS=4, 9 of 9 runs rc=0.
    • Logs kept locally (eo-e2e2, eo-e2e3).
  • 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 of
    this 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-int8 on the PR build: PASS.

Not run

  • Other Turing cards. Ampere and newer do not set expert_tiles_, so nothing changes there.
Each run (tok/s)

Prompt:

Model Measure Build Run 1 Run 2 Run 3
IQ4_NL prompt 302 main 275.0 277.9 277.9
IQ4_NL prompt 302 this PR 280.9 275.3 279.8
IQ4_NL prompt 2K main 611.9 614.9 615.1
IQ4_NL prompt 2K this PR 663.9 662.5 505.2*
IQ4_NL prompt 8K main 885.4 885.0 885.9
IQ4_NL prompt 8K this PR 908.4 908.6 910.2
UD-Q2_K_XL prompt 302 main 313.0 308.8 314.6
UD-Q2_K_XL prompt 302 this PR 311.9 316.3 316.5
UD-Q2_K_XL prompt 2K main 722.5 721.6 722.3
UD-Q2_K_XL prompt 2K this PR 723.2 723.6 723.3
UD-Q2_K_XL prompt 8K main 740.9 741.0 741.9
UD-Q2_K_XL prompt 8K this PR 740.6 740.6 741.5

* 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:

Model Measure Build Run 1 Run 2 Run 3 Run 4
IQ4_NL prompt 2K main 613.1 613.1 612.7 612.6
IQ4_NL prompt 2K this PR 662.9 663.6 662.9 663.6

Decode (256 tokens written after the prompt):

Model Measure Build Run 1 Run 2 Run 3
IQ4_NL decode after 302 main 40.8 41.3 40.9
IQ4_NL decode after 302 this PR 40.7 40.3 40.6
IQ4_NL decode after 8K main 34.9 35.3 35.2
IQ4_NL decode after 8K this PR 35.1 35.0 35.1
UD-Q2_K_XL decode after 302 main 45.6 45.6 45.4
UD-Q2_K_XL decode after 302 this PR 45.4 45.5 45.3
UD-Q2_K_XL decode after 8K main 41.2 41.3 41.4
UD-Q2_K_XL decode after 8K this PR 41.2 41.2 41.3

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

  • It helps only where a small copy shares the upload queue with expert uploads: Turing with --prompt-int8, in
    prompts of more than one call. It helps most with STRATA_INK_PRESTAGE=1.
  • Same bits: by construction, and by the frozen identity above.

🤖 Generated with Claude Code

…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>
@VecSzn
VecSzn merged commit 7af9bbd into simplexai-labs:main Nov 23, 2026
4 checks passed
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.

2 participants