Skip to content

[Engine] Inkling 2 on RTX 30: use the faster int8 prompt kernel - #300

Open
okada-shogo wants to merge 4 commits into
simplexai-labs:mainfrom
okada-shogo:port/i8m-sm86-select
Open

okada-shogo wants to merge 4 commits into
simplexai-labs:mainfrom
okada-shogo:port/i8m-sm86-select

Conversation

@okada-shogo

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

Copy link
Copy Markdown
Contributor

⚠️ Merge order: #286 → this PR

Stacked on #286 (port/i8m-sm75, the Turing int8 tiles). The diff shows that PR's commit too until it merges.

Problem and result

#286 gave the int8 prompt kernel a tile that loads its inputs in stages of 128 values, so two blocks fit on one SM.
Cards with 100 KB of shared memory per SM use the sm_86 build target (RTX 30, and RTX 40 builds without their own
target). There the default tile also runs only one block per SM. This PR uses the Turing tile on the sm_86 target,
but only for the products where it measured faster than main's default launcher choice (including main's cp.async
stage copy). The outputs are the same bits. On an RTX 3090, prompts get 2.2-2.3% faster on IQ4_NL and 0.5-0.6% on
UD-Q2_K_XL.

Prompt speed, RTX 3090 24 GB (all experts in VRAM), default flags (tok/s, higher is better, mean of 3 runs):

Card Model Measure main this PR alone Change
RTX 3090 IQ4_NL prompt 2K 3073.6 3142.6 +2.2%
RTX 3090 IQ4_NL prompt 8K 2979.5 3047.7 +2.3%
RTX 3090 UD-Q2_K_XL prompt 2K 2343.6 2355.5 +0.5%
RTX 3090 UD-Q2_K_XL prompt 8K 2294.2 2307.9 +0.6%

An earlier run with only the first two products switched (IQ4_NL downs, IQ2_XXS) gave IQ4_NL 2K +3.0% and 8K +3.2% on
the same card. Each run is in the details below.

Related discussion

none

