Skip to content

[Engine] Inkling 2: prompt products on Turing's int8 tensor cores by default (--no-prompt-int8 to turn off) - #231

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

okada-shogo wants to merge 2 commits into
simplexai-labs:mainfrom
okada-shogo:port/mmq-int8

Conversation

@okada-shogo

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

Copy link
Copy Markdown

Problem and result

For Turing cards (RTX 20 series and Quadro RTX, sm_75), while Inkling 2 reads a prompt. It runs the prompt's
expert products on Turing's int8 tensor cores, as main already does on Ampere and newer.

Prompt +17% (one slow run; +34% without it) to +49% on 8 GB Turing cards (main vs this PR); decode unchanged.

It is a rounding change (8-bit prompt activations, see Limits) and it is on by default on Turing for Inkling 2.
To turn it off:

  • --no-prompt-int8: Inkling 2 goes back to fp16 and cuBLAS on Turing.
  • STRATA_PF_I8MMA=0 (main's existing switch): turns the int8 kernel off on every card, Turing included.
  • --prompt-int8 still parses and says the default.

What it changes, in plain words: on main, a Turing card multiplies a prompt's quantized expert matrices in fp16:
each matrix is dequantized and given to cuBLAS. Main's int8 kernel (gemm_iq_i8_grouped, i8_mma.cuh) does not run
there, because it uses Ampere's int8 tensor-core instructions (the MMA shapes m16n8k32 and m16n8k16). Turing has the
same instruction in a smaller shape, m8n8k16. One m16n8k32 is four of them and one m16n8k16 is two, on the same
operand registers, and ldmatrix exists from sm_75. So the same kernel now also builds for sm_75. Its integer sums
are equal to Ampere's to the bit.

tok/s, mean of 3 interleaved runs, main d1f711e vs this PR 5b02dc1. RTX 2070 8 GB + Ryzen 7 5800X, fp16 KV,
default settings (no freeze, no profile; experts in VRAM at load: IQ4_NL 937, AD-IQ3_S 1277, UD-Q2_K_XL 2009 of 3072,
the same both ways), one --serve request per run.

Prompt speed, tok/s, higher is better, RTX 2070 8 GB, mean of 3 runs:

Card Model Measure main this PR alone Change
RTX 2070 8 GB IQ4_NL prompt 302 205.5 265.2 +29.1%
RTX 2070 8 GB UD-Q2_K_XL (loop) prompt 302 205.6 270.8 +31.7%
RTX 2070 8 GB AD-IQ3_S prompt 302 211.0 247.5 +17.3%
RTX 2070 8 GB IQ4_NL prompt 2K 420.3 562.5 +33.8%
RTX 2070 8 GB UD-Q2_K_XL (loop) prompt 2K 543.2 692.5 +27.5%
RTX 2070 8 GB AD-IQ3_S prompt 2K 468.0 679.2 +45.1%
RTX 2070 8 GB IQ4_NL prompt 8K 517.3 726.1 +40.4%
RTX 2070 8 GB UD-Q2_K_XL (loop) prompt 8K 535.8 674.3 +25.8%
RTX 2070 8 GB AD-IQ3_S prompt 8K 507.9 758.3 +49.3%

AD-IQ3_S prompt 302, this PR alone: run 2 (178.7 tok/s) was an outlier against 289.2 and 274.5. Without it the
mean is 281.9 tok/s, +33.6% over main; the lowest other row is then +25.8%.

Decode speed, tok/s, higher is better, RTX 2070 8 GB, mean of 3 runs, 256 tokens written:

Card Model Measure main this PR alone Change
RTX 2070 8 GB IQ4_NL decode after 302 40.1 39.9 −0.4%
RTX 2070 8 GB UD-Q2_K_XL (loop) decode after 302 44.9 45.4 +1.2%
RTX 2070 8 GB AD-IQ3_S decode after 302 41.8 41.7 −0.2%
RTX 2070 8 GB IQ4_NL decode after 8K 30.7 30.6 −0.1%
RTX 2070 8 GB UD-Q2_K_XL (loop) decode after 8K 38.5 38.4 −0.3%
RTX 2070 8 GB AD-IQ3_S decode after 8K 36.2 36.0 −0.6%
Each run on the RTX 2070 (tok/s)

Prompt tok/s, higher is better, each run:

Card Model Measure Build Run 1 Run 2 Run 3
RTX 2070 8 GB IQ4_NL prompt 302 main 215.1 198.6 202.8
RTX 2070 8 GB IQ4_NL prompt 302 this PR alone 271.6 262.5 261.6
RTX 2070 8 GB UD-Q2_K_XL (loop) prompt 302 main 205.8 208.1 203.0
RTX 2070 8 GB UD-Q2_K_XL (loop) prompt 302 this PR alone 276.3 262.2 274.0
RTX 2070 8 GB AD-IQ3_S prompt 302 main 209.4 211.7 211.9
RTX 2070 8 GB AD-IQ3_S prompt 302 this PR alone 289.2 178.7 274.5
RTX 2070 8 GB IQ4_NL prompt 2K main 431.1 429.8 400.1
RTX 2070 8 GB IQ4_NL prompt 2K this PR alone 566.4 554.0 567.0
RTX 2070 8 GB UD-Q2_K_XL (loop) prompt 2K main 541.1 547.3 541.2
RTX 2070 8 GB UD-Q2_K_XL (loop) prompt 2K this PR alone 697.3 684.6 695.6
RTX 2070 8 GB AD-IQ3_S prompt 2K main 467.4 470.8 465.7
RTX 2070 8 GB AD-IQ3_S prompt 2K this PR alone 679.2 676.8 681.5
RTX 2070 8 GB IQ4_NL prompt 8K main 517.9 517.7 516.3
RTX 2070 8 GB IQ4_NL prompt 8K this PR alone 727.3 725.9 725.1
RTX 2070 8 GB UD-Q2_K_XL (loop) prompt 8K main 535.8 535.7 535.9
RTX 2070 8 GB UD-Q2_K_XL (loop) prompt 8K this PR alone 674.6 672.7 675.6
RTX 2070 8 GB AD-IQ3_S prompt 8K main 508.0 507.7 507.9
RTX 2070 8 GB AD-IQ3_S prompt 8K this PR alone 757.7 758.7 758.4

Decode tok/s, higher is better, each run:

Card Model Measure Build Run 1 Run 2 Run 3
RTX 2070 8 GB IQ4_NL decode after 302 main 40.2 40.4 39.7
RTX 2070 8 GB IQ4_NL decode after 302 this PR alone 40.6 39.4 39.8
RTX 2070 8 GB UD-Q2_K_XL (loop) decode after 302 main 45.5 44.4 44.7
RTX 2070 8 GB UD-Q2_K_XL (loop) decode after 302 this PR alone 45.5 45.3 45.4
RTX 2070 8 GB AD-IQ3_S decode after 302 main 41.8 42.2 41.4
RTX 2070 8 GB AD-IQ3_S decode after 302 this PR alone 42.1 41.1 41.9
RTX 2070 8 GB IQ4_NL decode after 8K main 30.8 30.7 30.5
RTX 2070 8 GB IQ4_NL decode after 8K this PR alone 30.7 30.6 30.6
RTX 2070 8 GB UD-Q2_K_XL (loop) decode after 8K main 38.5 38.5 38.5
RTX 2070 8 GB UD-Q2_K_XL (loop) decode after 8K this PR alone 38.4 38.4 38.4
RTX 2070 8 GB AD-IQ3_S decode after 8K main 36.2 36.3 36.2
RTX 2070 8 GB AD-IQ3_S decode after 8K this PR alone 36.1 36.1 35.9

The same binary with --no-prompt-int8 against its default, on a Quadro RTX 4000 8 GB:

Prompt speed, tok/s, higher is better, mean of 3 runs (Quadro RTX 4000 8 GB, sm_75, --serve, 1 token written; experts
in VRAM: IQ4_NL 998, UD-Q2_K_XL 2129, AD-IQ3_S 1358 of 3072, the same both ways). "this PR alone" = this PR's build
(int8, default):

Card Model Measure halves (--no-prompt-int8 = main's path) this PR alone Change
Quadro RTX 4000 8 GB IQ4_NL prompt 2K 332.3 429.1 +29.1%
Quadro RTX 4000 8 GB UD-Q2_K_XL (loop) prompt 2K 362.0 436.0 +20.4%
Quadro RTX 4000 8 GB AD-IQ3_S prompt 2K 342.8 480.4 +40.1%
Quadro RTX 4000 8 GB IQ4_NL prompt 8K 356.6 458.0 +28.4%
Quadro RTX 4000 8 GB UD-Q2_K_XL (loop) prompt 8K 347.1 411.4 +18.5%
Quadro RTX 4000 8 GB AD-IQ3_S prompt 8K 340.5 464.3 +36.4%

Accuracy vs the all-FP16 path: same most likely token at 560 of 576 steps (3 files, 302 / 2048 / 8192 tokens, 64
steps each). Table below.

Each run (tok/s)

Prompt tok/s, higher is better, Quadro RTX 4000 8 GB, each run:

Card Model Measure Build Run 1 Run 2 Run 3
Quadro RTX 4000 8 GB IQ4_NL prompt 2K halves (--no-prompt-int8 = main's path) 329.4 337.9 329.6
Quadro RTX 4000 8 GB IQ4_NL prompt 2K this PR alone 421.6 418.8 447.0
Quadro RTX 4000 8 GB UD-Q2_K_XL (loop) prompt 2K halves (--no-prompt-int8 = main's path) 360.7 363.2 362.2
Quadro RTX 4000 8 GB UD-Q2_K_XL (loop) prompt 2K this PR alone 434.6 434.3 439.2
Quadro RTX 4000 8 GB AD-IQ3_S prompt 2K halves (--no-prompt-int8 = main's path) 341.9 344.5 342.1
Quadro RTX 4000 8 GB AD-IQ3_S prompt 2K this PR alone 476.9 474.0 490.4
Quadro RTX 4000 8 GB IQ4_NL prompt 8K halves (--no-prompt-int8 = main's path) 354.5 354.6 360.6
Quadro RTX 4000 8 GB IQ4_NL prompt 8K this PR alone 456.0 461.2 456.8
Quadro RTX 4000 8 GB UD-Q2_K_XL (loop) prompt 8K halves (--no-prompt-int8 = main's path) 346.9 346.9 347.6
Quadro RTX 4000 8 GB UD-Q2_K_XL (loop) prompt 8K this PR alone 411.2 411.7 411.2
Quadro RTX 4000 8 GB AD-IQ3_S prompt 8K halves (--no-prompt-int8 = main's path) 339.6 339.7 342.1
Quadro RTX 4000 8 GB AD-IQ3_S prompt 8K this PR alone 464.0 464.7 464.2

strata-poly --serve --prompt-cache 0 --conversation-cache-mib 0 --max-context 32768 --kv fp16, one GEN 1
request; halves and int8 alternated, order swapped each round. Same binary (b431bdb tree), halves = no flag at that
revision, int8 = --prompt-int8 (now the default).

Accuracy: int8 vs FP16 (KL, top-1, greedy)

The FP16 run writes 64 greedy tokens with the top 20 of every step; the int8 run follows those tokens (--follow)
and its top 20 are compared. "int8 twice" is the int8 run repeated, compared bit for bit. One run per row, Quadro RTX 4000 8 GB (sm_75, Turing),
64 steps per prompt; KL in nats, lower is better; top-1 same, higher is better.

File Prompt (tokens) KL mean (nats) KL max (nats) Top-1 same (of 64 steps) Own greedy tokens first differ at step int8 twice
IQ4_NL 302 2.6e-3 0.046 61 42 differ
IQ4_NL 2,048 0.070 2.77 63 7 same
IQ4_NL 8,192 6e-6 1.8e-4 64 none (identical) same
UD-Q2_K_XL (loop) 302 2.5e-3 0.029 61 63 differ
UD-Q2_K_XL (loop) 2,048 0.120 4.52 63 10 same
UD-Q2_K_XL (loop) 8,192 5e-5 1.2e-3 64 none (identical) same
AD-IQ3_S 302 3.2e-3 0.027 64 none (identical) differ
AD-IQ3_S 2,048 0.50 12.5 56 2 same
AD-IQ3_S 8,192 1.7e-5 5.6e-4 64 none (identical) same
  • The 2,048-token prompt is a known hypersensitive one: step 0 agrees (KL 6e-6 to 5e-4), then one close pick splits
    the answer (IQ4_NL at step 7, margin 0.35 nats) and the KL after that measures two different texts.
  • At 302 tokens two identical int8 runs differ already (and main vs this branch's FP16 path differ there too), so the
    302 rows include run-to-run variation, not only int8 rounding. At 2,048 and 8,192 tokens both repeat bit for bit.
  • No FP16-vs-FP16 KL floor was measured.

Related discussion

Split out of #200, as the maintainer asked there:
#200 (comment)

Independent of the other split PRs (based on main, not stacked). The expert-tiles PR (#234) builds on this one.

Approach

  • gemm_iq_i8_turing() turns the kernel on for sm_75, for the whole process. Inkling 2 calls it at load unless
    --no-prompt-int8 is given. Main's STRATA_PF_I8MMA=0 is checked first, so it turns the kernel off on Turing too.
  • Other model families never call it, so on Turing they keep fp16 and cuBLAS. Ampere and newer (sm_80+) are unchanged
    (main's default). HIP is unchanged (gemm_iq_i8_turing is an empty stub there).
  • The raw stage copy (cp.async, Ampere only) stays off on sm_75; the weights are read through registers as for the
    other types.
  • Covers the types of Inkling 2 Mini's GGUFs: IQ4_NL, Q8_0, IQ3_S, IQ3_XXS, IQ2_*, Q2_0 and the K-quants.
  • poly_mmq_paths_test and poly_mmq_k32_test take --turing-int8 (ctest *_turing_int8).
  • docs/models/inkling.md and the usage text say int8 is the default on RTX 20, with the switch.

Validation

Passed:

  • End-to-end speed, main vs this PR, the first table: RTX 2070 8 GB (Bazzite box), e2e-ab.sh (main and this PR
    interleaved, order reversed every other round, one warm-up; strata-poly --serve --prompt-cache 0 --conversation-cache-mib 0 --kv fp16 --max-context 32768, 302 + 256, 2,048 + 1 and 8,192 + 256 tokens; both builds
    CUDA 12.9 75;86).
  • Kernel tests, Quadro RTX 4000 8 GB (sm_75), CUDA 12.9, b431bdb tree: poly_mmq_paths_test PASS,
    poly_mmq_paths_test --turing-int8 PASS, poly_mmq_k32_test --turing-int8 PASS (40 cases),
    compute-sanitizer --tool memcheck poly_mmq_k32_test --turing-int8: 0 errors.
  • Old default path unchanged, same card: main d1f711e vs this branch without the flag, IQ4_NL, 64 greedy tokens +
    top 20: identical at 2,048 and 8,192 tokens (302: differ, run-to-run variation, see Accuracy).
  • Speed and accuracy above (log h2h/i8-i8a/progress.log).
  • Identity of the new default at HEAD 5b02dc1, sm_75 (IQ4_NL and UD-Q2_K_XL loop, prompts 302 and 2,048, 64 greedy
    tokens + top 20, fp16 KV, frozen cache): token ids and top-20 probabilities byte for byte the same in all 4 cases
    for each pair, and each reference run repeats itself bit for bit:
    • Quadro RTX 4000 8 GB: the new default (no flag) = the old opt-in binary (b431bdb) with --prompt-int8; the new
      binary with --prompt-int8 = the same.
    • A second rented sm_75 card (all experts in VRAM): --no-prompt-int8 = main d1f711e's default (halves + cuBLAS);
      STRATA_PF_I8MMA=0 = main too.
  • CUDA 12.9 build, 75;86, at 5b02dc1: strata-poly, poly_mmq_paths_test, poly_mmq_k32_test; --help shows
    --no-prompt-int8.
  • Earlier independent review: the sm_86 and sm_120 SASS of i8_mma.cu is identical to main's (cuobjdump -sass diff).
  • HIP build (ROCm container, gfx1201;gfx1100), strata-poly at [Engine] Inkling 2: cached prompt experts in one launch per row class on Turing, default-on (STRATA_POLY_EXPERT_TILES=0 to turn off) #234's head 7b4d536 (this PR + expert tiles) with
    b681c69 ([Engine] build Inkling 2's DSpark screen on HIP #206's Inkling 2 HIP fix) on top in a scratch tree: compiles and links.
  • python3 tools/settings_register.py --check: exit 0; python3 tools/test_settings_register.py: OK;
    python3 tools/check --only docs: passed. No new environment variable.

Failed: none observed.

Not run:

  • An RTX 20 card other than the Quadro RTX 4000 for speed.
  • Ampere+ (the default path there is unchanged).

Limits

  • A rounding change (8-bit prompt activations). It is the same class of change as main's default on sm_80+ and as
    PR poly: Inkling 2 Mini (inkling2 / inkling2_loop) #200's llama.cpp MMQ path. It is now on by default for Inkling 2 on Turing; --no-prompt-int8 or
    STRATA_PF_I8MMA=0 turns it off.
  • Turing only (sm_75); sm_70 is not covered.
  • Register spills: the new sm_75 kernel instances spill with CUDA 12.9 (worst: the 128-row, NJ=8 tiles, e.g. Q2_K with
    412 B of spill stores). tools/check_cuda_spills.py reports 27 new sm_75 i8m_kernel entries (main already fails
    that guard with 12.9). Not checked with CUDA 13.x.
  • gemm_iq_i8_turing() is a per-process setting: a later model in the same process keeps the last Inkling 2 setting.

🤖 Generated with Claude Code

…sor cores

On Turing (sm_75) mmq_own.cu multiplies a prompt's quantized matrices as halves: each matrix dequantized and given to
cuBLAS, since gemm_iq_i8_grouped (i8_mma.cuh) needs Ampere's m16n8k32 and m16n8k16 int8 MMAs.  Turing has the int8
MMA as m8n8k16: an m16n8k32 is four of them and an m16n8k16 two, on the same operand registers, and ldmatrix exists
from sm_75.  So the same kernel now also builds for sm_75, with integer sums equal to Ampere's to the bit; the raw
stage copy (cp.async, Ampere only) stays off there, the weights are read through registers as for the other types.

gemm_iq_i8_turing() turns it on for the process.  Inkling 2 does so with --prompt-int8; without it nothing changes on
Turing (main's default, halves and cuBLAS), and on Ampere and newer the kernel is the default already.  The flag is
lossy against Turing's default: the activations are int8 with a scale per 32 values, as on Ampere.  It covers the
types of Inkling 2 Mini's GGUFs: IQ4_NL, Q8_0, IQ3_S, IQ3_XXS, IQ2_*, Q2_0 and the K-quants.

poly_mmq_paths_test and poly_mmq_k32_test take --turing-int8 (ctest *_turing_int8).

Class: lossy (opt-in, Inkling 2 only); the default path is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…fault

The int8 kernel that main takes by default on Ampere and newer (VecSzn's i8_mma.cuh) is now Inkling 2's default on
Turing (sm_75) too.  --no-prompt-int8 keeps Turing's halves and cuBLAS; --prompt-int8 says the default.
STRATA_PF_I8MMA=0, main's switch for the kernel, still turns it off on every card, Turing included, so one switch
covers both.  Other model families, sm_80+ and HIP are unchanged (HIP's gemm_iq_i8_turing is the empty stub).

Options::prompt_int8 is -1 (default), 1 or 0; the explicit flags stay Inkling 2's.

Measured on a Quadro RTX 4000 (8 GB), prompt tok/s (median of 3), halves -> int8: IQ4_NL 330 -> 422 (2K),
355 -> 457 (8K); UD-Q2_K_XL 362 -> 435, 347 -> 411; AD-IQ3_S 342 -> 477, 340 -> 464.  Same most likely token
as the halves' greedy answers at 560 of 576 steps (3 files x 302/2048/8192 tokens x 64).  docs/models/inkling.md
says so.

Class: lossy (rounding only: 8-bit prompt activations, a scale per 32 values), now default on Turing for Inkling 2,
the same class as main's sm_80+ default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@okada-shogo okada-shogo changed the title [Engine] Inkling 2: --prompt-int8, prompt products on Turing's int8 tensor cores [Engine] Inkling 2: prompt products on Turing's int8 tensor cores by default (--no-prompt-int8 to turn off) Nov 23, 2026
@okada-shogo
okada-shogo marked this pull request as ready for review November 23, 2026 00:38
okada-shogo added a commit to okada-shogo/PolyStrata that referenced this pull request Nov 23, 2026
…ng's int8 tensor cores by default (--no-prompt-int8 to turn off)

# Conflicts:
#	engine/src/poly/engine.cpp

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
okada-shogo added a commit to okada-shogo/PolyStrata that referenced this pull request Nov 23, 2026
…n Turing by default (STRATA_POLY_EXPERT_TILES=0 turns it off)

The tiles give the same numbers as the int8 default without them: on an
RTX 2070 8 GB, IQ4_NL and UD-Q2_K_XL, 302 and 2,048 tokens + 64 greedy,
experts frozen, the ids and top-20 lines were the same with them on and
off (12 of 12), and poly_mmq_paths_test --turing-int8 has mul_at() equal
to mul() for every int8 type.  A same-bits change is on by default with
a switch to go back, so they are now on wherever they apply: Inkling 2 on
a Turing card (sm_75) with its int8 prompt products on (not with
--no-prompt-int8 or STRATA_PF_I8MMA=0).  STRATA_POLY_EXPERT_TILES=0 is
exactly simplexai-labs#231's path, a launch a run of slots.  Nothing changes from
Ampere on.

Measured with the flag on against off: +1.8% to +2.5% on prompts on an
RTX 2080 Ti 22 GB with every expert in VRAM (IQ4_NL, AD-IQ3_S; 0% on
UD-Q2_K_XL), and no change on an RTX 2070 8 GB (+0.0% to +0.6% at 2K
and 8K, noise at 302).

The register entry becomes a rollback switch (default on), docs/SETTINGS.md
is regenerated with --docs, the usage text of --no-prompt-int8 and
docs/models/inkling.md say what the default does and how to turn it off.

Class: same (bitwise vs STRATA_POLY_EXPERT_TILES=0), default on.

Co-Authored-By: Claude Opus 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