[PR #5096] [CLOSED] [Engine] Order empty DMA notifications behind pending uploads #5307

Closed
opened 2026-11-07 16:34:14 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/5096
Author: @AlanJager
Created: 11/3/2026
Status: ❌ Closed

Base: main ← Head: fix/dma-empty-completion-order-5093


📝 Commits (1)

  • 47068bd Engine: order empty DMA completion notifications behind uploads

📊 Changes

1 file changed (+18 additions, -1 deletions)

View changed files

📝 src/core/verify.cpp (+18 -1)

📄 Description

Problem and result

In CUDA DMA split windows, a later group with zero PCIe experts can directly raise cumulative flagB past an earlier group's in-flight upload. The earlier GPU consumer's flagB >= ring wait then passes before its staging weights are ready. This patch queues that empty-group notification on the copy stream after DMA has been used, preserving upload/completion order.

Fixes https://github.com/Niko1221/Strata/issues/5093. That issue contains source-linked timing diagrams, a standalone ordering litmus, real-weight provenance checks, and the captured-input replay evidence. Its scope is this explicit DMA mechanism, not every symptom in #879.

Change and cost

Only Verifier::fetch_dma() changes. The pre-DMA direct-notification fast path stays; after DMA has been used, empty notifications use the existing FlagSet storage and copy_ stream. Callback submission failure ends the run rather than publishing a false completion. No additional expert buffer or worker thread is introduced, and expert arithmetic kernels are unchanged.

The cost is an additional queued host callback for empty groups after DMA, and notification latency behind earlier uploads. copy_used_ is conservative: it records use since the last drain/reset, not necessarily a currently pending copy.

Validation actually performed

Tested base: ffa80d73133ea5c548aefe57889a16e8085a938f (engine0.1.56), still upstream main when preparing this PR. RTX3090 24GiB/sm_86, CUDA12.8, driver580.126.09, Linux5.15/KVM, 64GiB RAM, 32 vCPU Xeon Platinum8260; Qwen3.8-Flash-Next-GSQ-RCO-IQ2_XS native pack. LOOKAHEAD=0, official rotation=1, tail skip=0, DMA/PCIe fraction1, lookupT12/MTP4, workers7, prefill2048, context32768/int8KV, official16 staging slots. Shared actual cache12756 slots/17501MiB, arena17490MiB. CPU fallback was not asserted to be zero.

The verify.cpp in this PR is byte-identical to the earlier GPU-tested candidate, SHA256 e7855cf96947eaf45134ad37a180a97b6f15e12bea74525e78b3596cb6c0e2ec. Release comparison replaced only verify.cpp.o; original GPU/other libraries retained their hashes. The PR adds no diagnostic instrumentation.

Check Original notifications Ordered empty notifications
Uninstrumented same-configuration A-B-B-A, including warmups 7/14 requests ended with nonfinite logits 0/14
Four formal code requests, 512-token cap All four stopped early:376/468/510/363 tokens All four reached512
Patched full-byte staging readback — 125171 blobs /180397721600 bytes, zero mismatch across9 requests/9 wide windows
Independent bounded stream-order litmus Later flag already2 while copy event NotReady Flag remains0 until stream drains, then2

Additional passed checks:

  • Three existing CTests: ctest --test-dir "$BUILD" -R '^(exchange_storage_test|file_expert_source_test|nv_defaults_test)$' --output-on-failure, 3/3 passed in the CUDA build.
  • A separate27-request diagnostic round: original observation/original snapshot-freeze/ordered control observed13/12/11 wide windows, with5/3/0 weight-sample mismatch windows and2/1/0 expert-nonfinite windows. The ordered control had no head-nonfinite ending. Probe timing is diagnostic, not throughput evidence.
  • Real activation/original kernel A-B-B-A replay: correct/captured/captured/correct weights produced0/401/401/0 nonfinite outputs. Bad replays matched the observed expert output bitwise. Correct weights matched the original GGUF; the bad suffix matched two previous-layer experts byte-for-byte. Details and hashes are in #5093.
  • Local patch forward/reverse/source-hash checks and git diff --check passed. Original service, source/files and GPU selector state restored after the GPU experiments; no new kernel-log entries during the final diagnostic round.

Observed failures and performance limits:

  • The original-DMA failures above are retained. There is no successful full512-token original code baseline for claiming a code speedup. Complete Chinese control throughput was94.01→92.74 token/s (-1.35%, overlapping ranges), with CPU-s/1k tokens17.68→18.82. This is a correctness fix with possible callback overhead, not a demonstrated throughput optimization.
  • Four uninstrumented natural-stop repair tasks scored14/14,14/14,13/14,14/14. The13/14 result was on a patched run and failed the large-number case with OverflowError; it remains a model-output quality failure, with no trace establishing this race as its cause. No general quality improvement is claimed.

Draft: verification still needed

  • HIP and SYCL compilation/execution, other GPUs, other models, and other DMA batching modes were not validated for this patch.
  • No newly integrated repository regression test calls fetch_dma() automatically. The runnable standalone protocol litmus and real-model reproductions are in #5093; a maintainable in-tree regression test remains to be agreed.
  • Forced callback-submission failure, other direct flag-publication paths, and the entire #879 family remain unverified.
  • The candidate has not replaced the daily service binary. These results concern explicit --pcie-mode dma; they do not establish a defect or a speed change in the kernel-copy mode.

AI-assisted investigation and patch preparation; all reported measurements were checked against retained experiment artifacts.


Compound Engineering
Prepared with GPT-6 via Codex.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/5096 **Author:** [@AlanJager](https://github.com/AlanJager) **Created:** 11/3/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/dma-empty-completion-order-5093` --- ### 📝 Commits (1) - [`47068bd`](https://github.com/Niko1221/Strata/commit/47068bdc63d52bdb5596f76583d9919c08ea6be0) Engine: order empty DMA completion notifications behind uploads ### 📊 Changes **1 file changed** (+18 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `src/core/verify.cpp` (+18 -1) </details> ### 📄 Description ## Problem and result In CUDA DMA split windows, a later group with zero PCIe experts can directly raise cumulative `flagB` past an earlier group's in-flight upload. The earlier GPU consumer's `flagB >= ring` wait then passes before its staging weights are ready. This patch queues that empty-group notification on the copy stream after DMA has been used, preserving upload/completion order. Fixes https://github.com/Niko1221/Strata/issues/5093. That issue contains source-linked timing diagrams, a standalone ordering litmus, real-weight provenance checks, and the captured-input replay evidence. Its scope is this explicit DMA mechanism, not every symptom in #879. ## Change and cost Only `Verifier::fetch_dma()` changes. The pre-DMA direct-notification fast path stays; after DMA has been used, empty notifications use the existing `FlagSet` storage and `copy_` stream. Callback submission failure ends the run rather than publishing a false completion. No additional expert buffer or worker thread is introduced, and expert arithmetic kernels are unchanged. The cost is an additional queued host callback for empty groups after DMA, and notification latency behind earlier uploads. `copy_used_` is conservative: it records use since the last drain/reset, not necessarily a currently pending copy. ## Validation actually performed Tested base: `ffa80d73133ea5c548aefe57889a16e8085a938f` (engine0.1.56), still upstream main when preparing this PR. RTX3090 24GiB/sm_86, CUDA12.8, driver580.126.09, Linux5.15/KVM, 64GiB RAM, 32 vCPU Xeon Platinum8260; Qwen3.8-Flash-Next-GSQ-RCO-IQ2_XS native pack. LOOKAHEAD=0, official rotation=1, tail skip=0, DMA/PCIe fraction1, lookupT12/MTP4, workers7, prefill2048, context32768/int8KV, official16 staging slots. Shared actual cache12756 slots/17501MiB, arena17490MiB. CPU fallback was not asserted to be zero. The `verify.cpp` in this PR is byte-identical to the earlier GPU-tested candidate, SHA256 `e7855cf96947eaf45134ad37a180a97b6f15e12bea74525e78b3596cb6c0e2ec`. Release comparison replaced only `verify.cpp.o`; original GPU/other libraries retained their hashes. The PR adds no diagnostic instrumentation. | Check | Original notifications | Ordered empty notifications | | --- | --- | --- | | Uninstrumented same-configuration A-B-B-A, including warmups | 7/14 requests ended with nonfinite logits | 0/14 | | Four formal code requests, 512-token cap | All four stopped early:376/468/510/363 tokens | All four reached512 | | Patched full-byte staging readback | — | 125171 blobs /180397721600 bytes, zero mismatch across9 requests/9 wide windows | | Independent bounded stream-order litmus | Later flag already2 while copy event NotReady | Flag remains0 until stream drains, then2 | Additional passed checks: - Three existing CTests: `ctest --test-dir "$BUILD" -R '^(exchange_storage_test|file_expert_source_test|nv_defaults_test)$' --output-on-failure`, 3/3 passed in the CUDA build. - A separate27-request diagnostic round: original observation/original snapshot-freeze/ordered control observed13/12/11 wide windows, with5/3/0 weight-sample mismatch windows and2/1/0 expert-nonfinite windows. The ordered control had no head-nonfinite ending. Probe timing is diagnostic, not throughput evidence. - Real activation/original kernel A-B-B-A replay: correct/captured/captured/correct weights produced0/401/401/0 nonfinite outputs. Bad replays matched the observed expert output bitwise. Correct weights matched the original GGUF; the bad suffix matched two previous-layer experts byte-for-byte. Details and hashes are in #5093. - Local patch forward/reverse/source-hash checks and `git diff --check` passed. Original service, source/files and GPU selector state restored after the GPU experiments; no new kernel-log entries during the final diagnostic round. Observed failures and performance limits: - The original-DMA failures above are retained. There is no successful full512-token original code baseline for claiming a code speedup. Complete Chinese control throughput was94.01→92.74 token/s (-1.35%, overlapping ranges), with CPU-s/1k tokens17.68→18.82. This is a correctness fix with possible callback overhead, not a demonstrated throughput optimization. - Four uninstrumented natural-stop repair tasks scored14/14,14/14,13/14,14/14. The13/14 result was on a patched run and failed the large-number case with `OverflowError`; it remains a model-output quality failure, with no trace establishing this race as its cause. No general quality improvement is claimed. ## Draft: verification still needed - HIP and SYCL compilation/execution, other GPUs, other models, and other DMA batching modes were not validated for this patch. - No newly integrated repository regression test calls `fetch_dma()` automatically. The runnable standalone protocol litmus and real-model reproductions are in #5093; a maintainable in-tree regression test remains to be agreed. - Forced callback-submission failure, other direct flag-publication paths, and the entire #879 family remain unverified. - The candidate has not replaced the daily service binary. These results concern explicit `--pcie-mode dma`; they do not establish a defect or a speed change in the kernel-copy mode. AI-assisted investigation and patch preparation; all reported measurements were checked against retained experiment artifacts. --- [![Compound Engineering](https://img.shields.io/badge/Compound_Engineering-6366f1)](https://github.com/EveryInc/compound-engineering-plugin) Prepared with GPT-6 via [Codex](https://openai.com/codex/). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 16:34:14 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#5307
No description provided.