[PR #4211] [CLOSED] [Engine] dsv41: a layer split's chunked prompt no longer deadlocks (wait for the other group's flag on the host first) #4952

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

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/4211
Author: @wyxu95
Created: 10/26/2026
Status: ❌ Closed

Base: main ← Head: dsv41-layer-split-host-wait


📝 Commits (1)

  • 8f8bba7 DeepSeek engine: a layer split's chunked prompt no longer deadlocks - the host waits for another group's flag before it queues the device-side wait (2x H100, IST-DAS-2.25bpw)

📊 Changes

1 file changed (+25 additions, -3 deletions)

View changed files

📝 src/dsv41/ds4_model.cu (+25 -3)

📄 Description

Draft PR, not ready for review: the HIP and Windows builds and other GPUs are not run, and the requests below ran
at 7dd5cf18e, not at this branch's base (see Validation).

Problem and result

On a two-GPU layer split, every prompt that takes the chunked prompt path never finished. The engine stopped
answering, and the server's watchdog ended it after 955 s ("the engine said nothing ... during the request").
The layer split comes from the pack: the IST-DAS-2.25bpw (IQ2_XS) experts' 256-value blocks do not split
n_ff 2304, so --tp 2 falls back to whole layers per GPU (tensor parallel 2 -> 1).

  • Before: a fresh 243-token, 1,604-token or 102,045-token prompt never finished. GPU 1 showed 100% utilization
    at about 128 W, and GPU 0 showed 0%. One engine thread was busy. The windowed path (--prefill-chunk 0) worked,
    at about 135 tok/s.
  • After: the chunked path reads prompts at 729-1,561 tok/s, including a 916,468-token prompt, and decode speed
    is unchanged (numbers below).

Related: #4090 shows the same stall on 2x RTX 5090 under WSL2 (intermittent there). This change was not tested
on that machine.

What stalled

Temporary stderr prints (not part of this PR) showed where each device's thread stopped in run_dev_chunks:

  1. Device 1 queued xfer_get for chunk 0's hand-off into layer 19 and for its source rows from layer 14. Then its
    thread called cublasSgemm in hc_mix_chunk (layer 19). The call did not return.
  2. Device 0 read the chunk's Engram rows (34 ms) and queued layer 0's Engram work. Then its thread called
    cublasSgemm in hc_mix_chunk (layer 0). The call did not return, and device 0 queued nothing more.

So device 1's wait kernel spun for a hand-off that device 0 never started. Why a cublasSgemm call blocks while
a wait kernel spins on the same device, and why device 0's call blocks too, is not established here. This part
is inferred, not confirmed: something in the cuBLAS or driver call waits on the device, and the other device's
thread waits behind it.

These did not change the stall (each with a fresh prompt of 243-247 or about 1,600-2,000 tokens): --threads on,
--prefill-chunk 2048, --dspark none (a clean split, layers 0-19 and 20-39 plus the head, every expert in
VRAM), DS4_FLOW=0, --mmap-experts off, CUDA_MODULE_LOADING=EAGER, CUDA_MODULE_LOADING=EAGER with
CUDA_MODULE_DATA_LOADING=EAGER, and a cuBLAS workspace set at handle creation (cublasSetWorkspace, 32 MiB).

Approach

Before the chunk path queues a device-side wait for another group (xfer_get or wait_flags), the host now
polls the same host-mapped flag until it is up. The kernel then finds the flag up and never spins. This covers
the four cross-group waits of the chunk path: the hand-off into a group, the hand-off acknowledgements, the
source rows, and their acknowledgements. host_wait_at_least uses the kernels' test (flag - seq as a signed
difference, so a wrapped counter still works). It yields first, then sleeps 20 us between reads.

  • The data and the order of the GPU work do not change, so the results are the same bits. Only when the host
    queues the waiting group's work changes.
  • A single GPU and a tensor-parallel group do not reach these waits.
  • The window path and decode are unchanged. Their hand-offs did not stall here.

Validation

Environment: 2x NVIDIA H100 80GB HBM3 (NVLink NV18, PCIe 5.0 x16), driver 580.126.09, CUDA 13.0 (nvcc V13.0.88),
Ubuntu 24.04.5 in a container, kernel 6.8.0-100, Xeon Platinum 8480C, 2 TB RAM. Model files are on a network
filesystem (WekaFS). Source 7dd5cf18e (engine 0.1.49.2) plus this patch. Pack IST-DAS-2.25bpw, served through
serve/server.py with gpu [0, 1] and --max-context 1048576 --eos 1 --dspark auto --dspark-conf 0.65.
Every expert sits in VRAM except 274 on the CPU lane.

Build: cmake -S . -B build-dsv41 -G Ninja -DCMAKE_BUILD_TYPE=Release -DSTRATA_ENABLE_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES=90 -DSTRATA_BUILD_TESTS=OFF -DSTRATA_BUILD_DSV41=ON -DSTRATA_NATIVE_EXPERTS=ON, then
cmake --build build-dsv41 --target strata-dsv41.

