mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#4776
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/3773
Author: @baptisterajaut
Created: 10/22/2026
Status: 🔄 Open
Base:
main← Head:feat/q36-sampled-mtp-on-3678📝 Commits (3)
8e7742eq36 engine: quantized KV caches behind --kv (int8 / fp8 / rk4v4-e8 q4)8308481fix: q36 fp16 cache skips the quantized staging before the prompt GEMMsea58bfcfeat: q36 MTP drafts for sampled requests behind STRATA_Q36_MTP_SAMPLED📊 Changes
3 files changed (+1233 additions, -74 deletions)
View changed files
📝
docs/QWEN36.md(+7 -1)📝
src/qwen35/q36_engine.cu(+1123 -73)📝
src/qwen35/q36_kernels.cuh(+103 -0)📄 Description
Problem and result
On the q36 path a request with a temperature above 0 or a repeat / frequency / presence penalty decodes one token at a time even with the MTP block loaded (
spec = E.mtp_d > 0 && !smp.needs_logits() && !adm), so the drafts only serve greedy requests. WithSTRATA_Q36_MTP_SAMPLED=1a sampled request alone on the engine gets the speculative steps too, and its text keeps the sampled distribution. Without the variable nothing changes.Stacked on #3678: the first commit is #3678 as it stands (
8e7742e8), the second (83084811) is the fp16 staging fix I posted there (https://github.com/Niko1221/Strata/pull/3678#issuecomment-6349879312, without it the default fp16 cache does not start), and only the last commit (ea58bfcf) is this change. The stack is there because the switch pays only with an attention that reads the cache once per KV head, which #3678 brings for--kv int8; on v0.2.2's attention it loses from 16K on (numbers below).Related discussion
#3354: the server fills in qwen35moe's model-card sampling (temperature 1.0, presence_penalty 1.5) for a request that names none, so served requests report
drafts accepted 0 of 0; with this variable they draft. #3678 (the quantized caches and their GQA decode kernel) and #2464 (q36 decode falling with context).Approach
The drafts stay the MTP block's greedy proposals.
spec_steptakes an optionaldraw(r)callback: row r's token is the request's own sampler over row r's logits, with drafts 0 .. r - 1 appended to the history so the penalties see them, instead of the row's argmax. A draft is kept while the draw equals it and the first draw that differs is the step's token, so every emitted token is a draw of the target distribution: a greedy draft is a point mass, for which the exact-match rule is rejection sampling, asgenerate.cpp:14926already does for its point-mass drafts. Each emitted token costs one draw of the request's rng, so with the slot tables fixed the same seed gives the same text with and without drafts. The serve loop keeps the drawn token across the step (its row's logits are gone) and passes the callback only for sampled requests; greedy requests and the batch window are untouched.Validation
Environment: RTX 3090, 2x Xeon Gold 6226, 64 GB, CUDA 13.2, Debian 12; Qwen3.8-35B-A3B-Distill Q8_0 (empero-ai, with its MTP layer) in hybrid mode (87-95 of 256 experts per layer in VRAM),
--max-context 131072 --mtp 2 --prefill auto(chunk 2048), throughserve.server.Passed:
STRATA_Q36_FIXED_SLOTS=1.--kv int8(1271 of 1680 drafts kept in those answers) and under the fp16 default. Since every emitted token is one draw of the same rng over the same logits, equal texts at equal seeds mean the drafts do not change what is drawn.--kv int8, 60K prompt: 81.1 / 84.9 -> 86.7 / 88.4 tok/s; 2K prompt: 99.3 / 99.9 -> 118.9 / 121.5 tok/s.numactl --interleave=all. In hybrid mode the pinned expert copy lands on whichever node has free pages at load; on this box, whose UPI link runs at half width, the same binary decoded 2-3x slower from one start to the next depending on that placement (numa_maps: 82-86% of the pinned pages on node 1 against 73-81% on node 0). Interleaving puts it at 50/50 in every arm.Failed: none observed.
Not run:
q36_engine.cuis part of the HIP build and I have no AMD toolchain. The change is host C++ in that file, no kernel code.--kv fp8and--kv q4,--batch> 1 (the batch window does not take this path), and thinking-on answers past 1600 tokens.Limits
The variable is process-wide, not per request. It loses at long context wherever decode attention reads the cache once per query head (fp16 cache here, v0.2.2's fp32), so it should go with
--kv int8until that attention shares the KV reads. With the default dynamic slots the verify rows move the experts, so the same seed's text drifts from the one without drafts as rounding does; the chi-square check covers the first verify row only, the accepted drafts rest on the same-seed identity with fixed slots.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.