[PR #1600] [CLOSED] split: decide STRATA_SPLIT_RING before sizing the lend regions (a 104k read stops reading 10 GB from the file) #3556

Closed
opened 2026-11-07 14:42:18 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/1600
Author: @noon-at-cgn
Created: 10/8/2026
Status: ❌ Closed

Base: main ← Head: pr/lend-sizing


📝 Commits (5)

  • 39708ae resident split: a test that the RAM copy keeps each stage's lend region (red: FileExpertSource has no stage_lend_regions, and no append_stage_lend_regions)
  • 3ba11b1 resident split: pin_cache_complement keeps each stage's lend region in the RAM copy too (stage_lend_regions, append_stage_lend_regions) - the experts the prompt path borrows under a split streamed from the mapped files through page faults (3.7 GiB read for one 73K prompt, 1.5 s of a 3.9 s chunk on host staging, 2026-10-06 rig); one budget caps complement and regions, experts past it keep the file fallback
  • 6b6277a generate: size every part's lend region for a layer split by the serve scan's own arithmetic (auto ceiling or the explicit chunk, the 128-slot floor, the auto percentage cap), #340's own-buffer rule deciding which parts lend nothing - and hand them to the resident copy before it pins
  • 84ef5db split: decide STRATA_SPLIT_RING before sizing the lend regions; log borrowed vs RAM-kept slots
  • 8c274dd docs: replace the evidence placeholder in the lend-sizing paragraph with the measured result

📊 Changes

9 files changed (+628 additions, -20 deletions)

View changed files

📝 CMakeLists.txt (+19 -0)
📝 docs/MULTI_GPU.md (+23 -0)
📝 include/strata/core/expert_source.hpp (+22 -0)
➕ include/strata/program/split_ring.hpp (+36 -0)
📝 src/core/expert_source.cpp (+79 -0)
📝 src/program/generate.cpp (+100 -20)
➕ src/program/split_ring_test.cpp (+84 -0)
📝 tests/core/file_expert_source_test.cpp (+46 -0)
➕ tests/core/split_lend_complement_test.cpp (+219 -0)

📄 Description

Title

Issue: Related: #1190 (this PR depends on it and is branched from its head; please merge it first). Near it: #1417 changes part_slots in the same area of generate.cpp.

Summary

Why it matters: with STRATA_SPLIT_RING=384 the prompt path borrowed 5,396 cache slots but the RAM copy kept only 4,662. Each long prompt then re-read the other 734 slots' experts from the model file in every chunk. The cause is an ordering bug: the lend regions are sized with Prefill::bytes_needed before the ring override is applied, although Prefill::set_ring_override says it must come first. Now the ring is decided first, and a start-up line shows borrowed against kept so a mismatch is visible.

2x RTX 3080, layer split 23, 104k-token prompt, resident RAM mode before after
slots borrowed / kept in RAM 5,396 / 4,662 5,396 / 5,396
blob reads from the model file per request 413 0
expert data read from the GGUF per request 10,345 MB 0 MB
pinned RAM for the copies 13.61 GiB 15.76 GiB (+2.15)

Nothing changes without a split or without --resident-experts. With the override unset the lend lines are identical before and after.

What changed

  • src/program/generate.cpp: the ring choice moves into decide_split_ring(), called before the stage lend regions are sized (the old call site stays and does nothing a second time). The tail-slot count for a region and for the borrow is one function. New line: strata serve: lend sizing: the prompt path borrows N slots (ring R slots at chunk C), K of them keep their experts in RAM too, with a WARNING when K is below N.
  • include/strata/program/split_ring.hpp (new): split_ring_slots, split_lend_slots. src/program/split_ring_test.cpp (new) + CMakeLists.txt: CPU test (23 checks): the copy keeps every borrowed slot with the ring decided first, not with the old order.
  • docs/MULTI_GPU.md: one paragraph.

Extra Notes

Machine: 2x RTX 3080 20 GB (220 W), Xeon E5-2696 v4, 90 GiB container, UD-Q4_K_XL, --prefill auto:16384, one restart per arm; the patched binary has none of our other patches. MemAvailable minimum during the reads: 11.98 GiB with the fix, 13.34 GiB without, both above the 2 GiB floor.
Not claimed: a speed gain. Medians of three 104k reads were 2,803 (before) and 2,907 (after) tok/s, but the before arm's spread is 2,540-2,897 (its first read faulted 4.2 GB in from NVMe) and it has no A/A restart. 25k and 51k reads are equal within 1-2% (they touch none of the unkept slots). On a box with less spare page cache the 10 GB per request would be disk traffic; here the page cache absorbed it.
The setting our own deployment uses, STRATA_PREFILL_RING=384, was never affected. 413 = 7 x 59 (7 equal chunks) is our inference, not logged. Not tested: both ring variables unset.
Checked: split_ring_test, #1190's file_expert_source_test and split_lend_complement_test, CUDA build on #1190's base. Not built: HIP, SYCL. This is a bug fix, not an opt-in: with a split and the resident RAM mode the sizing order changes for every ring choice.
Context: the setup measured in the community benchmark #1640 does not use STRATA_SPLIT_RING, so its numbers do not depend on this fix.


🔄 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/1600 **Author:** [@noon-at-cgn](https://github.com/noon-at-cgn) **Created:** 10/8/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `pr/lend-sizing` --- ### 📝 Commits (5) - [`39708ae`](https://github.com/Niko1221/Strata/commit/39708ae565d7869a8570ea8982f7f44dd24fd9d2) resident split: a test that the RAM copy keeps each stage's lend region (red: FileExpertSource has no stage_lend_regions, and no append_stage_lend_regions) - [`3ba11b1`](https://github.com/Niko1221/Strata/commit/3ba11b16385ab709ce5e78f73b70ccf4cff17ab5) resident split: pin_cache_complement keeps each stage's lend region in the RAM copy too (stage_lend_regions, append_stage_lend_regions) - the experts the prompt path borrows under a split streamed from the mapped files through page faults (3.7 GiB read for one 73K prompt, 1.5 s of a 3.9 s chunk on host staging, 2026-10-06 rig); one budget caps complement and regions, experts past it keep the file fallback - [`6b6277a`](https://github.com/Niko1221/Strata/commit/6b6277a687b78324986e07b69aed1fad770e99ad) generate: size every part's lend region for a layer split by the serve scan's own arithmetic (auto ceiling or the explicit chunk, the 128-slot floor, the auto percentage cap), #340's own-buffer rule deciding which parts lend nothing - and hand them to the resident copy before it pins - [`84ef5db`](https://github.com/Niko1221/Strata/commit/84ef5db7e7d396794c1cb4c5a927e9e0556e83a7) split: decide STRATA_SPLIT_RING before sizing the lend regions; log borrowed vs RAM-kept slots - [`8c274dd`](https://github.com/Niko1221/Strata/commit/8c274ddcc28382c7c19a6abb7ecebc92e544c03e) docs: replace the evidence placeholder in the lend-sizing paragraph with the measured result ### 📊 Changes **9 files changed** (+628 additions, -20 deletions) <details> <summary>View changed files</summary> 📝 `CMakeLists.txt` (+19 -0) 📝 `docs/MULTI_GPU.md` (+23 -0) 📝 `include/strata/core/expert_source.hpp` (+22 -0) ➕ `include/strata/program/split_ring.hpp` (+36 -0) 📝 `src/core/expert_source.cpp` (+79 -0) 📝 `src/program/generate.cpp` (+100 -20) ➕ `src/program/split_ring_test.cpp` (+84 -0) 📝 `tests/core/file_expert_source_test.cpp` (+46 -0) ➕ `tests/core/split_lend_complement_test.cpp` (+219 -0) </details> ### 📄 Description ## Title Issue: Related: #1190 (this PR depends on it and is branched from its head; please merge it first). Near it: #1417 changes `part_slots` in the same area of `generate.cpp`. ## Summary **Why it matters:** with `STRATA_SPLIT_RING=384` the prompt path borrowed 5,396 cache slots but the RAM copy kept only 4,662. Each long prompt then re-read the other 734 slots' experts from the model file in every chunk. The cause is an ordering bug: the lend regions are sized with `Prefill::bytes_needed` before the ring override is applied, although `Prefill::set_ring_override` says it must come first. Now the ring is decided first, and a start-up line shows borrowed against kept so a mismatch is visible. | 2x RTX 3080, layer split 23, 104k-token prompt, resident RAM mode | before | after | |---|---|---| | slots borrowed / kept in RAM | 5,396 / 4,662 | 5,396 / 5,396 | | blob reads from the model file per request | 413 | 0 | | expert data read from the GGUF per request | 10,345 MB | 0 MB | | pinned RAM for the copies | 13.61 GiB | 15.76 GiB (+2.15) | Nothing changes without a split or without `--resident-experts`. With the override unset the lend lines are identical before and after. ## What changed - `src/program/generate.cpp`: the ring choice moves into `decide_split_ring()`, called before the stage lend regions are sized (the old call site stays and does nothing a second time). The tail-slot count for a region and for the borrow is one function. New line: `strata serve: lend sizing: the prompt path borrows N slots (ring R slots at chunk C), K of them keep their experts in RAM too`, with a `WARNING` when K is below N. - `include/strata/program/split_ring.hpp` (new): `split_ring_slots`, `split_lend_slots`. `src/program/split_ring_test.cpp` (new) + `CMakeLists.txt`: CPU test (23 checks): the copy keeps every borrowed slot with the ring decided first, not with the old order. - `docs/MULTI_GPU.md`: one paragraph. ## Extra Notes Machine: 2x RTX 3080 20 GB (220 W), Xeon E5-2696 v4, 90 GiB container, UD-Q4_K_XL, `--prefill auto:16384`, one restart per arm; the patched binary has none of our other patches. MemAvailable minimum during the reads: 11.98 GiB with the fix, 13.34 GiB without, both above the 2 GiB floor. **Not claimed:** a speed gain. Medians of three 104k reads were 2,803 (before) and 2,907 (after) tok/s, but the before arm's spread is 2,540-2,897 (its first read faulted 4.2 GB in from NVMe) and it has no A/A restart. 25k and 51k reads are equal within 1-2% (they touch none of the unkept slots). On a box with less spare page cache the 10 GB per request would be disk traffic; here the page cache absorbed it. The setting our own deployment uses, `STRATA_PREFILL_RING=384`, was never affected. 413 = 7 x 59 (7 equal chunks) is our inference, not logged. Not tested: both ring variables unset. Checked: `split_ring_test`, #1190's `file_expert_source_test` and `split_lend_complement_test`, CUDA build on #1190's base. Not built: HIP, SYCL. This is a bug fix, not an opt-in: with a split and the resident RAM mode the sizing order changes for every ring choice. Context: the setup measured in the community benchmark #1640 does not use `STRATA_SPLIT_RING`, so its numbers do not depend on this fix. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 14:42:18 +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#3556
No description provided.