Passed (patched build, default chunked prompt path; every prompt is fresh text with no prefix reuse). The
rates are the engine's own "read in" figures:

Request Result
1,630-token prompt read in 2.2 s, 729 tok/s
7,850-token prompt read in 9.0 s, 873 tok/s
35,308-token prompt read in 25.0 s, 1,410 tok/s
five ~2K prompts in a row 786-819 tok/s each
102,045-token needle-in-a-haystack (a password at 5% depth) read in 65.4 s (1,561 tok/s), answer correct
916,468-token needle-in-a-haystack prompt read in 707.8 s (1,294.8 tok/s), answer correct; then 93 tok/s decode
decode, 4 different prompts of ~500 tokens 75.8, 105.4, 65.7, 101.5 tok/s
the same 4 prompts before the patch, --prefill-chunk 0 74.1, 102.6, 67.3, 103.2 tok/s
Codex CLI 0.164 exec against the server, 2 runs passed (a file written and run)

Observed, not explained: right after an engine start, the second request read at about 130 tok/s twice (1,653
and 1,958 tokens). Later requests in the same run were fast, and it did not occur in the five-request run.

This branch is on 4b9e05a. The patch applied there with a three-way merge, and its added and removed lines are
the ones tested at 7dd5cf18e. Between the two revisions, the four waits did not change. Two changes nearby: the
prompt path is now chosen from the prompt's length (the chunked pass from 96 tokens, dfd1b0f), and
forward_chunks now takes the warm-up lock first.

Passed at 4b9e05a with this patch: the build above (CUDA 13.0, sm_90) links strata-dsv41. Its only warnings
are three unused declarations in ds4_tq.cu, which this change does not touch.

Failed: none observed with the patch.

