mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #5127] [Engine] DS4_PROF: a chunked prompt overflows the profile's sample array (stack smashing) #5317
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#5317
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/5127
Author: @R-Okauchi
Created: 11/3/2026
Status: 🔄 Open
Base:
main← Head:dsv41-prof-sample📝 Commits (1)
c9cf36aDeepSeek engine: DS4_PROF's chunked prompt fits its sample array again📊 Changes
1 file changed (+5 additions, -3 deletions)
View changed files
📝
src/dsv41/ds4_model.cu(+5 -3)📄 Description
Problem and result
With
DS4_PROF=1and noDS4_PROF_SYNC, a prompt that takes the chunked pass aborted the DeepSeek engine on my DGX Spark:the engine log ended with
*** stack smashing detected ***: terminatedand the server reported exit code -6. Shorter prompts(the windowed path) still ran.
prof_collect()sums each event pair into a localdouble sample_ms[6], but the chunked prompt numbers its stages 0 to 10(
prof_mark(d, 6)..prof_mark(d, 10): attn mHC, attention projections, compressor + indexer, q_b + rope, sparse attention,ffn mHC + router + sort), so stages 6-10 write past the array. A chunk sample then adds only stages 0-3 to
cprof_ms(
stages = chunk_sample ? 4 : 6), so where the overflow does not abort, the finer prompt table prints 0 for stages 4-10 (thispart is from reading the code; I did not see a run get that far).
This came with the collector's rewrite in
29c2d574f8(DeepSeek--parallelfrom Project Maya). In v0.2.9,prof_collect()added each sample straight into
(prof_chunk ? cprof_ms : st.prof_ms)[m.stage], andcprof_mshas 16 entries.Change
sample_msgetscprof_ms's size (16), a mark outside it is not summed, and a chunk sample adds all of its stages tocprof_ms, as before29c2d574f8. A decoded token still adds its 6 stages tost.prof_ms. Only theDS4_PROFpath changes;without it nothing runs differently.
Validation
On a DGX Spark (GB10, driver 580.178.04, CUDA 13.0, Ubuntu 24.04 container), DeepSeek-V4.1-Flash-1017 GSQ-RCO IQ2_XS (ISTA-DASLab's
four-shard layout, packed with
pack_gguf.pyas setup does), standalone runs ofstrata-dsv41 --pack <pack> --ids @<ids> --n <N> --max-context 262144 --eos 1 --vision on --experts 6 --dspark nonewithDS4_UMA_HEADROOM_GIB=12. The prompt is a chat prompt inDeepSeek's format (the one
tools/dsv41/smoke.pybuilds) around 1,308 or 65,095 tokens of plain text.Passed:
Built
strata-dsv41atffa80d7313as released and with this patch, withspark/build_engine.sh's cmake configuration(Release,
-DSTRATA_PORTABLE=ON -DSTRATA_NATIVE_EXPERTS=ON -DSTRATA_Q6K_EXPERTS=ON -DSTRATA_MMQ_KQUANTS=ON,-DCMAKE_CUDA_ARCHITECTURES=121-real;121-virtual) innvidia/cuda:13.0.2-devel-ubuntu24.04(arm64). Both printstrata-dsv41 0.1.56 build ffa80d731; the patchedds4_model.cucompiles with the same two warnings as the unpatched one(#177-D at lines 102 and 106, unrelated) and no new ones.
Unpatched build,
DS4_PROF=1, the 1,308-token prompt,--n 16:*** stack smashing detected ***: terminated,Aborted (core dumped), no token. The release package (0.1.56) did the same underserve/server.py(withDS4_IO_STATS=1as well; the server reported exit code -6).
Patched build, the same command: 16 tokens, exit 0, and the prompt table has every stage:
and the decode line after it:
GPU per token (DS4_PROF): 71.29 ms - between layers 0.04, attention 30.99, routing + shared expert 12.16, experts gate/up 7.43, waiting for the CPU lane 15.67, down + post 5.00.Patched build, the 65,095-token prompt with
--prefill-chunk 8192,--n 16: exit 0, every stage filled (experts incl. waits46,545 ms, sparse attention 20,448 ms, q_b + rope 13,540 ms, ffn mHC + router + sort 11,212 ms, ...).
Metal:
cmake -S metal -B build-metal -G Ninja -DCMAKE_BUILD_TYPE=Releasewith metal-cpp 26 and llama.cpp 3cf03257 (thepins of
.github/workflows/metal-build.yml),cmake --build build-metal --target strata_ds4on macOS 26.4 (SDK 26.5): thepatched
ds4_model.cucompiles andstrata_ds4links, no diagnostics.HIP:
tools/dsv41/build_hip_linux.sh strata-dsv41withSTRATA_HIP_ARCHS=gfx1151inrocm/dev-ubuntu-24.04:7.2.4-complete,as released and with the patch: both link; the patched binary differs;
ds4_model.cuhas 616 warnings in both builds andnone in the changed lines.
Not run:
ds4_model.cu.Limits
Only the profiler's collection. I did not look into why the prompt events were said to hang the driver on gfx1151 Windows
(
prof_chunk = prof_on && !prof_sync_on); if that was this overflow, it would show there too.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.