mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #4969] [Engine] dsv41: the chunked prompt pass DMAs a pinned expert copy from every NUMA part #5271
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#5271
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/4969
Author: @yazun
Created: 11/2/2026
Status: 🔄 Open
Base:
main← Head:fix/dsv41-numa-pinned-dma📝 Commits (1)
36278a0[Engine] dsv41: the chunked prompt pass DMAs a pinned expert copy from every NUMA part📊 Changes
1 file changed (+40 additions, -0 deletions)
View changed files
📝
src/dsv41/ds4_model.cu(+40 -0)📄 Description
Problem and result
On a machine with two NUMA nodes, DeepSeek V4.1 crashed on the first prompt of 96 tokens or more:
The first report came through the server, with a 20,053-token prompt at a 1M context. It also happens with the
engine alone and a 301-token prompt at an 8K context.
Cause. With two NUMA nodes the engine keeps its RAM copy of the CPU lane's experts in two parts. Part X holds
rows
[X n / 2, ..)of each matrix, atcp_lay(ram_to_blobputs them back together). The staging pump andstream_expertread both parts. But the chunked prompt pass DMAs a pinned copy straight from RAM, and it tookevery matrix from part 0 only. So the second half of each gate, up and down matrix came from the wrong bytes.
What that did, in the per-layer dumps (
DS4_DUMP_L) of the old binary:Layers 3 to 7 (all IQ2_XXS) gave wrong but finite values.
Layer 8, the first with an IQ2_S down, gave NaN.
The router of the next layer then read out of bounds. All-NaN scores leave its pick at
0x7fffffff.compute-sanitizer (memcheck) reported:
When it happens. All three must hold:
"copied into RAM (…, 2 NUMA parts)" and "the copied experts pinned … the prompt path DMAs them in place".
ff / 2anddim / 2multiples of 128.Until now the workaround was
DS4_COPY_NUMA=1.After this change the crash is gone. The two-part run gives the same prompt pass as the one-part run (below).
The one-part path is unchanged.
Related discussion
None needed. This is a focused fix.
route_kernel, from another cause (the Q6_Kdequant staging). There the maintainer said a router change that stops a NaN from becoming an out-of-bounds read
is being tested. That change would turn this crash into wrong output. This PR fixes where the NaN comes from on a
two-node host and leaves the router alone. Strix Halo has one NUMA node, so this bug does not explain the faults
reported there.
ram_part,cp_lay). Its diff does not touch the pinned DMAbranch in
flow_push. If it lands, its band layout would need the same per-part DMA. This PR covers the currenttwo-part layout only.
Approach
flow_push: in copy mode withNH > 1, a pinned item records its copy's slot (Item::cs). It no longer storesthree pointers into part 0, because no single pointer can hold a matrix split over two parts.
dma_parts: copies such an item into its ring slot from both parts. It puts the same bytes in the sameplaces as the one-part path:
[a, b); all rows when alone), cut at the part boundary. One copy perpart that holds some of them.
nm > 1) it copies the member's blocks of every row, with onecudaMemcpy2DAsyncper part.ring_fillevent,n_dmaandstream_bytes.Compatibility:
it.csstays-1and the old code runs unchanged. One part means one NUMA node,DS4_COPY_NUMA=1, experts read from the files, or no pinned copy.branch runs only when
copy_mode && NH > 1. A run also checked it: the new binary with one part gives the same32 tokens as the old binary (below).
947.7 tok/s (two parts vs one, one run each). I make no speed claim.
Validation
Environment:
36278a0c(this branch) onc62d5e3a(main)STRATA_BUILD_DSV41=ON,CMAKE_CUDA_ARCHITECTURES=native(sm_80)Each run used this command, with the one-part and two-part copies chosen by
DS4_COPY_NUMA:Passed:
Build:
cmake --build build-dsv41 --target strata-dsv41(CUDA, sm_80).The crash is gone. One run each:
c62d5e3a)c62d5e3a)The 32 generated tokens:
See the run-to-run note under Limits.
Per-layer prompt residuals (
DS4_DUMP_L). New binary, 301-token prompt, 8K context, four runs (two with onepart, two with two parts):
cmpof the two dumpfiles finds no difference, and neither has NaN.
old binary read wrong rows and layer 8 gave NaN. Differences start at layer 20 (4.8e-7 in 31 of 301 rows) and
grow to 1063 at layer 39.
to 7403 at layer 39.
So two parts differ from one part no more than two one-part runs differ from each other, and one two-part run
matches a one-part run byte for byte. Wrong rows would have given NaN at layer 8.
python -m pytest tests/terminal/test_dsv41_context.py(it readsds4_model.cu): 12 passed, 1 skipped.Failed:
None observed with this change. One existing behaviour is noted under Limits.
Not run:
cudaMemcpyAsyncandcudaMemcpy2DAsync,which this file already uses on the same path. Still unverified.
metal/CMakeLists.txtcompilesds4_model.cu, and its shim defines both calls. AMac is one node, so its default is one part and the old path. Unverified.
ds4_model.cu.nm > 1): I have one GPU. Thenm > 1parts ofdma_partsnever ran (themember's gate and up rows cut at the part boundary, and the down's 2D copy per part).
DS4_COPY_NUMA=2on a one-node machine: not run. From reading the code it should reproduce the bug and the fixthere.
NHis capped at 2, so it is the same code path.strata launch/serve) with the fixed engine: not run. Only the engine alone.Limits
Run-to-run differences (existing, cause not found). On this machine the prompt pass is not reproducible bit
for bit between runs, even with one part:
--dump-logits(the window path, which this change does not touch), the logits of the old and newbinaries with one part differ too.
This is why a two-part and a one-part run can pick different tokens after many identical ones. I did not look
for the cause. It is outside this change.
route_kernelstill reads out of bounds when every score is NaN. This PR does not change it (see #4825).🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.