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#2934
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/958
Author: @Krypto-Whitehat
Created: 10/5/2026
Status: ❌ Closed
Base:
main← Head:fix/583-fused-layout-per-layer📝 Commits (1)
bb71d44#583: the fused layout shrinks the MoE buffers only when every layer can take the fused path📊 Changes
2 files changed (+60 additions, -2 deletions)
View changed files
📝
src/prefill/prefill.cpp(+31 -1)📝
sycl/src/prefill/prefill.cpp(+29 -1)📄 Description
Fix for #954.
The defect
fused_layout()shrinks a layout'sGU,HandXqto the fused path's sizes, with an MMQ-sized floor forstream_all_min() - 1= 1023 tokens, so that a last sub-1024-token chunk can still run MMQ in them. It decided to do that on:The run loop picks the path per layer (
prefill.cpp:2286):A layer MMQ does not cover keeps the FP16 path, and that path writes the layer's routed rows of the full chunk into exactly those buffers —
m.gemm.f16(..., m.GU + o0 * 1280, ne, 1280, N)overnerows (prefill.cpp:2804), and MMQ likewise atT * Krows intoXq(prefill.cpp:2428). The fused layout holds 1023 tokens of those rows, so at a 16384-token chunk the write runs ~16x past the end: garbage, an illegal access, or a kernel that never returns. The firstck()to reach the sticky error isprefill mmq: iotaa prompt later, which is why the report reads as a hang in the ring rather than as a buffer that was too small.This is the same hole
fused_ring()closes one level up for the native kernels (220e0e8): that one asks "do the fused kernels cover every layer", this asks "do MMQ's", and neither covered both. The shrink is now all-or-nothing over both, and the SYCL mirror matches.Why the ring shows up in the report
The byte-budget ring is not at fault. It moved the chunk (16384 on this rig), and the chunk is what sets how far past the buffer the write runs. That is also consistent with all three control runs on the same binary:
STRATA_PF_FUSED=1(default ring)prefill mmq: iotaSTRATA_PF_FUSED=0(default ring)fused_layout()is false → MMQ-sized buffers → worksSTRATA_PF_FUSED=1+STRATA_RING_BYTES=0It is also consistent with 0.1.37 running the same configuration for ~4,700 requests: its chunk was below the fused layout's 1023-token MMQ floor, or the layer that overflows was not on the prompt path.
What this PR changes
mmq_all()— a new predicate next tommq_plan();fused_layout()requires it instead ofmmq_plan().any. A pack with one layer MMQ does not cover now keeps MMQ's buffers, asfused_ring()already does for the native kernels.m.fused_bufsrecords which layoutcarve()made, and the run loop refuses a layer that would write full-chunk rows into the fused buffers — with the layer and the chunk named, instead of hanging. This is the backstop for anything that drifts between the two decisions later.On a pack where every layer is both MMQ-capable and natively covered (including a homogeneous IQ3_XXS one),
mmq_all() == mmq_plan().anyand the fix changes nothing: no chunk, no loan, no buffer size. On a pack with an odd layer out, the fused layout switches off there, exactly as it already does for the native kernel coverage.Verification — please read, this is not runtime-verified
I do not have a CUDA toolchain or a Blackwell card on the machine this was prepared on, so I could not build
strata_prefill, run the test suite, or reproduce #954. What I did verify:/W4and returns the right answer for every layer vector, exercised in a standalone harness withmmq_all()copied verbatim from the patch: all-MMQ → shrink; one FP16 layer (first, middle, last) → no shrink; no MMQ / no layers → no shrink. That harness confirms the hole directly — with 48 layers and #7 on the FP16 path, the old predicate says shrink and the new one says no.prefill_fused_moe_test/prefill_fused_iq_testdo not cover this: they exercise the kernels with their own buffers and never build a layout, so the ring × fused × layout interaction has no test. I did not add one either —mmq_all()isinlinein an anonymous namespace over a loaded pack, so a test would have to duplicate it rather than call it, which would test the copy.So the overflow mechanism above is established by reading the code, and the guard will name the offending layer on the first run if some other condition is what actually triggers #954 on that rig. The reporter should confirm against their own 0.1.39 build — a 0.1.39 binary with only this patch, same rig. If it still hangs, the new message will say which layer and which chunk, and that is the next thread to pull.
STRATA_RING_BYTES=0remains a valid workaround meanwhile.Not changed on purpose
bytes_needed()prices the loan withfused_layout(T, true)whilecarve()uses the realm.src != nullptr. When a layout is created without an expert source the loan is under-priced, andAlloc::takebounds-checks, so the result is a clean"device buffers ... do not fit"atinitrather than a hang. Loud, not silent, and out of scope here — happy to fix it in a follow-up if you want the two call sites to share one predicate.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.