mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-05 07:48:45 +00:00
[Engine] MTP drafter prompt pass: FP16 GEMMs by default instead of Q8_0 MMQ
The batched prompt pass of the MTP drafter (E-9, Prefill::draft_kv) now runs
its four Q8_0 projections through Gemm::native (dequantize + cuBLAS /
hipBLAS) by default, our own code instead of llama.cpp's MMQ.
STRATA_MTP_BATCH_F16=0 keeps the Q8_1 x Q8_0 MMQ form until MMQ leaves the
build. SYCL unchanged (no MMQ there). Host code only.
RTX PRO 5000 (sm_120), Qwen3.8 IQ3_S, --draft mtp --spec 4, 5 rotated
rounds, fresh engine per arm and round. 20 decode prompts (DF-WS held-out
9-12 of each class), greedy, 300 tokens; FP16 / MMQ by class:
class prompt ms (MMQ / FP16) decode tok/s (MMQ / FP16) ratio acceptance (MMQ / FP16)
code 420.9 / 421.9 225.5 / 225.8 1.000 0.7582 / 0.7606
json 613.8 / 613.9 270.5 / 270.9 1.000 0.8091 / 0.8077
tool 1190.8 / 1188.4 314.0 / 313.0 0.995 0.9526 / 0.9378
agent 1842.5 / 1839.7 244.2 / 245.1 1.000 0.7544 / 0.7565
chat 449.0 / 449.1 220.8 / 220.2 0.993 0.6410 / 0.6345
all 4518.2 / 4513.6 240.8 / 240.8 0.999 0.7470 / 0.7447
Generated tokens identical in 100 of 100 requests (and each arm against its
own first round). Every engine took the batched pass (38 chunks each).
Long prompts, prompt tok/s MMQ / FP16 (ratio median [min-max]):
2K 4031.1 / 4022.4 1.000 [0.998-1.003]
8K 5323.9 / 5308.8 1.000 [0.989-1.002]
20K 5602.7 / 5583.4 0.999 [0.996-1.007]
Device code base 9bef5255d vs this commit (sm_120, CUDA 13.2, same tree):
strata 3,596 / 3,596 functions, 0 differing; libstrata_kq.so 256 / 256,
0 differing. Settings register: STRATA_MTP_BATCH_F16 default on, rollback.
This commit is contained in:
1 parent
9bef5255df
commit
5a9d6f5599
2 files changed
+10
-7
No files matched your search
@@ -21670,7 +21670,7 @@
|
||||
"reads": [
|
||||
{
|
||||
"file": "src/prefill/prefill.cpp",
|
||||
"line": 2313,
|
||||
"line": 2319,
|
||||
"backend": "cuda-hip",
|
||||
"fn": "getenv"
|
||||
},
|
||||
@@ -21682,7 +21682,7 @@
|
||||
}
|
||||
],
|
||||
"parse": "flag",
|
||||
"default_state": "off",
|
||||
"default_state": "on",
|
||||
"code_default": null,
|
||||
"engine_sets": [],
|
||||
"engine_defaults": [],
|
||||
@@ -21695,9 +21695,9 @@
|
||||
"since": "v0.1.40.1",
|
||||
"last_commit": "b88eff688b",
|
||||
"last_date": "2026-09-30",
|
||||
"status": "research",
|
||||
"status": "rollback",
|
||||
"owner": "prefill",
|
||||
"note": "[auto] off unless set, not documented for users",
|
||||
"note": "[reviewed] CUDA / HIP: on unless set to 0 (src/prefill/prefill.cpp:2319, the MTP drafter's prompt pass on FP16 GEMMs instead of Q8_0 MMQ; =0 is MMQ's form until MMQ leaves the build); SYCL: off unless set to 1 (no MMQ there). Not documented for users",
|
||||
"retire_after": "",
|
||||
"retired_in": ""
|
||||
},
|
||||
|
||||
@@ -2311,9 +2311,12 @@ bool Prefill::draft_kv(core::MtpDrafter& mtp, const float* R_rows, const int32_t
|
||||
if (r0 >= n) return true;
|
||||
// per row: emb/e2 (N), en16 (N half), hn/h2/Rm/gated (HCN), hn16/xn16 (HCN half), lo (LR) + lo16, grs, mixed (N) +
|
||||
// mixed_h, K and V (KV each), the token id
|
||||
// E-9: the drafter's Q8_0 matrices through Q8_1 x Q8_0 MMQ - its own pass's integer dot products (mmvq), so
|
||||
// its K/V stay close to what the drafter computes itself; STRATA_MTP_BATCH_F16=1: FP16 GEMMs (the A/B)
|
||||
static const bool f16_only = [] { const char* v = std::getenv("STRATA_MTP_BATCH_F16"); return v && v[0] == '1'; }();
|
||||
// E-9: the drafter's Q8_0 matrices through FP16 GEMMs (Gemm::native: dequantize + cuBLAS / hipBLAS), our own code
|
||||
// instead of llama.cpp's MMQ. Measured on an RTX PRO 5000 (IQ3_S, 5 rounds, 20 decode prompts of five classes, lane
|
||||
// P4-FALLBACK 11-11): the same tokens in 100 of 100 requests, prompt time 1.001 of MMQ's form, decode 0.993-1.000 by
|
||||
// class, acceptance 0.7447 against 0.7470. STRATA_MTP_BATCH_F16=0: the Q8_1 x Q8_0 MMQ form (as the drafter's own
|
||||
// integer dot products, mmvq), kept until MMQ leaves the build.
|
||||
static const bool f16_only = [] { const char* v = std::getenv("STRATA_MTP_BATCH_F16"); return v == nullptr || v[0] != '0'; }();
|
||||
const bool q8 = !f16_only && mmq::built() && mmq::fits(kQ8_0, Nn) && mmq::fits(kQ8_0, KV); // #420
|
||||
const uint64_t per_row = 4 * (2 * Nn + 4 * HCN + LR + HC + Nn + 2 * KV + 1) + 2 * (Nn + 2 * HCN + LR + Nn) + 64 +
|
||||
(q8 ? (uint64_t) mmq::q8_bytes(g.hc, Nn) + 4 * g.hc : 0);
|
||||
|
||||
Reference in new issue
Block a user