Repository navigation
[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
Open
okada-shogo wants to merge 2 commits into
okada-shogo wants to merge 2 commits into
Conversation
…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
marked this pull request as ready for review
November 23, 2026 00:38
This was referenced Nov 23, 2026
[Engine] Inkling 2: IQ1_S prompt products on the int8 kernel (opt-in, STRATA_PREFILL_IQ1S=int8)
#250
Open
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>
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
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-int8still 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 runthere, 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
ldmatrixexists from sm_75. So the same kernel now also builds for sm_75. Its integer sumsare 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
--serverequest per run.Prompt speed, tok/s, higher is better, RTX 2070 8 GB, mean of 3 runs:
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:
Each run on the RTX 2070 (tok/s)
Prompt tok/s, higher is better, each run:
Decode tok/s, higher is better, each run:
The same binary with
--no-prompt-int8against 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; expertsin 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):
--no-prompt-int8= main's path)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:
--no-prompt-int8= main's path)--no-prompt-int8= main's path)--no-prompt-int8= main's path)--no-prompt-int8= main's path)--no-prompt-int8= main's path)--no-prompt-int8= main's path)strata-poly --serve --prompt-cache 0 --conversation-cache-mib 0 --max-context 32768 --kv fp16, oneGEN 1request; 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.
the answer (IQ4_NL at step 7, margin 0.35 nats) and the KL after that measures two different texts.
302 rows include run-to-run variation, not only int8 rounding. At 2,048 and 8,192 tokens both repeat bit for bit.
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-int8is given. Main'sSTRATA_PF_I8MMA=0is checked first, so it turns the kernel off on Turing too.(main's default). HIP is unchanged (
gemm_iq_i8_turingis an empty stub there).cp.async, Ampere only) stays off on sm_75; the weights are read through registers as for theother types.
poly_mmq_paths_testandpoly_mmq_k32_testtake--turing-int8(ctest*_turing_int8).Validation
Passed:
e2e-ab.sh(main and this PRinterleaved, 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 buildsCUDA 12.9
75;86).poly_mmq_paths_testPASS,poly_mmq_paths_test --turing-int8PASS,poly_mmq_k32_test --turing-int8PASS (40 cases),compute-sanitizer --tool memcheck poly_mmq_k32_test --turing-int8: 0 errors.top 20: identical at 2,048 and 8,192 tokens (302: differ, run-to-run variation, see Accuracy).
h2h/i8-i8a/progress.log).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:
--prompt-int8; the newbinary with
--prompt-int8= the same.--no-prompt-int8= main d1f711e's default (halves + cuBLAS);STRATA_PF_I8MMA=0= main too.75;86, at 5b02dc1:strata-poly,poly_mmq_paths_test,poly_mmq_k32_test;--helpshows--no-prompt-int8.i8_mma.cuis identical to main's (cuobjdump -sassdiff).gfx1201;gfx1100),strata-polyat [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) withb681c69 ([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:
Limits
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-int8orSTRATA_PF_I8MMA=0turns it off.412 B of spill stores).
tools/check_cuda_spills.pyreports 27 new sm_75i8m_kernelentries (main already failsthat 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