[PR #934] [CLOSED] Per-layer expert cache: each layer's slots are that layer's blob #2923

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

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/934
Author: @Chromadera
Created: 10/5/2026
Status: ❌ Closed

Base: main ← Head: per-layer-blob-slots


📝 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

4 files changed (+106 additions, -13 deletions)

View changed files

📝 docs/ORCA_Q4_K_S.md (+1 -1)
➕ docs/per-layer-expert-slots.png (+0 -0)
📝 src/program/generate.cpp (+50 -6)
📝 sycl/src/program/generate.cpp (+55 -6)

📄 Description

Credit

Measured and prepared by Chromadera.

The arrangement comes from the report that this model wrote on its own expert pack: Qwen3.8-Flash-Next GSQ-RCO IQ3_XXS, the weights served as qwen3.8-flash-next-gsq-iq3-xxs (Qwen3.8-Flash-Next-GSQ-RCO-IQ3_XXS-00001-of-00002.gguf and shard 2, pack strata-gsq-iq3-xxs).

Schematic

Per-layer expert cache

--expert-cache N with --expert-cache-per-layer is still a budget of N slots of the largest blob. On a native pack the engine now spends that budget on each layer's real blob. Every layer gets the same number of slots, because a per-layer range is layer * quota + n.

On Qwen3.8-Flash-Next GSQ-RCO IQ3_XXS, 48 layers, --expert-cache 7008:

before after
slots 7,008 (146 per layer) 9,312 (194 per layer)
VRAM 15.20 GiB 15.14 GiB
experts page-locked in RAM 38.00 GiB 37.10 GiB

Startup prints:

per-layer slots use each layer's blob: 7008 uniform slots (15.20 GiB) -> 9312 slots, 194 per layer (15.14 GiB)

Why this does not hit the #369 problem

#369 kept per-layer mode on the largest blob because the sized-slot list was built in profile order. A size chosen for one layer could land in another layer's slot. This list is built in layer order. Slot layer * quota + n is that layer's blob, and every expert in a layer is one size. open_sized already starts each layer at the bottom of its range, and the profile fill already skips a layer once that layer is full.

If one copy of every layer does not fit, the cache stays the old uniform slots. When the cache shrinks, it rebuilds the same equal counts. Cutting the list in the middle would put one layer's blob into the next layer's range.

A layer split is untouched. It already walks that stage's profile. The shared cache, without --expert-cache-per-layer, is unchanged.

Measured

RX 7900 XTX, same binary, same profile, only the slot layout changed. BetterBench cold prefill, thinking on, 5 passes:

prompt 146 uniform 194 real size
8,086 1,518.9 tok/s 1,524.7
63,949 1,686.4 1,690.2
128,136 1,661.5 1,670.3
~197k 1,587.9 1,587.2

No depth got slower. Past the 28,928-token chunk a long prompt is dominated by streaming, so the extra cached experts barely show up there, and they did not cost anything. The weights are the same bytes. A GPU-resident expert rounds differently from the CPU copy; the engine already records that as equal perplexity. More slots means more tokens take the GPU path.

There is no known performance drawback from this. Decode on the shipped profile at 194 slots was 48.9 tok/s weighted (5 passes). The earlier uniform 146-slot serve was 43.8 (20 passes) on an older binary, so that pair is not a clean comparison.

Check

Start with --expert-cache-per-layer on a native pack. The log line should show more slots than N, and the profile fill should fill them. Slot 0 is still checked against the file.


🔄 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/934 **Author:** [@Chromadera](https://github.com/Chromadera) **Created:** 10/5/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `per-layer-blob-slots` --- ### 📝 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 **4 files changed** (+106 additions, -13 deletions) <details> <summary>View changed files</summary> 📝 `docs/ORCA_Q4_K_S.md` (+1 -1) ➕ `docs/per-layer-expert-slots.png` (+0 -0) 📝 `src/program/generate.cpp` (+50 -6) 📝 `sycl/src/program/generate.cpp` (+55 -6) </details> ### 📄 Description ## Credit Measured and prepared by Chromadera. The arrangement comes from the report that this model wrote on its own expert pack: **Qwen3.8-Flash-Next GSQ-RCO IQ3_XXS**, the weights served as `qwen3.8-flash-next-gsq-iq3-xxs` (`Qwen3.8-Flash-Next-GSQ-RCO-IQ3_XXS-00001-of-00002.gguf` and shard 2, pack `strata-gsq-iq3-xxs`). ## Schematic ![Per-layer expert cache](https://github.com/Chromadera/Strata/raw/per-layer-blob-slots/docs/per-layer-expert-slots.png) `--expert-cache N` with `--expert-cache-per-layer` is still a budget of N slots of the largest blob. On a native pack the engine now spends that budget on each layer's real blob. Every layer gets the same number of slots, because a per-layer range is `layer * quota + n`. On Qwen3.8-Flash-Next GSQ-RCO IQ3_XXS, 48 layers, `--expert-cache 7008`: | | before | after | |---|---|---| | slots | 7,008 (146 per layer) | 9,312 (194 per layer) | | VRAM | 15.20 GiB | 15.14 GiB | | experts page-locked in RAM | 38.00 GiB | 37.10 GiB | Startup prints: `per-layer slots use each layer's blob: 7008 uniform slots (15.20 GiB) -> 9312 slots, 194 per layer (15.14 GiB)` ## Why this does not hit the #369 problem #369 kept per-layer mode on the largest blob because the sized-slot list was built in profile order. A size chosen for one layer could land in another layer's slot. This list is built in layer order. Slot `layer * quota + n` is that layer's blob, and every expert in a layer is one size. `open_sized` already starts each layer at the bottom of its range, and the profile fill already skips a layer once that layer is full. If one copy of every layer does not fit, the cache stays the old uniform slots. When the cache shrinks, it rebuilds the same equal counts. Cutting the list in the middle would put one layer's blob into the next layer's range. A layer split is untouched. It already walks that stage's profile. The shared cache, without `--expert-cache-per-layer`, is unchanged. ## Measured RX 7900 XTX, same binary, same profile, only the slot layout changed. BetterBench cold prefill, thinking on, 5 passes: | prompt | 146 uniform | 194 real size | |---|---|---| | 8,086 | 1,518.9 tok/s | 1,524.7 | | 63,949 | 1,686.4 | 1,690.2 | | 128,136 | 1,661.5 | 1,670.3 | | ~197k | 1,587.9 | 1,587.2 | No depth got slower. Past the 28,928-token chunk a long prompt is dominated by streaming, so the extra cached experts barely show up there, and they did not cost anything. The weights are the same bytes. A GPU-resident expert rounds differently from the CPU copy; the engine already records that as equal perplexity. More slots means more tokens take the GPU path. There is no known performance drawback from this. Decode on the shipped profile at 194 slots was 48.9 tok/s weighted (5 passes). The earlier uniform 146-slot serve was 43.8 (20 passes) on an older binary, so that pair is not a clean comparison. ## Check Start with `--expert-cache-per-layer` on a native pack. The log line should show more slots than N, and the profile fill should fill them. Slot 0 is still checked against the file. --- <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:11 +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#2923
No description provided.