mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #4708] [Engine] Qwen3.6 warmup writes past KV cache at context=prompt chunk=2048 #2156
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#2156
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 @rrp1696 on GitHub (Oct 30, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/4708
Problem and result
The Qwen3.6 engine (
strata-q36, engine build 0.1.54) reproducibly fails during startup warmup on a Colab Tesla T4 with--context 2048and a 2048-token prompt chunk. The surfaced error iscudaMemcpyAsync(...): an illegal memory access was encountered(originalq36_engine.cu:2288), but Compute Sanitizer traces the first invalid global write tok_attn_prep, called duringEngine::warmup().Reproduced on real hardware. A two-change source patch bounded the initial warmup input by the configured context and reset the sequence position before the smaller GEMM/decode/speculative probes. On the same T4 and original model/settings, the patched engine started with warmup enabled, completed 3/3 identical Japanese inference requests, and finished a separate startup/warmup Compute Sanitizer test with zero errors. This is a locally tested patch, not a claim about an official release.
Environment
870aedd9e1ebe1c91f94da93b59af17729f6c5c0.Minimal reproduction and workaround
With the specified model installed, run on the T4/High-RAM environment:
Observed, unmodified release: startup fails with an illegal CUDA memory access.
CUDA_LAUNCH_BLOCKING=1moves the reported failure earlier into the attention/GEMM path, but does not by itself identify the first bad kernel.Control with the same model and settings: append
--set no-warmup=onto the command. The unmodified engine then started and answered 3/3 requests correctly. That is a diagnostic workaround, not the proposed permanent fix.Root cause
In
src/qwen35/q36_engine.cu,Engine::warmup(), the firstprocess()takestmaxtokens. Withctx = tmax = 2048, this fills KV positions 0–2047. The subsequentprocess(..., kGemmT + 1, ...)adds nine tokens without resetting the position. The first added positions are 2048–2056, outside the allocated context.Under Compute Sanitizer, the first reported invalid write is in
k_attn_prep, not in the latercudaMemcpyAsyncthat first surfaced the asynchronous CUDA failure. The reported address was 7,425 bytes after the last valid byte of a 4,194,304-byte KV allocation; this matches the model's attention dimensions and the offending position/head/thread index.Focused proposed source change
The essential change for
ctx == tmax == 2048is thereset()between the initial full prompt and the subsequent warmup probes; limiting the initial token count alone does not resolve the observed overflow. The patch does not modify MMQ, expert routing/copies, model weights, or request-time context handling.Real-hardware validation
CUDA_LAUNCH_BLOCKING=1--set no-warmup=oncompute-sanitizer --tool memcheckk_attn_prep; exit 9925; normal-run CUDA error logs 0ERROR SUMMARY: 0 errors; exit 0 (separate from three-question test)All three regular inference requests used
5の二乗はいくつですか。数字だけで答えてください。with temperature 0, and ended withfinish_reason=stop. The patched engine's measured native decode rates were 35.1, 51.4 and 51.5 tokens/s (short-question test only); peak observed GPU use was 14,359 MiB. These timings are not a controlled claim of a general performance improvement.Reproduction status and limits
The patch and minimal, sanitized evidence summary are available for maintainer review; I can provide the relevant raw diagnostic excerpts after reviewing them for secrets/private paths. No private application data is needed to reproduce this defect.
@Niko1221 commented on GitHub (Oct 31, 2026):
Fixed in 0.2.9. Your analysis was right: the warm-up now only fills the cells that exist and starts its later steps from a clean state. We ran your case (context 2048, chunk 2048) on an RTX A4000 with a Qwen3.6-35B-A3B file. The 0.2.8 engine crashed at start; the new one starts and answers, and three test answers match 0.2.8 word for word. We couldn't run it on a T4, so please comment here if yours still has trouble.
@rrp1696 commented on GitHub (Oct 31, 2026):
Thank you for the quick fix and for confirming the root cause on the RTX A4000. It's great to see the fix included in 0.2.9!
For clarity, my locally patched engine passed on a Colab T4 with context 2048 / chunk 2048: all three test requests returned the expected answer, and a separate Compute Sanitizer startup/warmup run reported 0 errors.
I haven't tested the official 0.2.9 build on the T4 yet, so I can't confirm that release on T4. If I encounter any issues with it, I'll report them here.
Thanks again for addressing this so quickly!