mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #5030] [CLOSED] [Engine] dsv41: size the dense dequantizer's staging slot by the block, not by Q5_K's span #5291
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#5291
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/5030
Author: @cuzlin226
Created: 11/2/2026
Status: ❌ Closed
Base:
main← Head:fix/dq-rows-q6k-span📝 Commits (1)
e2837e4dsv41: size the dense dequantizer's staging slot by the block, not by Q5_K's span📊 Changes
1 file changed (+14 additions, -3 deletions)
View changed files
📝
src/dsv41/ds4_iq.cu(+14 -3)📄 Description
Problem and result: on a gfx11 device (RX 7900 XTX) a conversation switch could end in
illegal memory accessand a dead request path. The gfx11 default dense dequantizer,dq_rows_kernel<T>, sizes its per-warp shared staging slot for the Q5_K span (44uint4= 704 B) and copieskSpan / 16uint4into it. For Q6_K the span is4 * 210 = 840 B(53uint4), so every warp writes 136 B past its slot — into the next warp's slot, and past the array for the last warp — and the truncatedkSpan / 16(52) also drops the last 8 B of the fourth superblock. The decoded dense Q6_K weights come out as garbage whose FP16 conversion overflows toinf; a GEMM on them returnsNaN, the router's top-k then leaves0x7FFFFFFFin its output (NaN never compares greater), andmoe_sort_kernel<false>readsvs[0x7FFFFFFF], which is a protection fault on ROCm. After this change the same run passes and the dequantized weights contain noinf.Related discussion: Niko1221/Strata#4350 (root cause, probes and the single-variable evidence).
Approach: size the staging slot from the type instead of the Q5_K constant (
kSpanU4 = (kSpan + 15) / 16), index each warp's slot by it, and copy the tail of a span that is not a multiple of 16 bytes by byte instead of reading past the row. The staging path, the decode indexing and every other type's numbers are unchanged: Q2_K 21, Q3_K 28, Q4_K 36, Q5_K 44uint4are what they were, and Q6_K becomes 53. Shared memory per block grows only for Q6_K (8 warps: 5632 -> 6784 B).Validation (engine 0.1.55 tree at
c62d5e3a1, RX 7900 XTX / gfx1100, ROCm 7.2, single card, tp 1, a maya-ds4 pack with Q6_K dense tensors):Passed:
cmake --build build-hip --target strata-dsv41 -j 8(HIP), clean.Passed: the five-request reproduction from #4350 (A x3 chained, one interleaved conversation, then A again with its full history) under three settings —
DS4_DQ_OLDunset (gfx11 default),DS4_DQ_OLD=1(old kernel forced),DS4_DQ_OLD=0(the coalesced kernel). All three finish with noillegal memory access; before the change the first two faulted 5/5.Passed: the dequantized Q6_K block (k=8192, n=5120) is now bit-identical between
DS4_DQ_OLD=1andDS4_DQ_OLD=0(FNV-1a over all 8,388,608 halves =d5cadd2ca2a3e840in both, same first values), so the staged path produces exactly what the coalesced kernel produces. Before the change the same block from the old kernel held 17,920NaNand 558,114infhalves.Not run: a CUDA build. The kernel is HIP-only (
dq_use_old_kernel()returns false elsewhere) and this machine has no CUDA device; the change is inside a template body a CUDA build still compiles, but I did not build it.Not run: gfx1151. Its default is the same kernel (the
gfx11prefix), and #4825 reports amoe_sort_kernel<false>fault there, so it is the likely second beneficiary; I could not test it.Limits: the Q6_K dense-GEMM path is the one that reproduced this — a pack whose dense tensors are Q6_K and whose prompt reaches the chunked dense GEMM. A Q5_K dense tensor uses exactly the 44-
uint4span and keeps its current behavior. Theroute_kernelNaN guard discussed in #4350 is a separate hardening change and is not part of this one.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.