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#5030
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/4380
Author: @moses-sun
Created: 10/28/2026
Status: 🔄 Open
Base:
main← Head:fix/fused-ring-per-cuda-device📝 Commits (1)
5d5e380Prefill: the fused ring's layer check is cached per CUDA device, so a layer split over unlike cards keeps MMQ's buffers where it must📊 Changes
1 file changed (+17 additions, -5 deletions)
View changed files
📝
src/prefill/prefill.cpp(+17 -5)📄 Description
Problem and result
On a
--layer-splitacross cards that do not agree on the fused int8 prompt experts, every prefill chunk >=stream_all_min()failed while short prompts still worked. Four-card rig (2x RTX 5080, 84 SMs; 2x RTX 5070 Ti, 70 SMs;all sm_120), Qwen3.8-Flash-Next GSQ-RCO IQ3_S native pack,
--layer-split 12,25,37,--max-context 524288, engine 0.1.51:The request is refused (HTTP 400) and prompts above about 2K tokens are unusable on that rig. With this commit, same pack,
same split, same flags on engine 0.1.52:
and the string
too smalldoes not occur anywhere in the 24 hours of log around it.Related discussion
#3577 reports the same error at chunk 8192 with IQ3_S on an RTX 5080 + RTX 3060 split. I do not have that rig and did not
reproduce it there; reading the path, the 3060 is sm_86, so its stage is the one without
native_supported()and it wouldhit the same cached decision. It is not marked as fixed here.
The rule this keeps is the one #546 / #958 / #583 established: the MoE buffers may only be shrunk when every layer that
will run in them can take the fused path. That rule is about the card, and the old check answered "which card is current
right now" only once.
Approach
fused_ring()decides whetherfused_layout()shrinks the MoE buffers to the fused path's needs. It askedfused::native_supported()for every layer's format and cached the answer in one function-localstatic const bool.native_supported()is a per-device answer: on CUDA withSTRATA_PF_FUSEDunset it returnsd.ok && d.s120 && d.sms >= 80 && d_covered_on(...)frommoe_fused_iq.cu'sdev_info(), i.e. the card that iscurrent at that moment. On this rig the 5080s (84 SMs) take the fused kernels and the 5070 Tis (70 SMs) do not, so the
first call — on the 5080 stage — shrank the buffers for the whole split, and the 5070 Ti stages then ran MMQ at a full
chunk inside them. Layer 25 is the first layer of the first 5070 Ti stage, which is why that is the layer named in the
error.
The cache is now one entry per device (
0unknown,1every layer covered,2not), keyed on the caller's currentdevice, and read/written as
std::atomic<int8_t>with relaxed ordering: the batch-slot threads readfused_ring()too,and a lost race only recomputes the same per-device answer. A card that can take the fused path still gets the shrink and
its speed-up; a card that cannot keeps MMQ's full-size buffers. No new env var, no change to a homogeneous rig: every
device there answers what the single global used to.
Alternatives considered: the conservative "do not shrink unless every card in the split can take it" is simpler but
throws away the fused path on the 5080 stages of exactly the rigs that have the problem; a per-stage sizing pass would
have to reach the buffer ownership outside this file. If you prefer the conservative form, it is a smaller diff than this
one.
Validation
Passed:
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DSTRATA_ENABLE_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES=120 -DCMAKE_CUDA_COMPILER=/usr/local/cuda-13.1/bin/nvcc -DSTRATA_GGML_DIR=<llama.cpp checkout> -DSTRATA_NATIVE_EXPERTS=ON -DSTRATA_Q6K_EXPERTS=ON -DSTRATA_MMQ_KQUANTS=ON -DSTRATA_MMQ_TQ_OVERLAY=ONthencmake --build build --target strata -j48:the engine links, no warnings from
src/prefill/prefill.cpp.int8_tcache (this branch minus the atomic, which is a relaxedload and store of the same two values) has served that rig since 2026-10-28 00:20 —
2x 5080 + 2x 5070 Ti, IQ3_S native pack,
--layer-split 12,25,37, 512K context,--batch 4 --batch-groups auto --batch-mtp --trim-stage-weights,STRATA_PIPED_MTP=1. Fresh reads of the path that used to fail: 29,486 tokens at3,399.8 tok/s, 29,484 at 3,246.1, 17,441 at 3,134.6 (chunk 8192); decode 170.9 tok/s on a single stream.
grep -c "too small"over the log: 0. Before the change the same rig refused those prompts at chunk 8192, layer 25.Failed:
none observed.
Not run:
std::atomicform under load: the rig's four cards are serving that deployment and I do not restart it for a PR.Say so if you want it run first; the change is the cache type only.
src/prefill/prefill.cppreachescudaGetDevicethroughinclude/strata/hip_compat/cuda_runtime.hon HIP, and the file already callscudaGetDevice/cudaSetDevicethis way(lines 620, 863, 1503), so I expect it to hipify as before, but I did not build it.
untouched.
Limits
fused_ring()is read, which is how this file'sother device queries work (
cudaGetDeviceat line 620 and 1503) and what the rig shows: the fix took effect exactlywhere the error came from. A caller that sizes a stage's buffers without selecting it would still read the wrong
answer.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.