mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #4335] [Engine] q36: a 4096-token prompt chunk in the hybrid mode when the card has room #5012
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#5012
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/4335
Author: @rynwang
Created: 10/27/2026
Status: 🔄 Open
Base:
main← Head:q36-hybrid-chunk-4096📝 Commits (1)
61caa0dq36: a 4096-token prompt chunk in the hybrid mode when the card has room📊 Changes
2 files changed (+34 additions, -16 deletions)
View changed files
📝
docs/QWEN36.md(+11 -7)📝
src/qwen35/q36_engine.cu(+23 -9)📄 Description
Scope question is in #4332 (this changes a default, and CONTRIBUTING.md asks for agreement first). Happy to turn it
into an opt-in or move the boundary on request, and
STRATA_Q36_CHUNK=2048gives today's chunk either way.The change itself is one block in the hybrid branch of the chunk rule plus the prompt-chunk section of
docs/QWEN36.md.Problem and result
With Qwen3.6-35B-A3B-UD-Q4_K_XL on a 16 GB card, the q36 engine's hybrid mode picks the prompt chunk with a fixed
rule (2048 above 7.5 GiB free, 1024 above 5.5, else 512) and never tries 4096. A prompt chunk streams every layer's
experts over PCIe once, so a 4096-token prompt pays that cost per chunk, not per token. Measuring the two arms on the
same binary (RTX 4080 SUPER 16 GB, WSL2, i7-14700KF, engine 0.1.54 at
870aedd, CUDA 12.4,--mtp 2, threealternating runs per arm, medians):
So: prompt reading 51% faster at 8K context, 76% faster at 32K (4.9 s -> 3.2 s and 5.3 s -> 2.9 s for a 4096-token
prompt), and 64% faster at 16K with an 8,192-token prompt (10.4 s -> 5.6 s); decode unchanged at 8K, and 4-6%
faster at 32K/16K, where the MTP drafts were accepted more often.
Approach
In the hybrid branch, take 4096 when the chunk's buffers fit in a third of the room the expert slots keep at a
512-token chunk; otherwise keep today's rule:
cells.
41 experts per layer), which is the arm 0.1.52 runs today.
13% decode loss for 4096 on an RTX 3060.
--batchkeeps the smaller chunk (the 4096 arm runs only with one slot).The diff is the rule, its comment, and the prompt-chunk section of docs/QWEN36.md.
Validation
Passed (RTX 4080 SUPER 16 GB, WSL2 Ubuntu 22.04, driver 581.80, CUDA 12.4 build for sm_89 + sm_61):
mainat5e8a4ccwith and without the change; the same binary with--chunk 2048and with the new rule,three alternating runs per arm at 8192 and 32768 cells (table above).
STRATA_Q36_PLACE_DEBUG=1shows theinputs: free 11.50 GiB, raw 9.72, experts 18.29 GiB).
its free VRAM is below 7.5 GiB, so the rule picks 1024 as before and the new arm does not apply (23 experts per
layer, 34 tok/s decode; that card is not used in the numbers above).
ctestwith-DSTRATA_BUILD_TESTS=ONon this build (sm_61 + sm_89, CUDA 12.4): 201 of 205 pass. The 4 failures areenvironment/build-configuration ones, none in code this change touches —
ple_parity(the Qwen3.8 PLE shard fixtureis not on this machine),
platform_memory_test(a host-memory heuristic sized for a larger guest than this 24 GBWSL one),
isa_guard_check(an AVX-512 function is not on this build's allowlist) andcuda_spill_guard(thestack-use allowlist does not cover sm_61/sm_89 with this toolkit).
Not run:
the docs, not a measurement.
strata::qwen35::run).--batch/ parallel requests beyond compiling thebatch > 1guard.Independent validation (from the comments)
the PR binary. A 16,385-token input reads 1.30x faster (7,165 -> 5,503 ms, 5/5 pairs); a 1,025-token input is one
chunk either way, so prefill is identical (809.1 against 808.5 ms) and the generation pays ~3% for the 13 slots
4096 costs there. Same-chunk logits against
mainare bitwise equal, and the auto rule equalsmainwith anexplicit
--chunk 4096.Limits
is the difference docs/QWEN36.md already describes for every chunk size except 512; the change does not touch
kernels, routing, precision or the KV cache.
it moved +4.6% here, but I would not quote that as a decode improvement.
Fixes #4332 once the scope is agreed.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.