Skip to content

[Engine] Inkling 2 on GTX 16: dp4a path for --prompt-int8 - #304

Open
okada-shogo wants to merge 2 commits into
simplexai-labs:mainfrom
okada-shogo:port/gtx16-dp4a
Open

okada-shogo wants to merge 2 commits into
simplexai-labs:mainfrom
okada-shogo:port/gtx16-dp4a

Conversation

@okada-shogo

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

Copy link
Copy Markdown
Contributor

Problem and result

A GeForce GTX 16 card (TU116 / TU117: GTX 1630, 1650, 1660, 1660 SUPER, 1660 Ti) is sm_75 like an RTX 20 card, but it has no tensor cores. The int8 prompt kernel (--prompt-int8, i8_mma.cuh) uses int8 tensor-core instructions (mma.sync m8n8k16). On these cards those instructions run through a slow path, about 10 times slower than dp4a for the same work.

On these cards, this PR computes the same int32 sums with dp4a. The output is bit-identical, and the int8 prompt products are about 3 times faster. With --prompt-int8, an 8,192-token prompt is 18.2% faster on a GTX 1660 Ti.

The engine picks the path at load. Other cards and the default FP16 ("halves") prompt path do not change.

Prompt tok/s, GTX 1660 Ti 6 GB (TU116, i5-9300H), Inkling 2 Mini UD-Q2_K_XL. Mean of 3 warm runs, main and this PR
in turn, the same flags on both sides:

Card Model Measure main this PR alone Change
GTX 1660 Ti 6 GB UD-Q2_K_XL prompt 302, --prompt-int8 24.4 23.8 −2.7%
GTX 1660 Ti 6 GB UD-Q2_K_XL prompt 2,048, --prompt-int8 83.0 90.9 +9.6%
GTX 1660 Ti 6 GB UD-Q2_K_XL prompt 8,192, --prompt-int8 102.1 120.7 +18.2%
GTX 1660 Ti 6 GB UD-Q2_K_XL prompt 2,048, default flags 46.3 48.9 +5.5%
GTX 1660 Ti 6 GB UD-Q2_K_XL prompt 8,192, default flags 52.5 52.6 +0.2%

The default flags run the same code on both sides, so their rows show the noise on this machine. The 302-token prompt is
bound by the laptop CPU's experts, not the GPU.

With the two existing rounding opt-ins, STRATA_PREFILL_NVFP4=w4a8 and STRATA_PREFILL_IQ1S=int8, on both sides,
IQ1_S and NVFP4 also go to the int8 kernel, so to dp4a on these cards. Same build pair, mean of 3 runs:

Card Model Measure main this PR alone Change
GTX 1660 Ti 6 GB UD-Q2_K_XL prompt 2,048, --prompt-int8 + both opt-ins 98.0 133.7 +36.4%
GTX 1660 Ti 6 GB UD-Q2_K_XL prompt 8,192, --prompt-int8 + both opt-ins 130.5 189.0 +44.8%

Against main's default flags (52.5 tok/s at 8,192), that is 3.6 times the prompt speed. It has the opt-ins' rounding.

Decode does not use this kernel: a decode call has fewer than 32 rows. Decode tok/s after 302 tokens, mean of 3 runs:

Card Model Measure main this PR alone Change
GTX 1660 Ti 6 GB UD-Q2_K_XL decode 128 after 302, --prompt-int8 15.13 13.46 −11.1%
GTX 1660 Ti 6 GB UD-Q2_K_XL decode 128 after 302, default flags 13.87 12.82 −7.5%

Both rows move by about the same amount, and the default-flags row runs identical code on both sides. Decode on this machine is bound by the laptop CPU's experts (20-26 ms a token), so these are run-to-run variation. On the RTX 2070 Super
(below), decode is +0.1%.

