[PR #2078] [CLOSED] prefill: refill the lent expert slots from the GGUF mapping's pieces (STRATA_REFILL_PARTS=1, gfx1151's table: 4K +3.1%, 32K +1.0%) #3845

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

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/2078
Author: @libratechw
Created: 10/12/2026
Status: ❌ Closed

Base: main ← Head: pr/refill-parts


📝 Commits (1)

  • 8304364 prefill: refill a prompt's lent expert slots from the GGUF mapping's pieces (STRATA_REFILL_PARTS=1, gfx1151's table)

📊 Changes

9 files changed (+105 additions, -11 deletions)

View changed files

📝 docs/STRIX_HALO.md (+1 -0)
📝 include/strata/core/expert_cache.hpp (+6 -0)
📝 include/strata/core/expert_source.hpp (+8 -0)
📝 include/strata/core/remote_experts.hpp (+3 -0)
📝 src/core/arch_defaults.cpp (+1 -0)
📝 src/core/expert_cache.cpp (+24 -0)
📝 src/core/expert_source.cpp (+35 -11)
📝 src/program/generate.cpp (+10 -0)
📝 tests/core/expert_layout_test.cpp (+17 -0)

📄 Description

Title

Issue: none

Summary

After a prompt, the expert-cache slots it borrowed are refilled from the experts' files. With the GGUF read in place an expert
is three tensor slices (gate, up, down, possibly in two shards), so blob_stable first assembled each 4 MB blob in a staging
buffer (a copy on the calling thread) and the refill then copied that to the slot. Each slice is contiguous in its mapped
tensor, so it can go straight to its offset in the slot. The bytes in the slot are the same.

What changed

  • ExpertSource::blob_parts (default: none), FileExpertSource::blob_parts (the GGUF in place only; the RAM copy, an
    override, unbuffered reads, a closed mapping and STRATA_IO_PREFETCH=1 keep blob_stable), and the pass-through in
    RemotePrefillSource (none for an expert the helper holds, the fallback's pieces otherwise). blob_parts counts the read
    as blob does a read out of the mapping (count_mapped_read, now shared by both).
  • ExpertCache::fill_slot_queued_parts: the pieces on the same queue as fill_slot_queued; sync_queued waits as before.
  • generate.cpp: the --serve refill (refill_issue) uses them when STRATA_REFILL_PARTS=1. The single-run refill is
    unchanged.
  • src/core/arch_defaults.cpp: gfx1151 sets STRATA_REFILL_PARTS=1 (STRATA_REFILL_PARTS=0 or STRATA_GFX1151_DEFAULTS=0
    turns it off); docs/STRIX_HALO.md: its row.
  • tests/core/expert_layout_test.cpp: the pieces, each at its offset, equal the assembled blob byte for byte (the fixture's
    second layer spans two shards).

Ryzen AI Max+ 395 (gfx1151, ROCm 7.14.1, Linux), on 296b59d2, UD-Q4_K_XL, --serve --prefill 16384 --spec 4, the section-5
switches of docs/STRIX_HALO.md with STRATA_PF_SWITCH_MIN_T=2048 and STRATA_PF_FUSED_KQ=1, a chat request of 4K / 32K
tokens (a fresh nonce each, reasoning off, 256 tokens out), fresh servers alternating, 7 pairs (32K: of 8, dropping one
with page migration or reclaim during a prompt). Every one of the 7 pairs is faster:

4K 32K
296b59d2, prompt tok/s (median) 1,130 1,242
this branch 1,164 1,255
median of the pair ratios +3.1% +1.0%

The records (each request's engine timing, the requests, the servers' arguments and variables) and the scripts are in
libratechw/Strata@9b1a9fd5, 2078/;
its README says how the runs were made.

Builds and tests on this branch:

  • HIP gfx1151: ctest, 112 tests: 104 pass (expert_layout_test among them), 5 skip, and the same three fail as on 296b59d2
    (ple_parity, expert_parity, pool_test).
  • HIP: strata_kernels, strata_prefill and strata_mmq compile for gfx1012, gfx1030, gfx1100, gfx1103, gfx1150, gfx1151,
    gfx1200 and gfx1201.
  • CUDA 13.0, RTX 3060 (Windows): builds; ctest, 117 tests: 114 pass (expert_layout_test among them), 2 skip, and ple_parity
    fails as on 296b59d2.
  • SYCL (oneAPI 2026.1 icpx): builds. The SYCL port has its own expert_source.hpp/.cpp, expert_cache.cpp and generate.cpp,
    not changed; it shares expert_cache.hpp and arch_defaults.cpp.

Not run: UD-IQ4_XS, the single-run refill, gfx1151 under Windows, and STRATA_IO_PREFETCH=1.

🤖 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/2078 **Author:** [@libratechw](https://github.com/libratechw) **Created:** 10/12/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `pr/refill-parts` --- ### 📝 Commits (1) - [`8304364`](https://github.com/Niko1221/Strata/commit/830436448d5266ada066dc184993b69b1e50fc91) prefill: refill a prompt's lent expert slots from the GGUF mapping's pieces (STRATA_REFILL_PARTS=1, gfx1151's table) ### 📊 Changes **9 files changed** (+105 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `docs/STRIX_HALO.md` (+1 -0) 📝 `include/strata/core/expert_cache.hpp` (+6 -0) 📝 `include/strata/core/expert_source.hpp` (+8 -0) 📝 `include/strata/core/remote_experts.hpp` (+3 -0) 📝 `src/core/arch_defaults.cpp` (+1 -0) 📝 `src/core/expert_cache.cpp` (+24 -0) 📝 `src/core/expert_source.cpp` (+35 -11) 📝 `src/program/generate.cpp` (+10 -0) 📝 `tests/core/expert_layout_test.cpp` (+17 -0) </details> ### 📄 Description ## Title Issue: none ## Summary After a prompt, the expert-cache slots it borrowed are refilled from the experts' files. With the GGUF read in place an expert is three tensor slices (gate, up, down, possibly in two shards), so `blob_stable` first assembled each 4 MB blob in a staging buffer (a copy on the calling thread) and the refill then copied that to the slot. Each slice is contiguous in its mapped tensor, so it can go straight to its offset in the slot. The bytes in the slot are the same. ## What changed - `ExpertSource::blob_parts` (default: none), `FileExpertSource::blob_parts` (the GGUF in place only; the RAM copy, an override, unbuffered reads, a closed mapping and `STRATA_IO_PREFETCH=1` keep `blob_stable`), and the pass-through in `RemotePrefillSource` (none for an expert the helper holds, the fallback's pieces otherwise). `blob_parts` counts the read as `blob` does a read out of the mapping (`count_mapped_read`, now shared by both). - `ExpertCache::fill_slot_queued_parts`: the pieces on the same queue as `fill_slot_queued`; `sync_queued` waits as before. - `generate.cpp`: the `--serve` refill (`refill_issue`) uses them when `STRATA_REFILL_PARTS=1`. The single-run refill is unchanged. - `src/core/arch_defaults.cpp`: gfx1151 sets `STRATA_REFILL_PARTS=1` (`STRATA_REFILL_PARTS=0` or `STRATA_GFX1151_DEFAULTS=0` turns it off); `docs/STRIX_HALO.md`: its row. - `tests/core/expert_layout_test.cpp`: the pieces, each at its offset, equal the assembled blob byte for byte (the fixture's second layer spans two shards). Ryzen AI Max+ 395 (gfx1151, ROCm 7.14.1, Linux), on 296b59d2, UD-Q4_K_XL, `--serve --prefill 16384 --spec 4`, the section-5 switches of `docs/STRIX_HALO.md` with `STRATA_PF_SWITCH_MIN_T=2048` and `STRATA_PF_FUSED_KQ=1`, a chat request of 4K / 32K tokens (a fresh nonce each, reasoning off, 256 tokens out), fresh servers alternating, 7 pairs (32K: of 8, dropping one with page migration or reclaim during a prompt). Every one of the 7 pairs is faster: | | 4K | 32K | |---|---:|---:| | 296b59d2, prompt tok/s (median) | 1,130 | 1,242 | | this branch | 1,164 | 1,255 | | median of the pair ratios | +3.1% | +1.0% | The records (each request's engine timing, the requests, the servers' arguments and variables) and the scripts are in [libratechw/Strata@9b1a9fd5, `2078/`](https://github.com/libratechw/Strata/tree/9b1a9fd5d0a4850320a9211eb727de283d1e90a7/2078); its README says how the runs were made. Builds and tests on this branch: - HIP gfx1151: ctest, 112 tests: 104 pass (`expert_layout_test` among them), 5 skip, and the same three fail as on 296b59d2 (`ple_parity`, `expert_parity`, `pool_test`). - HIP: `strata_kernels`, `strata_prefill` and `strata_mmq` compile for gfx1012, gfx1030, gfx1100, gfx1103, gfx1150, gfx1151, gfx1200 and gfx1201. - CUDA 13.0, RTX 3060 (Windows): builds; ctest, 117 tests: 114 pass (`expert_layout_test` among them), 2 skip, and `ple_parity` fails as on 296b59d2. - SYCL (oneAPI 2026.1 icpx): builds. The SYCL port has its own `expert_source.hpp/.cpp`, `expert_cache.cpp` and `generate.cpp`, not changed; it shares `expert_cache.hpp` and `arch_defaults.cpp`. Not run: UD-IQ4_XS, the single-run refill, gfx1151 under Windows, and `STRATA_IO_PREFETCH=1`. 🤖 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 15:31:10 +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#3845
No description provided.