mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #5093] [Engine] CUDA DMA empty-group notification can release staged experts before uploads finish (NaN repro) #2379
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#2379
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 @AlanJager on GitHub (Nov 3, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/5093
Area
[Engine] (CUDA DMA expert staging and completion ordering)
Desktop app, Terminal or source?
Source build.
Strata version
Engine 0.1.56, commit
ffa80d7313(also current main when filing).Graphics card, memory and system
RTX 3090 24GiB (sm_86), 64GiB guest RAM, 32 vCPU Xeon Platinum 8260; Linux 5.15.0-161-generic / KVM, CUDA 12.8, NVIDIA driver 580.126.09. Full model/configuration and measured controls are below.
What happened
Reproduced locally: in explicit CUDA
--pcie-mode dma, a later empty PCIe group can publish a larger cumulativeflagBwhile an earlier group's H2D copy is still in flight. The GPU'sflagB >= ringwait then passes before its expert weights are ready.On an RTX 3090, I captured an expert blob containing a correct current-layer prefix and a stale previous-layer suffix. Both portions were independently matched against the original GGUF. With the captured real activation and the original expert kernel, replaying this blob produces 401 nonfinite outputs; replacing only that expert's weights with the correct blob produces zero. The bad replay is bit-identical to the observed expert output.
Expected: a cumulative completion value implies that all preceding uploads have completed. Actual: the empty-group fast path bypasses that ordering.
Related symptom discussion: #879. This report isolates one CUDA DMA failure mechanism; it does not attribute every failure in #879 to it. Main was rechecked before filing and is still the tested commit below.
Source and ordering
At
Verifier::fetch_dma:The GPU consumes the PCIe expert groups after a
wait_flag_ge. Its implementation spins while*flag < value.raise_flagimplements a monotonic maximum; it does not track gaps in completion.The two-group window schedule intentionally prepares work ahead of consumption. A later plan can therefore be served while an earlier DMA remains pending. Here, empty means zero PCIe expert blobs for this group, not zero preceding work.
Normal: notify through the copy stream
The values 60 and 61 below are completion sequence numbers, not layer numbers.
Failure: empty group publishes outside that stream
Captured bytes explain the first expert NaN
Decisive capture:
pos=96, T=12, step=59, layer=29, group=1. The consumer needs sequence 60, but sees B=61 while this group's completion callback has not run (completion_seen=0).The selected blob is layer 29, expert 222, 1,305,600 bytes, with IQ2_XXS gate/up and Q2_0 down. The correct CPU copy equals the corresponding gate/up/down ranges in the original GGUF in full; SHA256:
The captured staging blob has these independently verified sources (half-open byte ranges):
[0, 1007616)[1007616, 1024000)[1494016, 1510400)[1024000, 1305600)[0, 281600)The previous layer's blobs are 1,510,400 bytes; the current layer's are 1,305,600. Packing each group at its layer's blob stride makes the stale suffix cross two old blobs. Old quantized code bytes are consequently interpreted as current Q2_0 FP16 scale fields. The stale suffix is 297,984 bytes long, with 296,638 bytes differing from the correct target.
Correct gate/up/down scales are all finite. In the snapshot, gate/up scales remain finite, while down has 455 NaN/Inf scale fields in 401 distinct rows. The set of those rows equals the set of nonfinite output rows exactly. The first bad scale is at blob offset
1011354, down row925/block3, FP16 bits0x7db4.Same real activation, same original kernel, A-B-B-A replay
Before expert consumption, a diagnostic snapshots the actual staged blob and its activation/plan. In the freeze arm it redirects only the selected expert to this immutable snapshot; no synthetic bytes are inserted. Replay uses the original
native_expert_grouped, identical Q8_1 input, layout, plan, and grid grouping. Only the selected expert's weight pointer changes.The captured float activation has 15,360 values, all finite (max absolute 2.69835); all 960 Q8_1 FP16 scale/sum fields are finite. The selected expert contributes one planned 2,560-dimensional output row.
A1 equals A2 bitwise. B1 equals B2 and the observed expert output bitwise. The latter three selected output rows share SHA256
4c2f2874ad53cf185283b78e7020e38a4d894bf2e3f34187e12b6c529a046f41.In that window, the first weight mismatch and first nonfinite PCIe expert output are both at step59; resident-expert outputs first become nonfinite at step61. This particular speculative window did not trigger a head-nonfinite request termination: computed candidate rows and accepted output tokens have different coverage. A separate request in the original observation arm did terminate with the engine's
DONE nonfinitelog below.Proposed focused fix
After DMA has been used, enqueue empty-group completion notifications on the same copy stream, behind prior uploads/callbacks. Before any DMA, retain the direct notification fast path.
This uses existing
FlagSetstorage and adds no weight buffer or worker thread. Empty groups after DMA incur one additional host callback and ordered notification latency; CPU submission remains asynchronous.copy_used_is conservative: it means DMA was used since the last drain/reset, not that a copy must still be in flight. The patch below is the locally tested focused candidate; other flag-publication paths still deserve an ordering audit.Minimal candidate patch against the tested commit
Reproduction status and validation
Reproduced locally, timing-dependent. The exact same prompt/seed need not fail on every launch. The frozen expert-residency profile and cache history were held constant across controls.
Environment: source build, engine 0.1.56, commit
ffa80d7313, CUDA 12.8, driver 580.126.09, RTX 3090 24GiB / sm_86, Linux kernel 5.15.0-161-generic in a KVM guest, 64GiB RAM, 32 vCPU Xeon Platinum 8260. Model: Qwen3.8-Flash-Next-GSQ-RCO-IQ2_XS, native GGUF-in-place expert pack, MTPrt, text only, one request at a time. Original arithmetic GPU libraries retain their hashes; diagnostics add sampling/snapshot/finite-check kernels.Shared settings: LOOKAHEAD=0, official rotation=1, tail skip=0, prefill CPU share=0, DMA/PCIe fraction1, pool workers7, prefill2048, context32768/int8 KV, suffix3, lookup-max-t12/MTP-max4, adapt4/96/0.7/async0. Actual expert cache 12756 slots / 17501MiB, arena 17490MiB, official 16 staging slots. PCIe fraction1 is not a claim that all CPU fallback was absent.
Independent ordering litmus
A bounded host callback holds the copy stream before a 1MiB H2D, its completion event, and its normal flag callback. The test then either directly publishes the later empty flag (original) or queues it on that stream (ordered).
cudaEventQueryis checked before releasing the gate. This is a synthetic protocol test, separate from the real-model evidence above.Standalone CUDA ordering litmus source and reproduction command
Save as
ordering_litmus.cpp. Example build command for a Linux CUDA toolkit installation (adjustCUDA_ROOT):The measured litmus execution returned0 and produced the two rows above. This test deliberately holds a stream to expose the protocol ordering; it does not simulate model arithmetic.
Real workload controls
Each diagnostic arm ran nine serial requests: code and Chinese warmups, three code/Chinese pairs capped at512 output tokens, and a code-repair request capped at2048.
The ordered arm never detected a mismatch, so no snapshot pointer redirection occurred there. Sampling checks64 eight-byte locations per expert; finite checks inspect only planned output rows. Instrumentation changes timing: these counts describe the diagnostic run, not production failure rates or throughput.
An earlier unprofiled same-configuration A-B-B-A (28 requests including warmups) compared original DMA against the minimal notification patch: 7/14 versus 0/14 requests ended with nonfinite logits. All four formal original-DMA code requests stopped early; all four patched ones reached512. There is no successful full-length original code baseline for a speedup claim. Earlier full-byte readback on the patched path checked 125171 blobs / 180397721600 bytes, with no mismatch.
Passed: the ordering litmus, independent probe selftest (including ignoring unplanned NaN rows), GGUF byte provenance, original-kernel A-B-B-A replay, and three existing CTests (
exchange_storage_test,file_expert_source_test,nv_defaults_test). Original service/files/source/GPU selector state restored; no new dmesg entries during this diagnostic round. Collected189 evidence files were SHA256-verified after transfer.Observed failures retained: original notification arms have wrong weights/internal nonfinite values; one original diagnostic request ends at the head guard. Other repair-task semantic failures are retained separately and not attributed to this race without a corresponding trace.
Not run: HIP/SYCL execution/build validation of this candidate, other GPUs/models, or a complete root-cause analysis of every #879 symptom. This issue concerns the explicit DMA path. No claim is made that the kernel-copy path has this mechanism.
Relevant log excerpts
Separate original observation request:
Sanitized measured launch arguments and public replay prompts
The following are the engine arguments used in the run; path roles are replaced with variables. Keep a copy of the expert profile and use the same starting profile for each launch. These settings reproduce the tested configuration, not a guaranteed minimal model reproducer.
Send the code request, then the Chinese request as warmups, then repeat that pair three times serially. Wait for
loaded: truebefore sending requests. This is the first eight requests of each recorded arm; the ninth was a separate repair task. Retain failed requests and engine logs. Warm cache/residency history influences whether the race fires.Code request:
Chinese request:
Would this ordering invariant and the focused fix be appropriate for an engine regression test/fix? The full raw model snapshots remain local; the report includes their hashes and byte-source checks rather than uploading model-weight data.
AI-assisted investigation and writing; source paths, captured bytes, replay outputs, and reported measurements were checked against the actual experiment artifacts.
@github-actions[bot] commented on GitHub (Nov 3, 2026):
Thanks for the issue. To keep the tracker readable, every item needs an area prefix in the title and the parts of the issue form filled in. This one is missing:
Edit the issue (title and description) and this note goes away on its own. If it is still missing parts in 5 days it will be closed, which is not a rejection: fix it and comment
/reopen.Details: CONTRIBUTING.md
@github-actions[bot] commented on GitHub (Nov 3, 2026):
Thanks, this follows the format now.