Not run:

  • The requests above at 4b9e05a.
  • The HIP build (no ROCm here) and the Windows (MSVC) build.
  • Any other GPU. That includes 2x RTX 5090 under WSL2 (#4090), and the 2x RTX 3090 and 2x RTX PRO 6000 layer
    splits where the unpatched chunk path works (#4147, #4042).
  • A speed A/B on hardware where the unpatched chunk path works. There, the host now waits instead of queueing
    ahead, so a later group's work is queued later. The effect is unmeasured.
  • A single GPU (the changed waits are not reached there) and other packs. UD-Q8_K_XL runs tensor parallel 2 on
    this machine; its chunk path worked before the patch, and it was not re-run with the patch.

Limits

  • The root cause inside the cublasSgemm call is inferred, not confirmed.
  • The change covers only the chunk path's cross-group waits.

🤖 Generated with Claude Code


🔄 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/4211 **Author:** [@wyxu95](https://github.com/wyxu95) **Created:** 10/26/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `dsv41-layer-split-host-wait` --- ### 📝 Commits (1) - [`8f8bba7`](https://github.com/Niko1221/Strata/commit/8f8bba755d7e45bb1a0dfa8171c02de29ff3f832) DeepSeek engine: a layer split's chunked prompt no longer deadlocks - the host waits for another group's flag before it queues the device-side wait (2x H100, IST-DAS-2.25bpw) ### 📊 Changes **1 file changed** (+25 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `src/dsv41/ds4_model.cu` (+25 -3) </details> ### 📄 Description Draft PR, not ready for review: the HIP and Windows builds and other GPUs are not run, and the requests below ran at 7dd5cf18e, not at this branch's base (see Validation). ## Problem and result On a two-GPU layer split, every prompt that takes the chunked prompt path never finished. The engine stopped answering, and the server's watchdog ended it after 955 s ("the engine said nothing ... during the request"). The layer split comes from the pack: the IST-DAS-2.25bpw (IQ2_XS) experts' 256-value blocks do not split n_ff 2304, so `--tp 2` falls back to whole layers per GPU (`tensor parallel 2 -> 1`). - Before: a fresh 243-token, 1,604-token or 102,045-token prompt never finished. GPU 1 showed 100% utilization at about 128 W, and GPU 0 showed 0%. One engine thread was busy. The windowed path (`--prefill-chunk 0`) worked, at about 135 tok/s. - After: the chunked path reads prompts at 729-1,561 tok/s, including a 916,468-token prompt, and decode speed is unchanged (numbers below). Related: #4090 shows the same stall on 2x RTX 5090 under WSL2 (intermittent there). This change was not tested on that machine. ## What stalled Temporary stderr prints (not part of this PR) showed where each device's thread stopped in `run_dev_chunks`: 1. Device 1 queued `xfer_get` for chunk 0's hand-off into layer 19 and for its source rows from layer 14. Then its thread called `cublasSgemm` in `hc_mix_chunk` (layer 19). The call did not return. 2. Device 0 read the chunk's Engram rows (34 ms) and queued layer 0's Engram work. Then its thread called `cublasSgemm` in `hc_mix_chunk` (layer 0). The call did not return, and device 0 queued nothing more. So device 1's wait kernel spun for a hand-off that device 0 never started. Why a `cublasSgemm` call blocks while a wait kernel spins on the same device, and why device 0's call blocks too, is not established here. This part is inferred, not confirmed: something in the cuBLAS or driver call waits on the device, and the other device's thread waits behind it. These did not change the stall (each with a fresh prompt of 243-247 or about 1,600-2,000 tokens): `--threads on`, `--prefill-chunk 2048`, `--dspark none` (a clean split, layers 0-19 and 20-39 plus the head, every expert in VRAM), `DS4_FLOW=0`, `--mmap-experts off`, `CUDA_MODULE_LOADING=EAGER`, `CUDA_MODULE_LOADING=EAGER` with `CUDA_MODULE_DATA_LOADING=EAGER`, and a cuBLAS workspace set at handle creation (`cublasSetWorkspace`, 32 MiB). ## Approach Before the chunk path queues a device-side wait for another group (`xfer_get` or `wait_flags`), the host now polls the same host-mapped flag until it is up. The kernel then finds the flag up and never spins. This covers the four cross-group waits of the chunk path: the hand-off into a group, the hand-off acknowledgements, the source rows, and their acknowledgements. `host_wait_at_least` uses the kernels' test (`flag - seq` as a signed difference, so a wrapped counter still works). It yields first, then sleeps 20 us between reads. - The data and the order of the GPU work do not change, so the results are the same bits. Only when the host queues the waiting group's work changes. - A single GPU and a tensor-parallel group do not reach these waits. - The window path and decode are unchanged. Their hand-offs did not stall here. ## Validation Environment: 2x NVIDIA H100 80GB HBM3 (NVLink NV18, PCIe 5.0 x16), driver 580.126.09, CUDA 13.0 (nvcc V13.0.88), Ubuntu 24.04.5 in a container, kernel 6.8.0-100, Xeon Platinum 8480C, 2 TB RAM. Model files are on a network filesystem (WekaFS). Source 7dd5cf18e (engine 0.1.49.2) plus this patch. Pack IST-DAS-2.25bpw, served through `serve/server.py` with `gpu [0, 1]` and `--max-context 1048576 --eos 1 --dspark auto --dspark-conf 0.65`. Every expert sits in VRAM except 274 on the CPU lane. Build: `cmake -S . -B build-dsv41 -G Ninja -DCMAKE_BUILD_TYPE=Release -DSTRATA_ENABLE_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES=90 -DSTRATA_BUILD_TESTS=OFF -DSTRATA_BUILD_DSV41=ON -DSTRATA_NATIVE_EXPERTS=ON`, then `cmake --build build-dsv41 --target strata-dsv41`. Passed (patched build, default chunked prompt path; every prompt is fresh text with no prefix reuse). The rates are the engine's own "read in" figures: | Request | Result | |---|---| | 1,630-token prompt | read in 2.2 s, 729 tok/s | | 7,850-token prompt | read in 9.0 s, 873 tok/s | | 35,308-token prompt | read in 25.0 s, 1,410 tok/s | | five ~2K prompts in a row | 786-819 tok/s each | | 102,045-token needle-in-a-haystack (a password at 5% depth) | read in 65.4 s (1,561 tok/s), answer correct | | 916,468-token needle-in-a-haystack | prompt read in 707.8 s (1,294.8 tok/s), answer correct; then 93 tok/s decode | | decode, 4 different prompts of ~500 tokens | 75.8, 105.4, 65.7, 101.5 tok/s | | the same 4 prompts before the patch, `--prefill-chunk 0` | 74.1, 102.6, 67.3, 103.2 tok/s | | Codex CLI 0.164 `exec` against the server, 2 runs | passed (a file written and run) | Observed, not explained: right after an engine start, the second request read at about 130 tok/s twice (1,653 and 1,958 tokens). Later requests in the same run were fast, and it did not occur in the five-request run. This branch is on 4b9e05a. The patch applied there with a three-way merge, and its added and removed lines are the ones tested at 7dd5cf18e. Between the two revisions, the four waits did not change. Two changes nearby: the prompt path is now chosen from the prompt's length (the chunked pass from 96 tokens, dfd1b0f), and `forward_chunks` now takes the warm-up lock first. Passed at 4b9e05a with this patch: the build above (CUDA 13.0, sm_90) links `strata-dsv41`. Its only warnings are three unused declarations in `ds4_tq.cu`, which this change does not touch. Failed: none observed with the patch. Not run: - The requests above at 4b9e05a. - The HIP build (no ROCm here) and the Windows (MSVC) build. - Any other GPU. That includes 2x RTX 5090 under WSL2 (#4090), and the 2x RTX 3090 and 2x RTX PRO 6000 layer splits where the unpatched chunk path works (#4147, #4042). - A speed A/B on hardware where the unpatched chunk path works. There, the host now waits instead of queueing ahead, so a later group's work is queued later. The effect is unmeasured. - A single GPU (the changed waits are not reached there) and other packs. UD-Q8_K_XL runs tensor parallel 2 on this machine; its chunk path worked before the patch, and it was not re-run with the patch. ## Limits - The root cause inside the `cublasSgemm` call is inferred, not confirmed. - The change covers only the chunk path's cross-group waits. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 16:31:35 +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#4952
No description provided.