[PR #1324] file tier: an LRU part of the RAM budget (--resident-lru-gib), elastic under memory pressure (Windows) #3383

Open
opened 2026-11-07 14:41:06 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/1324
Author: @malloc32
Created: 10/7/2026
Status: 🔄 Open

Base: main ← Head: pr/ram-tier-lru


📝 Commits (10+)

  • d3659bc prefill: batched unbuffered expert reads in the stager; close the experts.bin view once reads are unbuffered
  • 24bd585 file tier: STRATA_STAGE_KEEP_MIB keeps recently read expert blobs across decode windows (experiment)
  • f8d0d27 file tier: the prompt path copies a blob the stage pool holds instead of reading the drive again
  • 46baaa6 file tier: --resident-lru-gib keeps part of the RAM budget as an LRU of the experts the decode reads
  • 8bb4a68 file tier: STRATA_TIER_TRACE writes every expert blob served outside the GPU caches (measurement)
  • 8d47932 file tier: the tier trace says which part of the engine read each blob (decode, prompt path, fills)
  • 23d2726 file tier: STRATA_LRU_OFFER=1 offers the RAM tier's idle LRU buffers to Windows instead of keeping them
  • 49716f4 file tier: STRATA_LRU_KEEP_FREE_GIB makes the RAM tier's LRU elastic
  • d1a3710 file tier: the elastic LRU keeps at least 1 GiB
  • c470b83 file tier: drop the offered-LRU experiment (STRATA_LRU_OFFER); the elastic LRU replaces it

📊 Changes

5 files changed (+506 additions, -32 deletions)

View changed files

➕ bench/results/2026-10-07-windows-ram-tier-lru/README.md (+84 -0)
📝 include/strata/core/expert_source.hpp (+65 -1)
📝 src/core/expert_source.cpp (+262 -12)
📝 src/prefill/prefill.cpp (+45 -18)
📝 src/program/generate.cpp (+50 -1)

📄 Description

AI-written. This PR was prepared by an AI (Claude Opus 5.5, via Claude Code) at the submitter's request: design, code and every measurement were done by the AI on the submitter's machine, and the submitter reviewed it before opening.

Depends on #1323 (the #833 port is this branch's first commit); review that one first.

Update 2026-10-07: rebased onto 0.1.40.2 (e8ca9af) together with #1323. New commit: on Windows the elastic watcher keeps commit available as well as RAM (every LRU buffer is committed memory; here the commit charge reached 112-120 of 121 GiB while serving with 8-9 GB of RAM free). The release's I/O prefetch flag (stage_pf_) is cleared when the LRU frees a buffer. Measured on 0.1.40.2 with the production config: decode 72.9 tok/s against 71.4 for the 0.1.40.1-based build, prompts unchanged.

What

--resident-budget-gib fills the RAM once from the global expert profile, so a conversation on another topic keeps reading the drive for experts that are cold in the profile but hot for it.

  • --resident-lru-gib L: L GiB of the budget hold the experts the decode reads from the files, least recently used out first (the unbuffered reads' stage pool). The prompt path copies from it but never adds to it or refreshes it: a prompt chunk sweeps every cold expert once and would push out what the decode reuses.
  • STRATA_LRU_KEEP_FREE_GIB=G: the LRU is elastic. A watcher frees the coldest buffers when the available RAM (on Windows also the available commit) falls below G (back to the OS at once, never paged) and grows the pool back a GiB at a time when RAM is free again. It never shrinks below 1 GiB.
  • STRATA_TIER_TRACE=<file>: one line per expert served outside the GPU caches. It is how the policy was chosen: replaying a traced session against same-size policies, the decode-fed LRU cut the decode's drive reads by ~45%.

The serve log reports the LRU's hits and, when elastic, what it holds and what it gave back. Without the flag and the variable nothing changes.

Measured

Full tables and method in bench/results/2026-10-07-windows-ram-tier-lru/. IQ3_S, 2x RTX 5060 Ti, i7-12700K, 64 GB:

  • 10 GiB by profile + 4 GiB LRU: decode 47.0 tok/s, against 41.9 for 14 GiB by profile alone (the same RAM).
  • 12 + 18 GiB elastic: decode ~64-65 tok/s, prompts ~950 / ~1,540 tok/s (8K / 32K).
  • Another program taking 20 GiB gets it in ~6 s, unpaged; decode drops to ~50 and is back at 60-70 tok/s ~20 s after the RAM is freed.

Tried and not in this PR: offering idle buffers to Windows (OfferVirtualMemory) halved decode speed; a routing lookahead reading the predicted blobs tripled the bytes read.

Not tested

The elastic watcher on Linux (it uses MemAvailable; only Windows was measured). HIP.

🤖 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/1324 **Author:** [@malloc32](https://github.com/malloc32) **Created:** 10/7/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `pr/ram-tier-lru` --- ### 📝 Commits (10+) - [`d3659bc`](https://github.com/Niko1221/Strata/commit/d3659bc752b101d422090fed7d6c24f19e0ebc11) prefill: batched unbuffered expert reads in the stager; close the experts.bin view once reads are unbuffered - [`24bd585`](https://github.com/Niko1221/Strata/commit/24bd585a53374cc40e85b516016b7ce4fdbd2089) file tier: STRATA_STAGE_KEEP_MIB keeps recently read expert blobs across decode windows (experiment) - [`f8d0d27`](https://github.com/Niko1221/Strata/commit/f8d0d273c8f3e1752387df9fa9528bc2f004c55c) file tier: the prompt path copies a blob the stage pool holds instead of reading the drive again - [`46baaa6`](https://github.com/Niko1221/Strata/commit/46baaa632bbbd641ac3abb08363777922792881d) file tier: --resident-lru-gib keeps part of the RAM budget as an LRU of the experts the decode reads - [`8bb4a68`](https://github.com/Niko1221/Strata/commit/8bb4a68f7628e360ba556d7e7797149a5c55e7c6) file tier: STRATA_TIER_TRACE writes every expert blob served outside the GPU caches (measurement) - [`8d47932`](https://github.com/Niko1221/Strata/commit/8d47932f80d2590c500d1f68df5b0b9e54a8e4bc) file tier: the tier trace says which part of the engine read each blob (decode, prompt path, fills) - [`23d2726`](https://github.com/Niko1221/Strata/commit/23d27263edac5a5cbed0dbbd574f91a28b64b9ed) file tier: STRATA_LRU_OFFER=1 offers the RAM tier's idle LRU buffers to Windows instead of keeping them - [`49716f4`](https://github.com/Niko1221/Strata/commit/49716f4db29faa9ff3c5553c4107bef677efb4dc) file tier: STRATA_LRU_KEEP_FREE_GIB makes the RAM tier's LRU elastic - [`d1a3710`](https://github.com/Niko1221/Strata/commit/d1a3710300742320a3e5e2efa7e247dc958ef0a4) file tier: the elastic LRU keeps at least 1 GiB - [`c470b83`](https://github.com/Niko1221/Strata/commit/c470b83f5d42ff4cf3c37ba9a590aa650f5cc844) file tier: drop the offered-LRU experiment (STRATA_LRU_OFFER); the elastic LRU replaces it ### 📊 Changes **5 files changed** (+506 additions, -32 deletions) <details> <summary>View changed files</summary> ➕ `bench/results/2026-10-07-windows-ram-tier-lru/README.md` (+84 -0) 📝 `include/strata/core/expert_source.hpp` (+65 -1) 📝 `src/core/expert_source.cpp` (+262 -12) 📝 `src/prefill/prefill.cpp` (+45 -18) 📝 `src/program/generate.cpp` (+50 -1) </details> ### 📄 Description **AI-written.** This PR was prepared by an AI (Claude Opus 5.5, via Claude Code) at the submitter's request: design, code and every measurement were done by the AI on the submitter's machine, and the submitter reviewed it before opening. **Depends on #1323** (the #833 port is this branch's first commit); review that one first. **Update 2026-10-07:** rebased onto 0.1.40.2 (`e8ca9af`) together with #1323. New commit: on Windows the elastic watcher keeps commit available as well as RAM (every LRU buffer is committed memory; here the commit charge reached 112-120 of 121 GiB while serving with 8-9 GB of RAM free). The release's I/O prefetch flag (`stage_pf_`) is cleared when the LRU frees a buffer. Measured on 0.1.40.2 with the production config: decode 72.9 tok/s against 71.4 for the 0.1.40.1-based build, prompts unchanged. ## What `--resident-budget-gib` fills the RAM once from the global expert profile, so a conversation on another topic keeps reading the drive for experts that are cold in the profile but hot for it. - `--resident-lru-gib L`: L GiB of the budget hold the experts the decode reads from the files, least recently used out first (the unbuffered reads' stage pool). The prompt path copies from it but never adds to it or refreshes it: a prompt chunk sweeps every cold expert once and would push out what the decode reuses. - `STRATA_LRU_KEEP_FREE_GIB=G`: the LRU is elastic. A watcher frees the coldest buffers when the available RAM (on Windows also the available commit) falls below G (back to the OS at once, never paged) and grows the pool back a GiB at a time when RAM is free again. It never shrinks below 1 GiB. - `STRATA_TIER_TRACE=<file>`: one line per expert served outside the GPU caches. It is how the policy was chosen: replaying a traced session against same-size policies, the decode-fed LRU cut the decode's drive reads by ~45%. The serve log reports the LRU's hits and, when elastic, what it holds and what it gave back. Without the flag and the variable nothing changes. ## Measured Full tables and method in `bench/results/2026-10-07-windows-ram-tier-lru/`. IQ3_S, 2x RTX 5060 Ti, i7-12700K, 64 GB: - 10 GiB by profile + 4 GiB LRU: decode 47.0 tok/s, against 41.9 for 14 GiB by profile alone (the same RAM). - 12 + 18 GiB elastic: decode ~64-65 tok/s, prompts ~950 / ~1,540 tok/s (8K / 32K). - Another program taking 20 GiB gets it in ~6 s, unpaged; decode drops to ~50 and is back at 60-70 tok/s ~20 s after the RAM is freed. Tried and not in this PR: offering idle buffers to Windows (`OfferVirtualMemory`) halved decode speed; a routing lookahead reading the predicted blobs tripled the bytes read. ## Not tested The elastic watcher on Linux (it uses `MemAvailable`; only Windows was measured). HIP. 🤖 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>
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#3383
No description provided.