Skip to content

Commit 5b02dc1

Browse files
okada-shogoclaude
andcommitted
poly: Inkling 2's prompt products on Turing's int8 tensor cores by default
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>
1 parent b431bdb commit 5b02dc1

6 files changed

Lines changed: 31 additions & 11 deletions

File tree

‎docs/models/inkling.md‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,20 @@ only part of the experts was not measured. Three runs each, 32 tokens written af
5151
| | 10,081 tokens | 3,340-3,360 tokens/s | 5,360-5,400 tokens/s |
5252
| | 20,162 tokens | 3,390-3,400 tokens/s | 5,480-5,510 tokens/s |
5353

54+
On an RTX 20 card (Turing) the engine multiplies the experts on the int8 tensor cores while it reads a prompt, as
55+
it does on RTX 30 and newer, with the prompt's numbers rounded to 8 bits with a scale for every 32. `--no-prompt-int8`
56+
multiplies them as halves instead (`STRATA_PF_I8MMA=0` turns the int8 products off on every card). Measured on a
57+
Quadro RTX 4000 (8 GB), which holds a third to two thirds of the experts: written after the halves' greedy answers to
58+
three prompts of 302 to 8,192 tokens, 64 tokens each, with three files (the two below and an IQ3_S), it gives the
59+
same most likely token at 560 of the 576 steps. Prompt speed, three runs each:
60+
61+
| Size | Prompt | Halves (`--no-prompt-int8`) | int8 (the default on RTX 20) |
62+
| --- | ---: | ---: | ---: |
63+
| **IQ4_NL** | 2,048 tokens | 329-338 tokens/s | 419-447 tokens/s |
64+
| | 8,192 tokens | 355-361 tokens/s | 456-461 tokens/s |
65+
| **UD-Q2_K_XL** | 2,048 tokens | 361-363 tokens/s | 434-439 tokens/s |
66+
| | 8,192 tokens | 347-348 tokens/s | 411-412 tokens/s |
67+
5468
On a laptop with an RTX 4070 Laptop (8 GB), a Core i7-14700HX and 32 GB of RAM, on Windows, UD-Q3_K_XL has 1,216 of
5569
its 3,072 experts on the card and the rest are computed on the CPU. On a card that does not hold every expert, setup
5670
gives Inkling 2 Mini four settings that read fewer bytes for each token: `--attn-requant q5_0` (the attention's

‎engine/include/strata/kernels/iq_kernels.hpp‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,8 @@ bool gemm_iq_f16_grouped(int ty, const void* W, size_t expert_bytes, int n_out,
211211
/// of Y (row i without ids). With `from`, row i is row from[i] of xq. false: not launched.
212212
bool gemm_iq_i8_takes(int ty, int K);
213213
/// The int8 kernel on Turing (sm_75) too, from now on in this process, by m8n8k16 MMAs: the same sums as on Ampere.
214-
/// Off by default, where Turing's products are the halves' (mmq_own.cu); a model's engine turns it on when asked.
214+
/// Off by default, where Turing's products are the halves' (mmq_own.cu); a model's engine turns it on (Inkling 2
215+
/// does unless --no-prompt-int8).
215216
void gemm_iq_i8_turing(bool on);
216217
void gemm_iq_i8_quantize(const float* x, const int32_t* ids, int64_t ld, int64_t rows, int K, void* xq, void* stream);
217218
bool gemm_iq_i8_grouped(int ty, const void* W, size_t mat_bytes, int n_out, int K, const void* xq, int64_t total_rows,

‎engine/src/poly/engine.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1878,8 +1878,8 @@ std::unique_ptr<Engine> Engine::open(const Options& o) {
18781878
// moe() weighs the picks as a softmax of their scores, which is how only this architecture's router does
18791879
if (o.cache_bias > 0.f && !qwen35)
18801880
throw std::runtime_error("--cache-bias is supported for qwen35moe models; this is a '" + name + "' model");
1881-
if ((!o.attn_requant.empty() || o.loop_bf16 || o.prompt_int8) && name != "inkling2_loop")
1882-
throw std::runtime_error("--attn-requant, --loop-bf16 and --prompt-int8 are Inkling 2's; this is a '" + name + "' model");
1881+
if ((!o.attn_requant.empty() || o.loop_bf16 || o.prompt_int8 >= 0) && name != "inkling2_loop")
1882+
throw std::runtime_error("--attn-requant, --loop-bf16 and --prompt-int8 / --no-prompt-int8 are Inkling 2's; this is a '" + name + "' model");
18831883
if (o.expert_gpu >= 0 && (name != "inkling2_loop" || !o.layer_split.empty()))
18841884
throw std::runtime_error("--expert-gpu is Inkling 2's, on one card beside it (no --layer-split); this is a '" +
18851885
name + "' model");

‎engine/src/poly/engine.hpp‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,9 @@ struct Options {
131131
std::string attn_requant; ///< Inkling 2: its attention's six matrices quantized again to this type at load
132132
///< (q4_0, q5_0 or iq4_nl; --attn-requant); empty: the file's types
133133
bool loop_bf16 = false; ///< Inkling 2: its loop controllers' matrices in BF16, not the file's F32 (--loop-bf16)
134-
bool prompt_int8 = false; ///< Inkling 2: on Turing its prompt products on the int8 tensor cores, as on Ampere
135-
///< (gemm_iq_i8_turing(); --prompt-int8); off: Turing's halves and cuBLAS
134+
int prompt_int8 = -1; ///< Inkling 2: on Turing its prompt products on the int8 tensor cores, as on Ampere
135+
///< (gemm_iq_i8_turing()); -1: the default, on; 1: --prompt-int8; 0: --no-prompt-int8,
136+
///< Turing's halves and cuBLAS
136137
float cache_bias = 0; ///< a token's few-at-a-time routing adds this to the score of each expert in VRAM
137138
///< before it picks its experts; their weights stay the softmax of the scores the
138139
///< router gave (--cache-bias, qwen35moe only); 0: the router's own picks

‎engine/src/poly/inkling2.cpp‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,9 @@ void Inkling2::load_geometry() {
101101
if (attn_type_) guess_type_ = attn_type_;
102102
ctrl_bf16_ = opt_.loop_bf16;
103103
#if !defined(STRATA_GPU_METAL)
104-
// --prompt-int8: Turing's prompt products on the int8 kernel that Ampere and newer take by default (i8_mma.cuh)
105-
if (opt_.prompt_int8) kernels::gemm_iq_i8_turing(true);
104+
// Turing's prompt products on the int8 kernel that Ampere and newer take by default (i8_mma.cuh), unless
105+
// --no-prompt-int8 (STRATA_PF_I8MMA=0 turns the kernel off on every card)
106+
kernels::gemm_iq_i8_turing(opt_.prompt_int8 != 0);
106107
#endif
107108
// --kv fp8: the attention caches in FP8 E4M3 with a scale a row's head, about half the bytes of fp16, as Strata
108109
// v0.2.19's Inkling engine has them on small cards (ink_cuda_backend.cu): at 32K tokens the eight full-attention

‎engine/src/poly/main.cpp‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1721,9 +1721,11 @@ void usage() {
17211721
" or iq4_nl) at load: fewer bytes a token, and the answers move a little\n"
17221722
" (default: the file's types; setup gives an 8 GB card q5_0)\n"
17231723
" --loop-bf16 Inkling 2: its loop controllers' matrices in BF16, not F32\n"
1724-
" --prompt-int8 Inkling 2 on an RTX 20 (Turing): its prompt products on the int8 tensor\n"
1725-
" cores as on RTX 30 and newer, in place of halves and cuBLAS: faster\n"
1726-
" prompts, and the answers move a little (activations int8 a 32 values)\n"
1724+
" --no-prompt-int8 Inkling 2 on an RTX 20 (Turing): its prompt products as halves and cuBLAS,\n"
1725+
" not on the int8 tensor cores as on RTX 30 and newer (the default there\n"
1726+
" too: faster prompts, and the answers move a little, activations int8 a\n"
1727+
" 32 values; --prompt-int8 says the default; STRATA_PF_I8MMA=0 turns the\n"
1728+
" int8 kernel off on every card)\n"
17271729
" --skip-weight F in place of --tail-skip: an expert outside VRAM that every token of a\n"
17281730
" window weighs under F of its experts' weight is left out (default 0 = off)\n"
17291731
" --cache-bias F qwen35moe: a token's router scores get F added for each expert in VRAM\n"
@@ -1851,7 +1853,8 @@ int main(int argc, char** argv) {
18511853
else if (a == "--route-top") o.route_top = std::atoi(val());
18521854
else if (a == "--attn-requant") o.attn_requant = val();
18531855
else if (a == "--loop-bf16") o.loop_bf16 = true;
1854-
else if (a == "--prompt-int8") o.prompt_int8 = true;
1856+
else if (a == "--prompt-int8") o.prompt_int8 = 1;
1857+
else if (a == "--no-prompt-int8") o.prompt_int8 = 0;
18551858
else if (a == "--skip-weight") o.skip_weight = (float) std::atof(val());
18561859
else if (a == "--cache-bias") o.cache_bias = (float) std::atof(val());
18571860
else if (a == "--layer-split") o.layer_split = val();

0 commit comments

Comments
 (0)