[PR #1033] [CLOSED] prefill: gather GPU-resident experts in groups on short prompts too #2981

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

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/1033
Author: @brenoperucchi
Created: 10/6/2026
Status: ❌ Closed

Base: main ← Head: prefill-group-resident


📝 Commits (10+)

  • fa16567 setup: an earlier config that does not parse is skipped, not a crash; configs are written atomically (#459)
  • 749d957 setup (--backend hip): a system ROCm without the HIP development files falls back to the wheels (#446)
  • 5a30024 calibrate: the engine's arguments come from the server's engine_args; a failed tuning says why (#447)
  • 9f60d13 serve, setup: name the small split card that caps the prompt chunk; setup recommends the big card alone (#448)
  • eb8da1d /metrics: each request's speculative draft counts, and their sums in the totals (#457)
  • 6a09387 setup (--gguf-dir): GGUFs Strata cannot run are named as such, with the --family/--model to use (#444)
  • d6a91e2 docs: the Coder is weaker outside code, Chinese/CJK text included; the unpruned sizes for that (#438)
  • d8d4ad3 Merge branch 'f-135-eng' into rel-0.1.35
  • 7b600d5 Merge branch 'f-135-small' into rel-0.1.35
  • d9ab843 Engine 0.1.35: Windows AMD uses its bundled HIP runtime (#468 #461), the low-RAM resident mode on Windows 32 GB PCs (#467), fixes #460 #459 #446 #447 #457 #448 #444; setup requires it

📊 Changes

1 file changed (+17 additions, -2 deletions)

View changed files

📝 src/prefill/prefill.cpp (+17 -2)

📄 Description

#372 (in 0.1.38) gathers an MMQ group's experts in one launch, but only in the streamed walk. A chunk below
stream_all_min() (1024 tokens) still takes the staged walk, where every expert gets its own gather_native launch.
@BlueKingMuch noticed this in #372: the 923-token tail of a 64K prompt was not affected.

On our box most short requests are 150-600 tokens with almost every routed expert already in the GPU cache, so this
per-expert launch is where their time goes. With STRATA_PREFILL_TIMING=1, a ~450-token prompt spends 50-55% of its
GPU timeline in the "dequant" phase, which on the MMQ path is the gather.

The staged walk was left out of #372 because a staged expert sits in the 8-slot staging ring, which is smaller than a
group of 16, so a group cannot hold its slots. Resident experts have no ring slot, no wait and no release. This patch
groups only those:

  • a resident expert joins the open group (gather_native_group, the same bytes into the same group slots);
  • a staged expert first flushes what the group holds, then is gathered alone as before, and the group restarts after
    it;
  • products, their order, the MMQ tail memsets and the streamed walk are unchanged;
  • STRATA_PREFILL_GROUP_GATHER=0 still turns grouping off everywhere.

One file, src/prefill/prefill.cpp, +17/-2.

Tested on an RTX 5090 32 GB, Ryzen 9 5950X, 96 GB DDR4, Windows 11 (WDDM), CUDA 13.0, with the Swift IQ3_XXS native pack,
--expert-cache auto, --prefill auto:32768, --kv int8, --max-context 32768. My builds use the
setup.py flags plus STRATA_PORTABLE=ON. The short-prompt baseline is v0.1.39 built here (it also carries #861, which
does nothing unless a request opts in); the other tables compare against the official v0.1.39 exe.

For short prompts I sent chat requests with a ~100-token system prompt (reused from the prompt cache) and a different excerpt of
src/program/generate.cpp each time, 1 token out; 30 requests per size, median of the last 28:

prompt read v0.1.39 this PR
158 tokens 425 ms 365 ms (-14%)
315 tokens 527 ms 452 ms (-14%)
452 tokens 593 ms 524 ms (-12%)

The "dequant" phase of a ~500-token chunk went from ~300 ms to ~214 ms.

For longer prompts I ran the official v0.1.39 exe and this build in alternation (A B A B), 1 warm-up and 3 runs each.
They come out the same, which is expected since a 2.6K or 14.7K prompt takes the streamed walk:

v0.1.39 this PR
2.6K prompt read ~3,170 tok/s ~3,130-3,173 tok/s
14.7K prompt read ~6,460-6,480 tok/s ~6,475 tok/s

To check that the numbers do not change, I compared per-token logprobs (STRATA_LOGPOS) on teacher-forced text,
official exe against this build, alternating, two runs each. All four runs of each text gave the same perplexity:

text v0.1.39 this PR target mismatches
English, 512-token chunks x 32 (staged walk) 8.9294 8.9294 0
Portuguese, 512-token chunks x 32 (staged walk) 1.606 1.606 0
English, 2048-token chunks x 8 (streamed walk, control) 6.8067 6.8067 0

My first version crashed with an illegal memory access. After a staged expert, the next flush still covered the
staged expert's position, whose group pointer was empty. The second commit (squashed here) starts the group after it.


🔄 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/1033 **Author:** [@brenoperucchi](https://github.com/brenoperucchi) **Created:** 10/6/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `prefill-group-resident` --- ### 📝 Commits (10+) - [`fa16567`](https://github.com/Niko1221/Strata/commit/fa165679f9860552ac97ebd07118bb8db286be4a) setup: an earlier config that does not parse is skipped, not a crash; configs are written atomically (#459) - [`749d957`](https://github.com/Niko1221/Strata/commit/749d957a1790b1a171dd4a01ab3e31b3882c9892) setup (--backend hip): a system ROCm without the HIP development files falls back to the wheels (#446) - [`5a30024`](https://github.com/Niko1221/Strata/commit/5a3002446dbb9dfcabb7d0bd9f113da90cc2f3c0) calibrate: the engine's arguments come from the server's engine_args; a failed tuning says why (#447) - [`9f60d13`](https://github.com/Niko1221/Strata/commit/9f60d13246e46b02b1dd0841980b4d18b0faaea7) serve, setup: name the small split card that caps the prompt chunk; setup recommends the big card alone (#448) - [`eb8da1d`](https://github.com/Niko1221/Strata/commit/eb8da1d8c26ec41e6ffb084fdf579dba7cad10bd) /metrics: each request's speculative draft counts, and their sums in the totals (#457) - [`6a09387`](https://github.com/Niko1221/Strata/commit/6a093874fe037020f49bd5cf053879ff6a133c21) setup (--gguf-dir): GGUFs Strata cannot run are named as such, with the --family/--model to use (#444) - [`d6a91e2`](https://github.com/Niko1221/Strata/commit/d6a91e2d1770d0f469d6ec15890acc7ee93e764c) docs: the Coder is weaker outside code, Chinese/CJK text included; the unpruned sizes for that (#438) - [`d8d4ad3`](https://github.com/Niko1221/Strata/commit/d8d4ad337d3c98ba21d3bd0af1a16e9177e112b6) Merge branch 'f-135-eng' into rel-0.1.35 - [`7b600d5`](https://github.com/Niko1221/Strata/commit/7b600d55ff801caaaa11542af1523050992e049b) Merge branch 'f-135-small' into rel-0.1.35 - [`d9ab843`](https://github.com/Niko1221/Strata/commit/d9ab8435f654c368c586340d490915f6addf56a3) Engine 0.1.35: Windows AMD uses its bundled HIP runtime (#468 #461), the low-RAM resident mode on Windows 32 GB PCs (#467), fixes #460 #459 #446 #447 #457 #448 #444; setup requires it ### 📊 Changes **1 file changed** (+17 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `src/prefill/prefill.cpp` (+17 -2) </details> ### 📄 Description #372 (in 0.1.38) gathers an MMQ group's experts in one launch, but only in the streamed walk. A chunk below `stream_all_min()` (1024 tokens) still takes the staged walk, where every expert gets its own `gather_native` launch. @BlueKingMuch noticed this in #372: the 923-token tail of a 64K prompt was not affected. On our box most short requests are 150-600 tokens with almost every routed expert already in the GPU cache, so this per-expert launch is where their time goes. With `STRATA_PREFILL_TIMING=1`, a ~450-token prompt spends 50-55% of its GPU timeline in the "dequant" phase, which on the MMQ path is the gather. The staged walk was left out of #372 because a staged expert sits in the 8-slot staging ring, which is smaller than a group of 16, so a group cannot hold its slots. Resident experts have no ring slot, no wait and no release. This patch groups only those: - a resident expert joins the open group (`gather_native_group`, the same bytes into the same group slots); - a staged expert first flushes what the group holds, then is gathered alone as before, and the group restarts after it; - products, their order, the MMQ tail memsets and the streamed walk are unchanged; - `STRATA_PREFILL_GROUP_GATHER=0` still turns grouping off everywhere. One file, `src/prefill/prefill.cpp`, +17/-2. Tested on an RTX 5090 32 GB, Ryzen 9 5950X, 96 GB DDR4, Windows 11 (WDDM), CUDA 13.0, with the Swift IQ3_XXS native pack, `--expert-cache auto`, `--prefill auto:32768`, `--kv int8`, `--max-context 32768`. My builds use the setup.py flags plus `STRATA_PORTABLE=ON`. The short-prompt baseline is v0.1.39 built here (it also carries #861, which does nothing unless a request opts in); the other tables compare against the official v0.1.39 exe. For short prompts I sent chat requests with a ~100-token system prompt (reused from the prompt cache) and a different excerpt of `src/program/generate.cpp` each time, 1 token out; 30 requests per size, median of the last 28: | prompt read | v0.1.39 | this PR | |---|---:|---:| | 158 tokens | 425 ms | 365 ms (-14%) | | 315 tokens | 527 ms | 452 ms (-14%) | | 452 tokens | 593 ms | 524 ms (-12%) | The "dequant" phase of a ~500-token chunk went from ~300 ms to ~214 ms. For longer prompts I ran the official v0.1.39 exe and this build in alternation (A B A B), 1 warm-up and 3 runs each. They come out the same, which is expected since a 2.6K or 14.7K prompt takes the streamed walk: | | v0.1.39 | this PR | |---|---:|---:| | 2.6K prompt read | ~3,170 tok/s | ~3,130-3,173 tok/s | | 14.7K prompt read | ~6,460-6,480 tok/s | ~6,475 tok/s | To check that the numbers do not change, I compared per-token logprobs (`STRATA_LOGPOS`) on teacher-forced text, official exe against this build, alternating, two runs each. All four runs of each text gave the same perplexity: | text | v0.1.39 | this PR | target mismatches | |---|---:|---:|---:| | English, 512-token chunks x 32 (staged walk) | 8.9294 | 8.9294 | 0 | | Portuguese, 512-token chunks x 32 (staged walk) | 1.606 | 1.606 | 0 | | English, 2048-token chunks x 8 (streamed walk, control) | 6.8067 | 6.8067 | 0 | My first version crashed with an illegal memory access. After a staged expert, the next flush still covered the staged expert's position, whose group pointer was empty. The second commit (squashed here) starts the group after it. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-04 02:04:39 +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#2981
No description provided.