Approach

  • i8m_amp_shape() picks the products. They come from interleaved A/B runs against main's own launcher pick:
    • IQ4_NL where the raw stage copy is not taken (the experts' downs);
    • IQ2_XXS;
    • NVFP4 downs (rows that end inside a 256-value stage);
    • Q8_0 in the widest tile with up to 1,024 outputs.
  • Every other product keeps main's shape and its raw stage copy.
  • Only the sm_86 build target takes the new shape (card.arch == 860). sm_80 (164 KB) already fits two blocks of the
    old tile. Other targets compile the new shapes as empty.
  • STRATA_I8M_AMPERE=<types> sets the types (0: none).
  • poly_i8m_shapes_test --ab N interleaves main's pick, this PR's pick and the new shape forced on. The order rotates
    every round, and it prints the medians.
Kernel times: RTX 3090 (µs, lower is better, median of 7 interleaved rounds)

poly_i8m_shapes_test --ab 7. "main" is main's own launcher pick, with its raw stage copy where it takes it.

Product Rows main this PR alone Change
IQ4_NL experts down [1152 → 2304] 8,192 964.7 781.6 +23.4%
IQ2_XXS experts gate·up 8,192 1,672.1 1,451.1 +15.2%
NVFP4 experts down 8,192 1,012.2 940.2 +7.7%
Q8_0 dense [2304 → 1024] 1,024 80.6 74.0 +8.8%
IQ4_NL experts gate·up (kept) 8,192 1,550.4 1,540.7 +0.6%
Q8_0 experts, Q8_0 [2304 → 3072], IQ2_S, IQ2_XS, NVFP4 gate·up (kept) ±1%

With the new shape forced on, IQ2_S, NVFP4 gate·up and Q8_0 experts are 2-5% slower, so they keep main's shape.
Rows that end inside a stage (IQ4_NL K = 704, NVFP4 K = 1,088) gain too: +15.5% and +8.7%.

Each run (tok/s)
Card Model Measure Build Run 1 Run 2 Run 3
RTX 3090 IQ4_NL prompt 2K main 3071.0 3086.4 3063.4
RTX 3090 IQ4_NL prompt 2K this PR 3155.6 3149.5 3122.8
RTX 3090 IQ4_NL prompt 8K main 2983.2 2978.9 2976.3
RTX 3090 IQ4_NL prompt 8K this PR 3035.0 3058.0 3050.2
RTX 3090 UD-Q2_K_XL prompt 2K main 2350.5 2337.3 2343.0
RTX 3090 UD-Q2_K_XL prompt 2K this PR 2358.4 2350.5 2357.6
RTX 3090 UD-Q2_K_XL prompt 8K main 2295.5 2289.3 2297.8
RTX 3090 UD-Q2_K_XL prompt 8K this PR 2300.6 2310.5 2312.5

Each run is a fresh --serve process, with one warm-up request before the measured one. The round order alternates.
main is cdfae80 and this PR is 975c0cb, CUDA 12.9, on a Salad container (Ryzen 9 5950X).

Validation

Passed:

  • Settings register: STRATA_I8M_AMPERE (and, from [Engine] Inkling 2 on RTX 20: faster int8 prompt kernel #286 which this branch contains, STRATA_I8M_TURING) are registered. python3 tools/settings_register.py --check and tools/test_settings_register.py: OK at this commit. No engine code changed in this commit.
  • poly_i8m_shapes_test --ab 7 on the RTX 3090 (sm_86): main's pick, this PR's pick and the new shape forced on give
    the same bits on all 18 products. Besides Inkling's shapes, these include K = 704 and 1,088, 2,280 outputs, and
    rows read and written by index with empty experts.
  • Prompt tok/s A/B above: IQ4_NL and UD-Q2_K_XL, 3 rounds.
  • Engine identity on the RTX 3090 (sm_86), UD-Q2_K_XL, a 302-token prompt + 64 greedy tokens, --top-probs 20,
    frozen experts (all 3,072 in VRAM): token ids and top-20 lines the same as main, with CUDA graphs and with
    --no-graphs, at default flags and with --prompt-int8 (+ STRATA_PREFILL_NVFP4=w4a8, STRATA_INK_FAST_CTRL=1,
    STRATA_INK_PRESTAGE=1). Main cdfae80 and a build of this PR's tree (the same tree as 975c0cb).
  • The same engine identity on the RTX 3090 (sm_86) with IQ4_NL (17.6 GB file, sha256 checked): a 302-token prompt + 64
    greedy tokens, --top-probs 20, frozen experts (all 3,072 in VRAM), CUDA graphs and --no-graphs, default flags and
    --prompt-int8 with the same three env flags: token ids and top-20 lines the same as main in all four settings.

Failed:

  • none observed

Not run:

  • RTX 40 (sm_89) and A-series workstation cards: no card.
  • sm_80 (A100): unchanged by design (card.arch == 860 only).

Limits

  • The product list comes from one RTX 3090 and one RTX 3060. Other sm_86 cards with other SM counts may pick
    differently.

🤖 Generated with Claude Code

…bits)

On sm_75 the int8 prompt kernel's tile of 128 activation rows takes 59-63 KB of the
multiprocessor's 64 KB, so one block decodes a stage and multiplies it by turns. For
Inkling 2 Mini's types (IQ4_NL, Q8_0, NVFP4, IQ2_XXS, IQ2_XS, IQ2_S) in tiles of 32 and
128 rows, the Turing pass now takes stages of 128 values with 256 threads (two blocks a
multiprocessor), half of the int32 sums made floats by an exact add in place of the
conversion, and for the i-quants shared rows without padding (pieces swizzled by row). The passes for
Ampere and newer compile these shapes empty.
Each output's terms are added in the same order: the same bits. Other cards, and
STRATA_I8M_TURING=0, take the tile as before.

RTX 2070 Super, poly_i8m_shapes_test --time: IQ4_NL experts gate|up 5,489 -> 5,002 us,
down 3,075 -> 2,551; Q8_0 dense [2304 -> 3072] 615 -> 543; NVFP4 down 3,391 -> 2,681;
IQ2_XXS 5,876 -> 5,095.

poly_i8m_shapes_test: each shape against the old one, bit for bit (--time: their times), and the launcher's
own pick; also rows of 704 and 1,088 values, 2,280 outputs, rows read and written by index with experts
without rows; it fails where a Turing shape fits fewer than two blocks a multiprocessor.
The kernel is VecSzn's (i8_mma.cuh); this changes only its tile shape on Turing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@okada-shogo okada-shogo changed the title [Engine] Inkling 2 on sm_86: the 128-value int8 prompt tiles where they beat the default (same bits) [Engine] Inkling 2 on Ampere (RTX 30): use the 128-value int8 prompt kernel where it is faster Nov 24, 2026
@okada-shogo okada-shogo changed the title [Engine] Inkling 2 on Ampere (RTX 30): use the 128-value int8 prompt kernel where it is faster [Engine] Inkling 2 on Ampere (RTX 30): use the Turing int8 prompt tile where it is faster (prompts up to +2.3%, same bits) Nov 24, 2026
@okada-shogo okada-shogo changed the title [Engine] Inkling 2 on Ampere (RTX 30): use the Turing int8 prompt tile where it is faster (prompts up to +2.3%, same bits) [Engine] Inkling 2 on RTX 30: use the faster int8 prompt kernel where it wins Nov 24, 2026
@okada-shogo okada-shogo changed the title [Engine] Inkling 2 on RTX 30: use the faster int8 prompt kernel where it wins [Engine] Inkling 2 on RTX 30: use the faster int8 prompt kernel Nov 24, 2026
okada-shogo and others added 3 commits November 25, 2026 12:45
Registered as a rollback of the 128-value int8 tile stages on Turing.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… they beat the default (same bits)

On a card with 100 KB of shared memory a multiprocessor (the sm_86 pass: RTX 30, and RTX 40 builds without their
own pass) the int8 prompt kernel's 128-row tile also runs one block a multiprocessor. The Turing shapes
(stages of 128, 256 threads, two blocks a multiprocessor) now run there too, for the products where they beat the
launcher's own pick, its raw stage copy included (i8m_amp_shape()): IQ4_NL where the raw copy is not taken (the
experts' downs), IQ2_XXS, NVFP4's downs, Q8_0 in the widest tile up to 1,024 outputs. Each output's terms are added
in the same order: the same bits. STRATA_I8M_AMPERE=<types> sets the types (0: none).

RTX 3090, poly_i8m_shapes_test --ab 7 (medians, against main's pick): IQ4_NL down 965 -> 782 us, IQ2_XXS
1,672 -> 1,451, NVFP4 down 1,012 -> 940, Q8_0 [2304 -> 1024] 80.6 -> 74.0. Prompt tok/s, IQ4_NL, all experts in
VRAM: 2K +2.2%, 8K +2.3%; UD-Q2_K_XL +0.5% / +0.6%.

poly_i8m_shapes_test --ab N: main's pick, the launcher's pick and the new shape forced on, interleaved with the
order turning every round; medians and every round.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Registered as a research setting (the types that take Turing's tile shapes on sm_86).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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