Each run (tok/s), GTX 1660 Ti
Card Model Measure Build Run 1 Run 2 Run 3
GTX 1660 Ti 6 GB UD-Q2_K_XL prompt 302, --prompt-int8 main 23.5 24.1 25.7
GTX 1660 Ti 6 GB UD-Q2_K_XL prompt 302, --prompt-int8 this PR 23.4 24.4 23.5
GTX 1660 Ti 6 GB UD-Q2_K_XL prompt 2,048, --prompt-int8 main 79.4 78.5 91.0
GTX 1660 Ti 6 GB UD-Q2_K_XL prompt 2,048, --prompt-int8 this PR 89.7 89.3 93.7
GTX 1660 Ti 6 GB UD-Q2_K_XL prompt 8,192, --prompt-int8 main 101.9 98.4 106.0
GTX 1660 Ti 6 GB UD-Q2_K_XL prompt 8,192, --prompt-int8 this PR 120.7 120.1 121.2
GTX 1660 Ti 6 GB UD-Q2_K_XL prompt 2,048, default flags main 45.8 45.8 47.3
GTX 1660 Ti 6 GB UD-Q2_K_XL prompt 2,048, default flags this PR 51.0 49.4 46.2
GTX 1660 Ti 6 GB UD-Q2_K_XL prompt 8,192, default flags main 52.4 52.5 52.5
GTX 1660 Ti 6 GB UD-Q2_K_XL prompt 8,192, default flags this PR 52.6 52.5 52.6
GTX 1660 Ti 6 GB UD-Q2_K_XL prompt 2,048, both opt-ins main 99.7 98.5 95.9
GTX 1660 Ti 6 GB UD-Q2_K_XL prompt 2,048, both opt-ins this PR 141.0 133.9 126.3
GTX 1660 Ti 6 GB UD-Q2_K_XL prompt 8,192, both opt-ins main 130.2 132.0 129.3
GTX 1660 Ti 6 GB UD-Q2_K_XL prompt 8,192, both opt-ins this PR 196.5 187.0 183.4
GTX 1660 Ti 6 GB UD-Q2_K_XL decode after 302, --prompt-int8 main 15.04 15.35 15.00
GTX 1660 Ti 6 GB UD-Q2_K_XL decode after 302, --prompt-int8 this PR 12.90 12.47 15.00
GTX 1660 Ti 6 GB UD-Q2_K_XL decode after 302, default flags main 13.17 13.30 15.13
GTX 1660 Ti 6 GB UD-Q2_K_XL decode after 302, default flags this PR 13.26 12.42 12.79
Where the time goes: GPU profile of an 8,192-token prompt, GTX 1660 Ti (ms)

From the event profiler (STRATA_PROFILE=1, bench-report branch plus this commit), one run each:

ms, 8,192-token prompt halves (default) int8, MMAs int8, dp4a dp4a + both opt-ins
experts on the GPU 103,018 54,057 47,242 22,290
dense products 36,805 9,917 3,057 3,115
attention 7,473 7,489 7,515 7,680
norms, mixes 5,159 5,079 6,254 8,058
everything else 2,973 2,480 3,168 3,553
wall 155,435 79,026 67,239 44,698
tok/s 52.7 103.7 121.8 183.3
  • The dense products are 3.2 times faster by dp4a.
  • The experts are only 13% faster without the opt-ins. Their time is mostly IQ1_S and NVFP4, which stay on the FP16
    HMMA kernel; this PR does not touch them. With the opt-ins they also take dp4a, and the experts fall to 22 s.
  • Uploads are not the limit: the GPU waits 16-56 ms for uploads in every column.

Output identity, experts frozen and capped (900 in VRAM), 302-token prompt, 64 greedy tokens, --top-probs 20:

Card Compared Tokens Top-20 probabilities
GTX 1660 SUPER and GTX 1660 Ti this PR vs main, --prompt-int8 same 64 of 64 byte-identical
GTX 1660 SUPER and GTX 1660 Ti this PR vs this PR with STRATA_I8M_DP4A=0 (tensor-core instructions) same 64 of 64 byte-identical
GTX 1660 SUPER and GTX 1660 Ti this PR vs main, default flags same 64 of 64 byte-identical

The end-to-end gain without the opt-ins is smaller than the kernel's 3 times. In UD-Q2_K_XL, IQ1_S (6 layers) and
NVFP4 (11 layers) are about 32% of the experts' multiply-adds, and they stay on the FP16 kernel unless the opt-ins are set (see the GPU profile above).

Related discussion

