[PR #1101] [CLOSED] prefill: let Stager threads sleep instead of yield-spinning (Linux + --mmap-experts: prompts ~10x faster on DGX Spark, ~1 core instead of ~20) #3025

Closed
opened 2026-11-04 02:05:02 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/1101
Author: @uncle-daddy-jp
Created: 10/6/2026
Status: ❌ Closed

Base: main ← Head: prefill-stager-sleep-2


📝 Commits (1)

  • 501ba3f prefill: let Stager threads sleep instead of yield-spinning

📊 Changes

2 files changed (+7 additions, -2 deletions)

View changed files

📝 include/strata/hip_compat/cuda_runtime.h (+1 -0)
📝 src/prefill/prefill.cpp (+6 -2)

📄 Description

Fixes #1056. Re-opened on the new main after today's history cleanup (replaces #1057, which GitHub closed when main was force-pushed).

Fixes the prefill slowdown and CPU burn described in the linked issue: the Stager threads waited by spinning (a yield loop on issued, and cudaEventSynchronize on events created without cudaEventBlockingSync, which spins under the default scheduler). With --mmap-experts there are 32 of them; on Linux they inherit the host thread's single-core pin and starve it (prompts read ~10x slower on a DGX Spark), and unpinned they take every core for the whole prompt.

This change makes both waits sleep:

  • the ring wait uses C++20 std::atomic::wait, with notify_all in issued_one() and finish();
  • dma_done events are created with cudaEventDisableTiming | cudaEventBlockingSync;
  • the HIP shim gets cudaEventBlockingSync -> hipEventBlockingSync (not tested on HIP).

No affinity changes. Measured on a DGX Spark (GB10, CUDA 13.0, Ubuntu 24.04) with IQ3_S, all experts in the GPU cache, prompts of 7,031 / 26,383 tokens:

build 8K read tok/s 30K read tok/s process CPU while reading decode tok/s
before (44df8fd / same code as main) 91 88 ~100 (all on core 0) 42-48
stagers unpinned instead 1,068-1,183 1,344-1,397 1,640-1,880 40-42
this PR 1,222-1,229 1,388-1,390 102 41-43

Output tokens are unchanged (greedy, same prompts). The commit cherry-picks cleanly onto the new main.

Measured with the help of Claude (Anthropic).

🤖 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/1101 **Author:** [@uncle-daddy-jp](https://github.com/uncle-daddy-jp) **Created:** 10/6/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `prefill-stager-sleep-2` --- ### 📝 Commits (1) - [`501ba3f`](https://github.com/Niko1221/Strata/commit/501ba3f5ec6018246f43e41b0879626b8483b4a9) prefill: let Stager threads sleep instead of yield-spinning ### 📊 Changes **2 files changed** (+7 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `include/strata/hip_compat/cuda_runtime.h` (+1 -0) 📝 `src/prefill/prefill.cpp` (+6 -2) </details> ### 📄 Description Fixes #1056. Re-opened on the new `main` after today's history cleanup (replaces #1057, which GitHub closed when main was force-pushed). Fixes the prefill slowdown and CPU burn described in the linked issue: the `Stager` threads waited by spinning (a `yield` loop on `issued`, and `cudaEventSynchronize` on events created without `cudaEventBlockingSync`, which spins under the default scheduler). With `--mmap-experts` there are 32 of them; on Linux they inherit the host thread's single-core pin and starve it (prompts read ~10x slower on a DGX Spark), and unpinned they take every core for the whole prompt. This change makes both waits sleep: - the ring wait uses C++20 `std::atomic::wait`, with `notify_all` in `issued_one()` and `finish()`; - `dma_done` events are created with `cudaEventDisableTiming | cudaEventBlockingSync`; - the HIP shim gets `cudaEventBlockingSync -> hipEventBlockingSync` (not tested on HIP). No affinity changes. Measured on a DGX Spark (GB10, CUDA 13.0, Ubuntu 24.04) with IQ3_S, all experts in the GPU cache, prompts of 7,031 / 26,383 tokens: | build | 8K read tok/s | 30K read tok/s | process CPU while reading | decode tok/s | |---|---:|---:|---:|---:| | before (44df8fd / same code as main) | 91 | 88 | ~100 (all on core 0) | 42-48 | | stagers unpinned instead | 1,068-1,183 | 1,344-1,397 | 1,640-1,880 | 40-42 | | **this PR** | **1,222-1,229** | **1,388-1,390** | **102** | **41-43** | Output tokens are unchanged (greedy, same prompts). The commit cherry-picks cleanly onto the new main. Measured with the help of Claude (Anthropic). 🤖 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-04 02:05:02 +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#3025
No description provided.