mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #2464] [Engine] Qwen3.6-35B-A3B decode falls with context (V100: 109 to 14.6 tok/s at 114K on 0.2.0-beta); llama.cpp holds ~90 #1008
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#1008
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?
Originally created by @christopherrobertbrooks-tech on GitHub (Oct 14, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/2464
Area
Engine
Desktop app, Terminal or source?
Source: built from the v0.2.0-beta tag for sm_70 (
-DCMAKE_CUDA_ARCHITECTURES=70 -DSTRATA_EXPERIMENTAL_SM60=ON, CUDA 12.9).What happened
On the Qwen3.6 engine (strata-q36), decode falls steeply as the context fills, with and without MTP drafts, while llama.cpp barely moves on the same card and file. Re-tested on 0.2.0-beta: still the same.
Decode tok/s,
strata-bench-v100/benchmark.py(fresh prompts filled to each size, greedy, 256-token answers, engine/metrics, 3 runs per size, medians):presence_penalty: 0(MTP drafts on)Prefill: 1,169 / 1,734 / 1,795 / 1,607 / 1,360 / 984 / 602 tok/s. The answers are correct; it is only the decode speed.
@kirinriki7777-sys sees the same shape on an L4 (sm_89) in the hybrid mode on 0.2.0-beta (comment below), so it is not Volta-only.
An int8 K/V cache helped a lot on this card: #2698 (
--kv int8, closed in the reset, not merged) decoded 52.5 tok/s at 65,536 vs 17.3 on its base (296b59d), and #3084 (FP16 K/V by default) gave +8% at 65,536. Neither is in 0.2.0-beta: the q36 engine still stores the K/V cache in FP32.Smallest steps or command that reproduce it
./setup.sh --family qwen36 --model UD-Q4_K_XL, then the engine with--native <gguf> --max-context 131072 --prefill auto --mtp 2(setup's config) and any prompt of 16K tokens or more; compare decode with a short prompt.Reproduction status
Reproduced locally on 0.2.0-beta (2026-10-19), and by @kirinriki7777-sys on an NVIDIA L4.
Strata version
0.2.0-beta (
3d1fb48, engine 0.1.45.3)Graphics card, memory and system
Tesla V100-PCIe-32GB (sm_70), i7-13700KF, 16 GB RAM, Linux, CUDA 12.9, driver 580.173.02
Model, size and settings
Qwen3.6-35B-A3B UD-Q4_K_XL (setup's pinned file from unsloth/Qwen3.6-35B-A3B-MTP-GGUF @ 5bc3e238),
--native --max-context 131072 --prefill auto --mtp 2, every routed expert in VRAM (19.31 GiB free after load).Original report (0.1.44)
Tested v0.1.44 (
ed4773e) with Qwen3.6-35B-A3B UD-Q4_K_XL (setup's pinned file from unsloth/Qwen3.6-35B-A3B-MTP-GGUF @ 5bc3e238, SHA-256 checked) on one Tesla V100-PCIe-32GB (i7-13700KF, 16 GB RAM), CUDA 12.9, built with-DSTRATA_EXPERIMENTAL_SM60=ONandlibstrata_kq.sonext to the engine. Config as setup writes it:--native <gguf> --max-context 131072 --prefill auto --mtp 2. Every routed expert fit in VRAM (18.75 GiB, after "the packed Q8_0 decode copies (1.78 GiB) given back"). Greedy, 256-token answers, the same benchmark.py prompts as our other V100 reports, 3 runs per size, medians. Decode tok/s, with time to first token in brackets:--mtp 2--mtp 0(decode)llama.cpp = mainline 5e03bdd built for sm_70,
-ngl 99 -fa on, the identical request bodies (thinking off), streamed.Short prompts are great on this card: MTP drafts are accepted 69% of the time and decode is ~1.7x llama.cpp's. But decode falls with context with and without MTP, while llama.cpp's barely moves, so at 16K Strata decodes ~35% slower than llama.cpp on the same card (it still reads the prompt 2.4x faster). Our guess is the full-attention layers' decode on sm_70, but we haven't profiled it, and we know Volta is experimental. HumanEval (thinking off) was 155/164 in 4.0 min, the same score as our earlier llama.cpp test of this model.
Happy to run variants (
STRATA_Q36_KEEP_PACKED=1, longer contexts) if that helps.@merbanan commented on GitHub (Oct 14, 2026):
Strata only supports Flash next. Try this branch https://github.com/merbanan/project-maya/commits/qwen38/ I am getting ~200 t /s.
@christopherrobertbrooks-tech commented on GitHub (Oct 14, 2026):
Thanks! Strata 0.1.44 does run it: the release notes list Qwen3.6-35B-A3B,
strata --familiesprintsqwen4exp qwen35moe, and the numbers above come from that path (the engine log showsstrata-q36: ... MTP block loadedandevery routed expert in VRAM (18.75 GiB)). Which GPU and model is your ~200 t/s on, and does the qwen38 branch run Qwen3.6-35B-A3B? Its recent commits look like DSv4 MTP work.@merbanan commented on GitHub (Oct 14, 2026):
Sure it can run it because it is based on llama.cpp.
Anyway I use a 32GB V100 and I am doing work on all MoE based models so Qwen3.6-35B-A3B got caught in the crossfire. Qwen3.8 seems to runs at 70+ t/s (which is nice).
@Niko1221 commented on GitHub (Oct 19, 2026):
Thanks for taking the time to report this.
We're resetting the tracker for 0.2.0-beta. There are more than 1,300 open issues and pull requests, too many for us to read properly, so we're closing everything that isn't being worked on right now. Closed here does not mean rejected.
To reopen it takes about two minutes:
/reopen. A check runs and either reopens the issue or lists what is still missing.The rules are in CONTRIBUTING.md.
@kirinriki7777-sys commented on GitHub (Oct 19, 2026):
Re-tested on 0.2.0-beta (
3d1fb48, engine 0.1.45.3): the same decode-vs-context fall on an NVIDIA L4 (sm_89), in the hybrid mode this time.Setup: Google Colab L4 (24 GB VRAM, 53 GB RAM, 12 vCPU Xeon 2.2 GHz), Linux, CUDA 13 engine built by setup.
./setup.sh --family qwen36 --model UD-Q6_K_XL --context 131072 --vision cpu --yes(setup's pinned file from unsloth/Qwen3.6-35B-A3B-MTP-GGUF @ 5bc3e238). The engine line:--native <gguf> --max-context 131072 --prefill auto --mtp 2 --vision;strata-q36: hybrid experts: 60 of 256 per layer in VRAM (6.57 GiB), all 28.03 GiB in pinned host memory, ... on 6 CPU threads;context 131072 cells, prompt chunk 2048, MTP block loaded, 8.97 GiB of VRAM free.What happened: one request at a time, sampled (default sampling of the chat API, so no MTP drafts:
drafts accepted 0 of 0), a document of Python/Markdown source with a question at the end. Decode tok/s from the server's ownsession 0:lines //metrics:Beyond ~16K the time per token grows by about 2.3 ms per 1,000 tokens of context (roughly 1/context).
nvidia-smishowed 97% GPU utilization while decoding at 116K, so it does not look like PCIe waiting. The answers were correct (a passphrase placed once at the start of the 116K document was found).Same box, llama.cpp b11467 (UD-Q4_K_XL from the same repo and revision,
-fit on -ctk q8_0 -ctv q8_0 -fa on --spec-type draft-mtp --spec-draft-n-max 3 -c 262144, same documents): 55.2 / 48.7 / 44.8 / 37.2 tok/s at 16.5K / 35K / 70K / 116K, and 30.5 at 191K. The quantization differs (Q4 there, Q6 here), so this is only a reference for the shape of the curve, not a like-for-like speed comparison.So the V100 report above (full VRAM, 16K) and this one (hybrid, sm_89, up to 116K) show the same pattern on two architectures and both placements. I did not profile the kernels; the guess in the original report (the full-attention layers' decode) fits what I see, but that is not confirmed.
Not tested: UD-Q4_K_XL in Strata on this card, greedy requests with MTP drafts at long context, other context settings than 131072.
@christopherrobertbrooks-tech commented on GitHub (Oct 20, 2026):
Thanks @kirinriki7777-sys for re-testing on an L4: it matches what the V100 shows on 0.2.0-beta. I've updated the description with the 0.2.0-beta numbers.
@christopherrobertbrooks-tech commented on GitHub (Oct 20, 2026):
/reopen
@github-actions[bot] commented on GitHub (Oct 20, 2026):
Reopened, thank you. A maintainer will pick it up from here.
@christopherrobertbrooks-tech commented on GitHub (Oct 20, 2026):
Profiled: the slowdown is
k_attn_part(src/qwen35/q36_engine.cu)Tesla V100-PCIe-32GB, Strata 0.1.45 (q36 engine,
--nativeUD-Q4_K_XL,--prefill auto, no--mtp), temperature 0 with presence and frequency penalty 0. Nsight Systems with the capture limited to the requests; decode-only window (kernels after the last prompt GEMM), 256 written tokens per context.k_attn_part(10 calls)k_attn_merge(10 calls)Untraced, same build: 93.7 / 79.8 / 55.9 tok/s at 1K / 4K / 16K (with
--mtp 2: 134.5 / 110.7 / 58.2). llama.cpp on the same file: 91.7 / 90.5 tok/s at 1K / 16K; its flash-attention kernels take 0.33 / 0.80 ms per token.From the source (unchanged in main
9ae93f7b), three things multiply the bytes read:const float* kc, vc);kvh = h / (H / HKV), so the 8 query heads that share each KV head (H = 16, HKV = 2) each read that head's K and V chunk separately;kp[i], a stride of HD between threads), so the K loads are not coalesced.fp32 K + V for one KV head at 16K is 33.5 MB, larger than the V100's 6 MB L2, so the eight re-reads go to HBM. Scaling 8.71 ms by 114K / 16K gives about 60 ms per token, which matches the 14.6 tok/s at 114K above.
Not tested: other cards (with a larger L2 the re-reads would partly hit cache), and whether
--kv int8changes this engine's path.@christopherrobertbrooks-tech commented on GitHub (Oct 20, 2026):
Follow-up: the same kernel also explains why
--mtpstops helping at long context on this card (134.5 vs 93.7 tok/s at 1K, 58.2 vs 55.9 at 16K). The grid isdim3(nc, nt * H), so verifying a 3-token draft reads every KV chunk once per verified token as well as once per query head; llama.cpp's draft-mtp on the same file keeps a 1.31-1.39x speed-up from 1K to 64K.@kirinriki7777-sys commented on GitHub (Oct 21, 2026):
Another data point for the decode-vs-context fall on the Qwen3.6 engine path, this time with a larger
qwen35moemodel (Ornith-1.5-122B, 32 query / 2 KV heads, 12 full-attention layers + the MTP block; the setup and the patch needed to load it are in #3574). Same L4 box and the same documents as my comment above.--max-context 131072,STRATA_Q8_PACKED=0, 8 expert slots per layer, sampled chat requests (no drafts), decode from the server'ssession 0:lines:Between 18.7K and 83.8K the time per token grows by about 6.0 ms per 1,000 tokens of context (Qwen3.6: about 2.3 ms). The ratio, 2.6, is close to the ratio of query heads x attention layers, (32 x 13) / (16 x 11) = 2.36.
The same model with every expert in VRAM (Colab A100 80 GB, same file, same patch, same documents,
every routed expert in VRAM (44.69 GiB), no CPU pool): 64.0 tok/s on a 2.5K prompt, 35.4 at 18,671, 13.3 at 83,802. Answers were right at both lengths. The growth there is 0.72 ms per 1,000 tokens, 8.3x less than on the L4, close to the ratio of the two cards' memory bandwidth. If every query head reads the fp32 K and V of its cells, 1,000 cells cost 13 layers x 32 heads x 1,000 x 256 x 4 B x 2 = 852 MB per token: that is ~1.18 TB/s on the A100 and ~142 GB/s on the L4, i.e. both cards look bandwidth-bound on these reads.Reading
k_attn_part(src/qwen35/q36_engine.cu), two things look like they would give exactly this shape. I have not profiled the kernel, so please treat this as a reading of the code, not a measurement:T * Hrows) and a block maps its row tokvh = h / (H / HKV), so the 16 query heads of one KV head (8 on Qwen3.6) each read the same K and V. At 84K one layer's fp32 K+V is ~344 MB, far above the L4's 48 MB L2. Doing theH / HKVquery heads of a KV head in one block (load each K row and V row once) would cut the reads by that factor.alloc_sessionusesdallocforkc/vc; setup.py'skv_bytes_per_tokensays "K and V in fp32 (strata-q36)"). The Flash-Next engine takes--kv fp16 / int8 / q4_0 / k8v4. fp16 or q8_0 here would halve or roughly quarter both the bytes read per token and the VRAM: on this model the 128K cache is ~6.5 GiB of a 22.5 GiB card, which is what leaves only 8 expert slots per layer.Also in
k_attn_part, each thread reads one cell's full 256-float K row (kp[i]overi), so neighbouring threads read addresses 1 KB apart; the V loop is laid out across threads.Not tested: a fixed kernel, fp16 KV, other context settings, and whether the L4 answers at 116K were right (my probe's output was lost on that run).
@storm-ace commented on GitHub (Nov 3, 2026):
Another data point, on AMD: the same decode fall on a Strix Halo (Radeon 8060S, gfx1151, Windows), and what the GQA-group read and an FP16 cache give there. The fix itself is the one in #3903; I am not opening a competing PR, these are measurements.
Environment: Ryzen AI MAX+ PRO 395, Radeon 8060S (gfx1151, unified memory, ~200 GB/s), Windows 11, engine 0.1.55 built from
c62d5e3awithtools/hip/build_windows.bat(STRATA_HIP_ARCHS=gfx1151, ROCm 10.2.0a20260930), Qwen3.6-35B-A3B UD-Q4_K_XL, every routed expert in VRAM,--max-context 131072 --prefill auto --mtp 2.The fall (unchanged engine 0.1.55), through the server, salted prompts of
q36_engine.cusource, nothing reused, temperature 0.6 (so no drafts), 300 new tokens, the engine'ssession 0:lines:The same requests after reading each K / V cell once per GQA group (one block per KV head and 256-cell chunk computing its 8 query heads, K staged in LDS and loaded coalesced; same idea as #3903's
--gqa-attn, written independently on storm-ace/Strataq36-strix-halo, commitfbf6976a):Each head keeps
k_attn_part's summation order, soSTRATA_Q36_VERIFY=1 --no-graphon a 2,600-token prompt reported22512 comparisons, 0 mismatches.The MTP verify window (the follow-up above about
dim3(nc, nt * H)): launching the window's rows on the same chunk next to each other (grid(rows, chunks)) so they meet the chunk's cells in cache took sampled decode with drafts at ~36K from 29.1 to 33.2 tok/s (one request each).FP16 K / V cache on top (
--bench-pp 65536 --bench-tg 64, greedy, no drafts; three arms in this order, each a fresh start with 3 repetitions):KL of the FP16 cache against FP32 (1,229-token real-text prompt, 32 teacher-forced steps): 1.9e-6 mean, top-1 32 of 32.
Not run: #3903 / #3678 themselves on this card, other AMD cards, NVIDIA. If it helps the review of #3903, I can run that branch on this Strix Halo with the same requests.
@pdmaclennan-art commented on GitHub (Nov 4, 2026):
Same shape on a Strix Halo laptop under Windows (gfx1151), on the 0.2.10 release (engine 0.1.56,
windows-x86_64-hip-rdna3).Machine: ASUS ProArt PX13, Ryzen AI Max+ 395, Radeon 8060S, 128 GB with a 96 GB BIOS carve-out, Windows 11 build 26300, AMD driver 32.0.22032.6002. Model: Unsloth Qwen3.6-35B-A3B-MTP-GGUF @ 5bc3e238, UD-Q4_K_XL, setup's own settings (
--native <gguf> --max-context 131072 --prefill auto --mtp 2), every routed expert in VRAM (18.75 GiB). The llama.cpp column is halo-box/strix-llama.cpp93e6d0285(gfx1151 ROCm build),-ngl 99 -fa on -b 2048 -ub 2048, on the same file, same day.Fresh prompts, 256 new tokens, temperature 0 with
presence_penalty: 0(so the MTP drafts run), thinking on, one run each. Client-side TTFT s / decode tok/s:--mtp 2--mtp 0The engine's own lines for the MTP run agree: 67.5 / 35.9 / 12.9 / 6.4 tok/s decode, prompt 733 / 591 / 460 / 302 tok/s. Full report, logs and a standard-v1 run: https://github.com/Niko1221/Strata/pull/5182.
For contrast, Flash-Next Q2_0 (setup's settings) on the same machine and harness held 49.3 / 37.3 / 39.5 / 44.2 tok/s decode at 4K / 16K / 32K / 64K, so the fall looks specific to the 35B path here too.
Not profiled here, so I can't say whether
k_attn_partdominates on gfx1151 as on the V100.