Inkling 2 Mini port series (#200); --prompt-int8 on Turing is from main.

Approach

  • Same sums. In i8m_kernel, a new multiply_dp replaces multiply on these cards. Each thread already owns four outputs of an MMA (tensor-core multiply): weight rows g and g + 8, activation rows 2 tg and 2 tg + 1. It reads those rows' int8 codes from the same shared-memory tiles (i8m_lds) and adds the products with dp4a (i8m_dot). The int32 sums are exact either way. The float epilogue is the MMA path's, term for term, in the same order, so every output has the same bits.
  • Who takes it (i8m_dp4a_pick, once per card and process):
    • only Turing's code (sm_75);
    • only a name with "GTX 16", and none of "RTX", "Quadro", "Tesla", "TITAN" (T4 and Quadro RTX have tensor cores);
    • then a probe of a few ms times MMAs against dp4a for the same work, and dp4a is taken only where the MMAs are not faster. If the probe cannot run, the name alone decides.
    • Measured: GTX 1660 SUPER MMAs 1.76 ms vs dp4a 0.19 ms, so it takes dp4a; RTX 2070 0.053 ms vs 0.192 ms, so it
      keeps the MMAs.
  • STRATA_I8M_DP4A=1 forces dp4a on any Turing code (for bit tests on RTX cards); =0 keeps the MMAs.
    STRATA_I8M_DP4A_LOG=1 prints the probe.
  • strata-poly prints one line at load when it takes the path.
  • Not the default. On GTX 16 cards the default stays the FP16 path. Main's own measure of int8 against the halves
    on Turing is 560 of 576 top-1 tokens, 97.2%, under the 97.8% a default change needs. This path has the same bits as
    that int8 path, so the same number applies. I recommend --prompt-int8 for GTX 16 users in the docs, not an
    automatic switch.
  • The idea of int8 tiles in shared memory multiplied with dp4a on cards without int8 tensor cores is llama.cpp / ggml's
    MMQ (ggml-cuda mmq.cuh, its dp4a path). The code here is our own, in i8_mma.cuh's structure.

Validation

Passed:

  • Settings register: STRATA_I8M_DP4A (rollback; =1 is a test switch) and STRATA_I8M_DP4A_LOG (test only) 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_dp4a_test (new): the int8 kernel by dp4a against its MMAs, bit for bit. It covers all 21 types the kernel
    takes (UD-Q2_K_XL's Q2_0, IQ1_S, IQ2_XXS/XS/S, NVFP4, MXFP4; IQ4_NL, Q8_0; the K-quants and others), K = 2,048 and
    1,152, every tile width, 200 and 512 outputs, uneven and empty experts, and scattered rows.
    • GTX 1660 SUPER (3 different Salad machines) and GTX 1660 Ti: 0 of 224 products differ.
    • RTX 2070 and RTX 2070 Super (sm_75, tensor cores), with STRATA_I8M_DP4A=1: 0 of 224 differ, and each card's
      own pick is the MMAs.
  • RTX 2070 and RTX 2070 Super: poly_mmq_k32_test --turing-int8 and poly_mmq_paths_test --turing-int8 pass, both with the card's pick
    and with STRATA_I8M_DP4A=1.
  • GTX 1660 SUPER and GTX 1660 Ti, strata-poly, UD-Q2_K_XL loop file: the identity table above.
    • Run: STRATA_FREEZE_EXPERTS=1 STRATA_GPU_EXPERTS=900 STRATA_POLY_AHEAD=0 strata-poly --tokens <302> --max-new 64 --top-probs 20 --max-context 4096 --expert-swaps 0 --prompt-int8, compared with cmp.
  • RTX 2070 Super 8 GB (the card keeps the MMAs), UD-Q2_K_XL, mean of 3 runs, main vs this PR:
    • --prompt-int8: prompt 302 349.6 vs 354.1 tok/s (+1.3%), prompt 2,048 774.3 vs 773.2 (−0.1%);
    • default flags: prompt 302 273.5 vs 270.7 (−1.0%), prompt 2,048 589.4 vs 587.8 (−0.3%);
    • decode after 302: 48.1 vs 48.2 (+0.1%).
  • Builds: CUDA 12.9, CMAKE_CUDA_ARCHITECTURES=75;86; STRATA_PORTABLE=ON for the GTX 1660 SUPER kernel and
    identity runs and the RTX runs; STRATA_ISA_FLOOR=avx for the GTX 1660 Ti e2e (the same commit).
Kernel time, GTX 1660 SUPER (µs, lower is better; 459 rows over 4 matrices, 512 outputs)
Type K MMAs (µs) dp4a (µs) Speedup
Q2_0 2,048 872 267 3.27x
IQ2_S 2,048 3,342 797 4.19x
IQ2_XXS 2,048 3,386 1,115 3.04x
IQ2_XS 2,048 3,337 1,242 2.69x
IQ1_S 2,048 2,788 750 3.72x
NVFP4 2,048 855 303 2.82x
MXFP4 1,152 1,892 664 2.85x
IQ4_NL 2,048 3,390 1,099 3.09x
Q8_0 2,048 2,339 1,006 2.33x

The absolute times move with that machine's clocks; the ratio is the stable number. Across all cases on the three GTX
1660 SUPER machines the speedup was 1.4x to 4.2x. It is smallest at 10 rows a matrix.

Failed:

  • none observed

Not run:

  • GTX 1650 / TU117 cards and the GTX 1660 (non-SUPER): not tested. The name check covers them.
  • HIP: the new functions have stubs in iq_kernels.cu's HIP block and i8_mma.cu compiles empty there. HIP build not
    run.

Limits

  • Only --prompt-int8 changes. The default FP16 path (HMMA, also slow on these cards) is unchanged.
  • IQ1_S and NVFP4 stay on the FP16 kernel under --prompt-int8 unless their existing rounding opt-ins are set
    (STRATA_PREFILL_IQ1S=int8, STRATA_PREFILL_NVFP4=w4a8). With those set they take this same kernel, by dp4a on
    these cards (both are covered by the bit test; +45% at 8,192 against main with the same opt-ins).
  • The dp4a tiles keep the MMA kernel's shape. A tile shape tuned for dp4a might be faster.

🤖 Generated with Claude Code

…res), same bits

A GeForce GTX 16 (TU116 / TU117) is sm_75 but has no tensor cores: there the int8 kernel's m8n8k16 MMAs
(--prompt-int8, i8_mma.cuh) run slowly, about 10 times the time of dp4a for the same work. On that card the
kernel now makes each MMA's four int32 sums with dp4a, read from the same shared-memory tiles (multiply_dp,
i8m_dot), and adds them into the float sums in the same order. The int32 sums are exact either way, so the
products are the same bits as the MMAs'.

Who takes it (i8m_dp4a_pick, once per card): Turing's code only, a name with "GTX 16" and no RTX / Quadro /
Tesla / TITAN, and a probe that times MMAs against dp4a (dp4a only where the MMAs are not faster; the name
alone if the probe cannot run). STRATA_I8M_DP4A=1 forces dp4a on any Turing code (bit tests on an RTX card),
=0 keeps the MMAs. Other cards and the default (halves) path are unchanged. strata-poly says so at load.

GTX 1660 SUPER: poly_i8m_dp4a_test (new) gives 224 of 224 products the same bits as the MMAs (21 types, K
2048 and 1152, every tile width) and the kernel 1.5-3.5x faster; Inkling 2 Mini UD-Q2_K_XL with frozen
capped experts gives the same tokens and top-20 probabilities as main with --prompt-int8.

The idea of int8 tiles in shared memory multiplied by dp4a on cards without int8 tensor cores is llama.cpp /
ggml's MMQ (ggml-cuda mmq.cuh, its dp4a path); the code here is our own, in i8_mma.cuh's structure.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@okada-shogo okada-shogo changed the title [Engine] Inkling 2: --prompt-int8 on GTX 16 cards by dp4a (no tensor cores), same bits [Engine] Inkling 2 on GTX 16 (no tensor cores): dp4a path for --prompt-int8 Nov 24, 2026
@okada-shogo okada-shogo changed the title [Engine] Inkling 2 on GTX 16 (no tensor cores): dp4a path for --prompt-int8 [Engine] Inkling 2 on GTX 16 (no tensor cores): use dp4a for --prompt-int8 (same bits, 8K prompt +18%) Nov 24, 2026
@okada-shogo okada-shogo changed the title [Engine] Inkling 2 on GTX 16 (no tensor cores): use dp4a for --prompt-int8 (same bits, 8K prompt +18%) [Engine] Inkling 2 on GTX 16: dp4a path for --prompt-int8 Nov 24, 2026
STRATA_I8M_DP4A is a rollback (0) and a test switch (1); _LOG is test only.

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