[GH-ISSUE #5391] [Engine] experts: a managed cold tier below the RAM budget (scope proposal) #3217

Open
opened 2026-11-07 14:38:56 +07:00 by bsakaguchi · 6 comments
Owner

Originally created by @yeyeyeason on GitHub (Nov 6, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/5391

Area

[Engine] (speed, kernels, models, the server and API)

What do you want to do?

A scope proposal before any code (per CONTRIBUTING.md): a managed cold tier for experts — today the experts the GPU does not hold are either copied into RAM (--resident-budget-gib, the ranked "warm" tier) or left to the OS file cache (--mmap-experts / GGUF-in-place), with nothing in between. When RAM cannot hold the rest of the experts, every cold expert read is un-prioritized, un-measured and un-managed. This proposal: make that remainder a first-class tier, ranked by the same expert profile the warm tier uses, with its own accounting and (later) prefetch.

We follow the release notes' own vocabulary — the VRAM cache, the RAM copy and the file reads are the hot, warm and cold tiers. The first two exist; this is about the third.

Who needs it. Anyone whose model is bigger than RAM-plus-VRAM: a 32 GB PC running UD-Q4_K_XL (59 GiB of experts), a 96 GB PC running Q8_0 (128 GiB) or DeepSeek-V4.1 (2xx GB), and — the vivid case — #5365's 81 GB IQ3_S on 32 GB of RAM plus a 500 GB pagefile across three SATA SSDs. That user is running the cold tier through the Windows pagefile with no priority, no ranking and no visibility. The engine already knows which experts are hot (the profile), and already does ranked SSD reads elsewhere (--ple-io direct); the cold tier is the missing third application of the same idea.

The measured problem. On this machine (2x RTX 4060 Ti 16 GB, i5-10600KF, 96 GB RAM, Windows 11; SC117 Qwen3.8-Flash-Next IQ3_S and Unsloth UD-Q4_K_XL, temperature 0, frozen profile, engine-measured decode; RAM-constrained arms simulated by allocating and touching memory down to the target free RAM), pure mmap and a ranked warm tier differ by:

Model / regime Pure mmap Ranked warm tier Change
UD-Q4_K_XL, 59 GiB complement, budget 46 GiB 11.5 tok/s 20.2 tok/s +76%
UD-Q4_K_XL, budget 35 GiB 11.5 tok/s 14.0 tok/s +22%
UD-Q4_K_XL, full warm (60 GiB) 11.5 tok/s 27.7 tok/s +142%
IQ3_S, 16 GB free RAM (complement 28.5 GiB), budget 2 GiB 18.8 tok/s 23.4 tok/s +24%
IQ3_S, 16 GB free RAM + 1M context, 130K-token recall task 11.0 tok/s 13.9 tok/s +26%
IQ3_S, 32 GB free RAM + 1M context, recall 9.1 tok/s 11.9 tok/s +31%

(1M-context rows on engine 0.1.56; re-checked on 0.1.57 / v0.2.11: +16% and +26% — the tier still wins, see "Relation to the 0.2.11 CPU-share change" below.)

The mechanism is visible in the engine's own per-arm logs: over the same request set, the pure-mmap UD-Q4_K_XL arm read 797 GB from the SSD while the 46 GiB warm-tier arm read 64 GB — the OS file cache re-reads the same cold experts over and over (12x the bytes for the same work), while the ranked tier reads each cold expert about once. That re-read factor is the waste a managed cold tier removes.

The reversal that makes this a placement-policy problem, not just a bigger-budget problem. The warm tier is not always right, and the engine has no way to say so today. At 1M context the KV cache's pinned RAM (~6.2 GiB, engine-logged) squeezes the page cache, and the tier wins; at 512K the same machine frees ~3.1 GiB back, the page cache covers the hot subset of a 28.5 GiB complement, and the tier loses (measured: 16 GB RAM + IQ3_S, 512K: mmap 24.5 vs tier 23.1 tok/s, −6%; the same scenario at 1M: tier +26%). The opposite failure exists too: UD-Q4_K_XL at 1M with a 13 GiB budget that covers only ~22% of the complement went −9% versus mmap — a pinned tier too small to matter steals RAM from the page cache serving the rest. So the value of a managed tier is a function of (complement size, free RAM, context length, budget) — four things the engine can see and the person cannot. A user who copies a 1M-tuned config to a 512K session, or vice versa, silently lands in the wrong regime in either direction.

Proposed shape (opt-in, engine-side, small first step).

  1. Name the third tier: the docs, --stats and Monitor already report VRAM-cache / RAM-resident / file reads; align them under hot / warm / cold so the placement story is one model. No behavior change.
  2. Give the cold tier a ranked read path: when a cold expert is needed, read it through the same profile ranking the warm tier uses (hottest-first admission into a small cold-read staging area, cold experts admitted/demoted by the profile the engine already maintains). This is --resident-budget-gib's ranking applied below the RAM line, not a new policy.
  3. Report it: cold reads, cold bytes, cold read latency and the re-read factor (bytes read per unique blob) per tier in --stats / /metrics, so a person can see which regime they are in — including "your budget is too small; mmap would serve you better."
  4. Later, context-aware budgeting: the 512K↔1M reversal data above is the case for the engine deriving (or at least warning about) --resident-budget-gib from --max-context, free RAM and the complement size.

Prefetch (profile-predicted reads ahead of the verify window) is deliberately out of the first step; the ranked read path and the accounting come first, with prefetch as a follow-up once the read pattern is measured.

Existing foundations this builds on. --resident-budget-gib already ranks and admits by the profile; --ple-io direct already does ranked SSD reads of the 28.8 GB PLE table (the I/O pattern exists); the GGUF-in-place file tier already reads experts from the files (the transport exists); the profile (--expert-profile, --expert-profile-save) already knows the hot set. The change is to extend ranking and accounting below the RAM line — not a new subsystem.

Validation plan. Same-machine A/B, mmap vs budget, at 128K/512K/1M across the two RAM simulations and both models (the tables above are that data, per-request JSON retained); a second model family (DeepSeek-V4.1 2.00 bpw) as the extreme case is planned and named up front; quality unchanged (placement does not touch math); every arm's engine logs kept, failures included. The reversal scenarios are part of the validation matrix on purpose: a placement policy that cannot say "mmap is better here" is not done.

Relation to the 0.2.11 CPU-share change (measured, so it belongs here): 0.2.11's CPU/upload share for missed experts (measured speed, ceiling 0.95) speeds up the GPU-side miss path — on the same machine it moved DFlash2 decode +34% on code — but it does not help the disk-side miss path these arms live in: both cold-tier arms' recall decode dropped ~20% on 0.1.57 (16 GB arm: mmap 11.0→8.7, tier 13.9→10.1), and the tier's advantage held (+26%→+16%, +31%→+26%). The two mechanisms sit on different bottlenecks (PCIe/CPU vs SSD bandwidth) and are complementary, not competing. The 0.1.57 low-RAM recall regression is separately worth its own report once reproduced cleanly.

Not proposing: no default change, no Linux page-cache tricks, no multi-disk sharding in v1, no change to the warm tier's admission policy.

What do you do today instead?

Three bad options, all silent: (a) --mmap-experts and accept the re-read waste (the 797 GB arm); (b) a --resident-budget-gib guess that may be too small (the −9% arm) or sized for a context you are not running (the 512K reversal); (c) #5365's route — a giant pagefile and hope. None of them can see which regime they are in; the engine can.

Originally created by @yeyeyeason on GitHub (Nov 6, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/5391 ### Area [Engine] (speed, kernels, models, the server and API) ### What do you want to do? A scope proposal before any code (per CONTRIBUTING.md): a **managed cold tier** for experts — today the experts the GPU does not hold are either copied into RAM (`--resident-budget-gib`, the ranked "warm" tier) or left to the OS file cache (`--mmap-experts` / GGUF-in-place), with nothing in between. When RAM cannot hold the rest of the experts, every cold expert read is un-prioritized, un-measured and un-managed. This proposal: make that remainder a first-class tier, ranked by the same expert profile the warm tier uses, with its own accounting and (later) prefetch. We follow the release notes' own vocabulary — the VRAM cache, the RAM copy and the file reads are the hot, warm and **cold** tiers. The first two exist; this is about the third. **Who needs it.** Anyone whose model is bigger than RAM-plus-VRAM: a 32 GB PC running UD-Q4_K_XL (59 GiB of experts), a 96 GB PC running Q8_0 (128 GiB) or DeepSeek-V4.1 (2xx GB), and — the vivid case — #5365's 81 GB IQ3_S on 32 GB of RAM plus a 500 GB pagefile across three SATA SSDs. That user is running the cold tier *through the Windows pagefile* with no priority, no ranking and no visibility. The engine already knows which experts are hot (the profile), and already does ranked SSD reads elsewhere (`--ple-io direct`); the cold tier is the missing third application of the same idea. **The measured problem.** On this machine (2x RTX 4060 Ti 16 GB, i5-10600KF, 96 GB RAM, Windows 11; SC117 Qwen3.8-Flash-Next IQ3_S and Unsloth UD-Q4_K_XL, temperature 0, frozen profile, engine-measured decode; RAM-constrained arms simulated by allocating and touching memory down to the target free RAM), pure mmap and a ranked warm tier differ by: | Model / regime | Pure mmap | Ranked warm tier | Change | | --- | ---: | ---: | ---: | | UD-Q4_K_XL, 59 GiB complement, budget 46 GiB | 11.5 tok/s | 20.2 tok/s | **+76%** | | UD-Q4_K_XL, budget 35 GiB | 11.5 tok/s | 14.0 tok/s | +22% | | UD-Q4_K_XL, full warm (60 GiB) | 11.5 tok/s | 27.7 tok/s | +142% | | IQ3_S, 16 GB free RAM (complement 28.5 GiB), budget 2 GiB | 18.8 tok/s | 23.4 tok/s | +24% | | IQ3_S, 16 GB free RAM + 1M context, 130K-token recall task | 11.0 tok/s | 13.9 tok/s | +26% | | IQ3_S, 32 GB free RAM + 1M context, recall | 9.1 tok/s | 11.9 tok/s | +31% | (1M-context rows on engine 0.1.56; re-checked on 0.1.57 / v0.2.11: +16% and +26% — the tier still wins, see "Relation to the 0.2.11 CPU-share change" below.) The mechanism is visible in the engine's own per-arm logs: over the same request set, the pure-mmap UD-Q4_K_XL arm read **797 GB** from the SSD while the 46 GiB warm-tier arm read **64 GB** — the OS file cache re-reads the same cold experts over and over (12x the bytes for the same work), while the ranked tier reads each cold expert about once. That re-read factor is the waste a managed cold tier removes. **The reversal that makes this a placement-policy problem, not just a bigger-budget problem.** The warm tier is not always right, and the engine has no way to say so today. At 1M context the KV cache's pinned RAM (~6.2 GiB, engine-logged) squeezes the page cache, and the tier wins; at 512K the same machine frees ~3.1 GiB back, the page cache covers the hot subset of a 28.5 GiB complement, and **the tier loses** (measured: 16 GB RAM + IQ3_S, 512K: mmap 24.5 vs tier 23.1 tok/s, −6%; the same scenario at 1M: tier +26%). The opposite failure exists too: UD-Q4_K_XL at 1M with a 13 GiB budget that covers only ~22% of the complement went −9% versus mmap — a pinned tier too small to matter steals RAM from the page cache serving the rest. So the value of a managed tier is a function of (complement size, free RAM, context length, budget) — four things the engine can see and the person cannot. A user who copies a 1M-tuned config to a 512K session, or vice versa, silently lands in the wrong regime in either direction. **Proposed shape (opt-in, engine-side, small first step).** 1. Name the third tier: the docs, `--stats` and Monitor already report VRAM-cache / RAM-resident / file reads; align them under hot / warm / cold so the placement story is one model. No behavior change. 2. Give the cold tier a ranked read path: when a cold expert is needed, read it through the same profile ranking the warm tier uses (hottest-first admission into a small cold-read staging area, cold experts admitted/demoted by the profile the engine already maintains). This is `--resident-budget-gib`'s ranking applied below the RAM line, not a new policy. 3. Report it: cold reads, cold bytes, cold read latency and the re-read factor (bytes read per unique blob) per tier in `--stats` / `/metrics`, so a person can see which regime they are in — including "your budget is too small; mmap would serve you better." 4. Later, context-aware budgeting: the 512K↔1M reversal data above is the case for the engine deriving (or at least warning about) `--resident-budget-gib` from `--max-context`, free RAM and the complement size. Prefetch (profile-predicted reads ahead of the verify window) is deliberately out of the first step; the ranked read path and the accounting come first, with prefetch as a follow-up once the read pattern is measured. **Existing foundations this builds on.** `--resident-budget-gib` already ranks and admits by the profile; `--ple-io direct` already does ranked SSD reads of the 28.8 GB PLE table (the I/O pattern exists); the GGUF-in-place file tier already reads experts from the files (the transport exists); the profile (`--expert-profile`, `--expert-profile-save`) already knows the hot set. The change is to extend ranking and accounting below the RAM line — not a new subsystem. **Validation plan.** Same-machine A/B, mmap vs budget, at 128K/512K/1M across the two RAM simulations and both models (the tables above are that data, per-request JSON retained); a second model family (DeepSeek-V4.1 2.00 bpw) as the extreme case is planned and named up front; quality unchanged (placement does not touch math); every arm's engine logs kept, failures included. The reversal scenarios are part of the validation matrix on purpose: a placement policy that cannot say "mmap is better here" is not done. **Relation to the 0.2.11 CPU-share change** (measured, so it belongs here): 0.2.11's CPU/upload share for missed experts (measured speed, ceiling 0.95) speeds up the *GPU-side* miss path — on the same machine it moved DFlash2 decode +34% on code — but it does **not** help the *disk-side* miss path these arms live in: both cold-tier arms' recall decode dropped ~20% on 0.1.57 (16 GB arm: mmap 11.0→8.7, tier 13.9→10.1), and the tier's advantage held (+26%→+16%, +31%→+26%). The two mechanisms sit on different bottlenecks (PCIe/CPU vs SSD bandwidth) and are complementary, not competing. The 0.1.57 low-RAM recall regression is separately worth its own report once reproduced cleanly. **Not proposing:** no default change, no Linux page-cache tricks, no multi-disk sharding in v1, no change to the warm tier's admission policy. ### What do you do today instead? Three bad options, all silent: (a) `--mmap-experts` and accept the re-read waste (the 797 GB arm); (b) a `--resident-budget-gib` guess that may be too small (the −9% arm) or sized for a context you are not running (the 512K reversal); (c) #5365's route — a giant pagefile and hope. None of them can see which regime they are in; the engine can.
Author
Owner

@yeyeyeason commented on GitHub (Nov 6, 2026):

Follow-up data (engine 0.1.56 → 0.1.57, five more experiment sets since the proposal)

The proposal's tables came from one machine (2x RTX 4060 Ti 16 GB, i5-10600KF, 96 GB RAM, Windows 11). Since then we ran five more sets on the same box, including the second engine line, and one correction to our own table.

1. Correction to the table above. The "full warm (60 GiB) +142%" row is a ceiling reference, not a cold-tier gain: budget 60 GiB ≥ the 59.1 GiB complement means every expert sits in RAM/VRAM with zero cold reads — it measures what memory capacity is worth, not what the tier earns. The cold-tier gains in the not-fitting regime are +22% (35 GiB budget) to +76% (46 GiB budget). We have annotated the local report accordingly.

2. The tier survives v0.2.11 (engine 0.1.57). Re-ran the 1M-context sponge arms on 0.1.57: the tier's recall advantage holds (+16% and +26%, vs +26% and +31% on 0.1.56). Both arms' recall decode dropped ~20% on the new engine (mmap 11.0→8.7, tier 13.9→10.1) — an engine-level change worth its own report once reproduced cleanly. The tier advantage itself is intact.

3. A bidirectional reversal the proposal predicted, measured. Halving the context (1M → 512K) frees ~3.1 GiB of pinned KV RAM back to the page cache, and the tier's advantage flips sign for IQ3_S at 16 GB (mmap 24.5 vs tier 23.1 tok/s, −6%) while growing for UD-Q4_K_XL at 32 GB (+26%). The tier's value is a function of (complement, free RAM, context, budget) — the four things the engine can see. A fixed budget cannot follow that; this is the case for context-aware budgeting.

4. The DeepSeek engine line replicates the tier's value and the under-sized-budget law. strata-dsv41 0.1.57, DeepSeek-V4.1-Flash 2.00 bpw (113.9 GiB routed experts + 110.6 GiB Engram), 128K, full 96 GB RAM, no simulation:

Arm Short-task mean
--ssd-cache 0 (managed store off; pure file path) 6.3 tok/s
--ssd-cache 48 (forced, undersized) 7.7 tok/s (−6% vs auto)
default (store auto-sized 68.4 GiB, profile-prefilled) 8.1 tok/s (+29%)

Two laws from our Qwen data replicate on this line: the managed tier wins big when the complement far exceeds RAM (+29%), and an under-sized pinned tier is a negative asset (48 GiB forced < auto's sizing → −6% vs auto; the same shape as Qwen's −9% at 13 GiB for a 59 GiB complement). We also swept --vram-experts 0.30/0.50/0.70: every manual share landed below the engine's own auto placement (6.0/6.3/7.0 vs 8.1) — the engine's layer-level placement beats hand-picked ratios, one more argument for engine-side scheduling over person-side guessing.

5. The read-path question, measured on the Qwen engine (phase 1). The engine already ships the unbuffered path (open_direct, FILE_FLAG_NO_BUFFERING/O_DIRECT) with a heuristic (file_tier_unbuffered) choosing between buffered and direct. In the squeezed regime (16 GB free, 1 GiB budget, 1M context), the heuristic moved both arms to unbuffered, so we compared against the buffered arm from set (1) at 68.9 GiB free:

Recall segment Disk bytes read Decode
buffered (page cache, when the heuristic believes it fits) 2,350 GB 6.0 tok/s
forced unbuffered (STRATA_UNBUFFERED_LOAD=1) 1,727 GB (−26%) 7.4 tok/s (+23%)

Byte saving ≈ speed gain. But this comes with the boundary condition the repo's own history records (#773: forced unbuffered in the no-budget mmap mode re-read 163-629 GB and halved speed — there the page cache IS the tier). Both paths have failure modes; the structural fix is a managed arena that reads each cold expert once (what dsv41's ExpertStore does and what the Qwen engine's budget mode lacks below its pinned tier).

What we propose to do with this (unchanged scope, sharpened)

  1. hot/warm/cold naming in --stats//metrics (no behavior change);
  2. ranked cold reads below the pinned budget — concretely: port the pattern of src/dsv41/ds4_store.hpp's ExpertStore (arena + LRU/LFU + profile prefill) to the Qwen engine's budget mode, opt-in;
  3. per-tier reporting including the re-read factor and the two negative regimes ("your cache fits; mmap serves you better" / "your budget is too small; raise it or turn it off");
  4. context-aware budgeting from the reversal data.

Hardware reference for anyone re-verifying (from our box and the community): expert-share-in-VRAM ↔ speed tier is steep — all-experts-in-VRAM boxes land ~59-100 tok/s on DeepSeek 2.00 bpw while CPU-lane-bound boxes land 6-26. On this consumer box (dual-channel DDR4, one NVMe), 40+ tok/s on this model is a memory-bandwidth wall, not a software gap; the tier work raises the software floor (+29% measured) and the punch-hole/dedup path (next step) shrinks the SSD footprint.

All arms' per-request JSON and engine logs retained; failures included; quality unchanged everywhere (placement does not touch math).

<!-- gh-comment-id:6688916873 --> @yeyeyeason commented on GitHub (Nov 6, 2026): ## Follow-up data (engine 0.1.56 → 0.1.57, five more experiment sets since the proposal) The proposal's tables came from one machine (2x RTX 4060 Ti 16 GB, i5-10600KF, 96 GB RAM, Windows 11). Since then we ran five more sets on the same box, including the second engine line, and one correction to our own table. **1. Correction to the table above.** The "full warm (60 GiB) +142%" row is a **ceiling reference, not a cold-tier gain**: budget 60 GiB ≥ the 59.1 GiB complement means every expert sits in RAM/VRAM with **zero cold reads** — it measures what memory capacity is worth, not what the tier earns. The cold-tier gains in the not-fitting regime are **+22% (35 GiB budget) to +76% (46 GiB budget)**. We have annotated the local report accordingly. **2. The tier survives v0.2.11 (engine 0.1.57).** Re-ran the 1M-context sponge arms on 0.1.57: the tier's recall advantage holds (+16% and +26%, vs +26% and +31% on 0.1.56). Both arms' recall decode dropped ~20% on the new engine (mmap 11.0→8.7, tier 13.9→10.1) — an engine-level change worth its own report once reproduced cleanly. The tier advantage itself is intact. **3. A bidirectional reversal the proposal predicted, measured.** Halving the context (1M → 512K) frees ~3.1 GiB of pinned KV RAM back to the page cache, and the tier's advantage flips sign for IQ3_S at 16 GB (mmap 24.5 vs tier 23.1 tok/s, −6%) while growing for UD-Q4_K_XL at 32 GB (+26%). The tier's value is a function of (complement, free RAM, context, budget) — the four things the engine can see. A fixed budget cannot follow that; this is the case for context-aware budgeting. **4. The DeepSeek engine line replicates the tier's value and the under-sized-budget law.** strata-dsv41 0.1.57, DeepSeek-V4.1-Flash 2.00 bpw (113.9 GiB routed experts + 110.6 GiB Engram), 128K, full 96 GB RAM, no simulation: | Arm | Short-task mean | | --- | ---: | | `--ssd-cache 0` (managed store off; pure file path) | 6.3 tok/s | | `--ssd-cache 48` (forced, undersized) | 7.7 tok/s (−6% vs auto) | | default (store auto-sized 68.4 GiB, profile-prefilled) | **8.1 tok/s (+29%)** | Two laws from our Qwen data replicate on this line: the managed tier wins big when the complement far exceeds RAM (+29%), and **an under-sized pinned tier is a negative asset** (48 GiB forced < auto's sizing → −6% vs auto; the same shape as Qwen's −9% at 13 GiB for a 59 GiB complement). We also swept `--vram-experts` 0.30/0.50/0.70: every manual share landed below the engine's own auto placement (6.0/6.3/7.0 vs 8.1) — the engine's layer-level placement beats hand-picked ratios, one more argument for engine-side scheduling over person-side guessing. **5. The read-path question, measured on the Qwen engine (phase 1).** The engine already ships the unbuffered path (`open_direct`, `FILE_FLAG_NO_BUFFERING`/`O_DIRECT`) with a heuristic (`file_tier_unbuffered`) choosing between buffered and direct. In the squeezed regime (16 GB free, 1 GiB budget, 1M context), the heuristic moved both arms to unbuffered, so we compared against the buffered arm from set (1) at 68.9 GiB free: | Recall segment | Disk bytes read | Decode | | --- | ---: | ---: | | buffered (page cache, when the heuristic believes it fits) | 2,350 GB | 6.0 tok/s | | forced unbuffered (`STRATA_UNBUFFERED_LOAD=1`) | **1,727 GB (−26%)** | **7.4 tok/s (+23%)** | Byte saving ≈ speed gain. But this comes with the boundary condition the repo's own history records (#773: forced unbuffered in the no-budget mmap mode re-read 163-629 GB and halved speed — there the page cache IS the tier). Both paths have failure modes; the structural fix is a managed arena that reads each cold expert once (what dsv41's `ExpertStore` does and what the Qwen engine's budget mode lacks below its pinned tier). ### What we propose to do with this (unchanged scope, sharpened) 1. hot/warm/cold naming in `--stats`/`/metrics` (no behavior change); 2. ranked cold reads below the pinned budget — concretely: port the pattern of `src/dsv41/ds4_store.hpp`'s `ExpertStore` (arena + LRU/LFU + profile prefill) to the Qwen engine's budget mode, opt-in; 3. per-tier reporting including the re-read factor and the two negative regimes ("your cache fits; mmap serves you better" / "your budget is too small; raise it or turn it off"); 4. context-aware budgeting from the reversal data. Hardware reference for anyone re-verifying (from our box and the community): expert-share-in-VRAM ↔ speed tier is steep — all-experts-in-VRAM boxes land ~59-100 tok/s on DeepSeek 2.00 bpw while CPU-lane-bound boxes land 6-26. On this consumer box (dual-channel DDR4, one NVMe), 40+ tok/s on this model is a memory-bandwidth wall, not a software gap; the tier work raises the software floor (+29% measured) and the punch-hole/dedup path (next step) shrinks the SSD footprint. All arms' per-request JSON and engine logs retained; failures included; quality unchanged everywhere (placement does not touch math).
Author
Owner

@yeyeyeason commented on GitHub (Nov 7, 2026):

Follow-up: the punch experiment's fix — a persistent cold store (design + request for scope agreement)

Test A (the comment above) showed the missing piece precisely: the ExpertStore's arena is rebuilt from the GGUF at every start, so punched regions enter the arena as zeros and the model silently degrades (396 → 42). This comment proposes the missing piece and asks for scope agreement before any code.

The design in one line: let the arena's source of truth be a dedicated cold-store file (cold-store.bin) instead of the GGUF, so the GGUF's expert bytes become removable duplicates.

Mechanism (mapping the pieces that already exist in the repo):

  1. Write side (one-time, offline). A small tool reads the model's GGUF expert extents (the ds4 tensors.txt map already carries every expert tensor's file/offset/size) and writes them contiguously into cold-store.bin beside the pack, with a manifest (per-layer offsets, sha256 of every region, the source shards' sizes and mtimes). This is punch_gguf.py's map reader with a writer instead of a puncher — the format is ours to define, ~200 lines.

  2. Read side (engine change, dsv41 first). ExpertStore's startup fill gets one new source branch: if cold-store.bin exists and its manifest matches (shard sizes/mtimes unchanged, region hashes spot-checked), fill the arena from it; otherwise fill from the GGUF as today and log which source was used. Everything else — LRU/LFU, prefetch, stats — is untouched. The change is one read-source switch plus one validation pass, opt-in via the presence of the file (no new flag needed: a pack with a cold store uses it).

  3. Consistency guard (the protection chain, learned the hard way). Test A's silent degradation is exactly what the validation must prevent: the manifest records the punched state (which GGUF regions are holes) and the store's region hashes; at startup, a mismatch (file replaced, store truncated) refuses to load with a loud error — never zeros into the arena.

  4. Punch side (then, and only then). With the cold store validated at startup, punch_gguf.py's guard lifts for packs that carry a matching cold-store.bin: the GGUF's expert regions are released (47.6 GiB measured in test A), the model restarts cleanly from the store.

Why dsv41 first: the ExpertStore already exists there (measured +29% over the pure file path); the cold store completes its story (restart-safe + dedup) with one read-source branch. Porting to the Qwen engine then ships the whole pattern (arena + cold store + punch) as one coherent feature — the #5391 proposal's "managed cold tier" with its dedup payoff included.

Validation plan: round-trip on this box (DeepSeek 2.00 bpw): baseline → cold-store write → punch 47.6 GiB → restart → byte-identical answers to baseline (temperature 0) → decode within noise → restart again → same. Failures included; the marker/hash chain exercised at every step.

Not in scope: no default change for packs without a cold store; no Qwen engine change in the first PR; no multi-disk spread yet (the cold store is one file; spreading it is a follow-up).

Sequencing question for the maintainer: does this fit the #5391 direction as the first concrete PR (dsv41 read-source branch + the two tools), with the Qwen port as the second?

<!-- gh-comment-id:6701024447 --> @yeyeyeason commented on GitHub (Nov 7, 2026): ### Follow-up: the punch experiment's fix — a persistent cold store (design + request for scope agreement) Test A (the comment above) showed the missing piece precisely: the ExpertStore's arena is rebuilt from the GGUF at every start, so punched regions enter the arena as zeros and the model silently degrades (396 → 42). This comment proposes the missing piece and asks for scope agreement before any code. **The design in one line: let the arena's source of truth be a dedicated cold-store file (`cold-store.bin`) instead of the GGUF, so the GGUF's expert bytes become removable duplicates.** Mechanism (mapping the pieces that already exist in the repo): 1. **Write side (one-time, offline).** A small tool reads the model's GGUF expert extents (the ds4 `tensors.txt` map already carries every expert tensor's file/offset/size) and writes them contiguously into `cold-store.bin` beside the pack, with a manifest (per-layer offsets, sha256 of every region, the source shards' sizes and mtimes). This is `punch_gguf.py`'s map reader with a writer instead of a puncher — the format is ours to define, ~200 lines. 2. **Read side (engine change, dsv41 first).** `ExpertStore`'s startup fill gets one new source branch: if `cold-store.bin` exists and its manifest matches (shard sizes/mtimes unchanged, region hashes spot-checked), fill the arena from it; otherwise fill from the GGUF as today and log which source was used. Everything else — LRU/LFU, prefetch, stats — is untouched. The change is one read-source switch plus one validation pass, opt-in via the presence of the file (no new flag needed: a pack with a cold store uses it). 3. **Consistency guard (the protection chain, learned the hard way).** Test A's silent degradation is exactly what the validation must prevent: the manifest records the punched state (which GGUF regions are holes) and the store's region hashes; at startup, a mismatch (file replaced, store truncated) refuses to load with a loud error — never zeros into the arena. 4. **Punch side (then, and only then).** With the cold store validated at startup, `punch_gguf.py`'s guard lifts for packs that carry a matching `cold-store.bin`: the GGUF's expert regions are released (47.6 GiB measured in test A), the model restarts cleanly from the store. **Why dsv41 first:** the ExpertStore already exists there (measured +29% over the pure file path); the cold store completes its story (restart-safe + dedup) with one read-source branch. **Porting to the Qwen engine** then ships the whole pattern (arena + cold store + punch) as one coherent feature — the #5391 proposal's "managed cold tier" with its dedup payoff included. **Validation plan:** round-trip on this box (DeepSeek 2.00 bpw): baseline → cold-store write → punch 47.6 GiB → restart → byte-identical answers to baseline (temperature 0) → decode within noise → restart again → same. Failures included; the marker/hash chain exercised at every step. **Not in scope:** no default change for packs without a cold store; no Qwen engine change in the first PR; no multi-disk spread yet (the cold store is one file; spreading it is a follow-up). Sequencing question for the maintainer: does this fit the #5391 direction as the first concrete PR (dsv41 read-source branch + the two tools), with the Qwen port as the second?
Author
Owner

@yeyeyeason commented on GitHub (Nov 7, 2026):

The cold store is now validated end-to-end on real hardware

Following up on the design comment above: the whole scheme (tools + engine patch) is implemented and verified on this box (DeepSeek-V4.1-Flash 2.00 bpw, 2x RTX 4060 Ti, engine built from current main + the patch below).

The round-trip, measured:

Stage math (17*23+5) recall (Australia's capital) Disk
baseline 396 ✓ Canberra ✓ full
47.6 GiB hole-punched + cold-store boot 396 ✓ Canberra ✓ -47.6 GiB
restored 396 ✓ Canberra ✓ full

The engine's own log line: ds4: cold store active: reads served from cold-store.bin (46077 entries; misses read the GGUF) — the arena fills from the cold store while the GGUF's expert regions are holes. Answers are identical to the baseline.

The three states we measured — each proves one part of the design:

Configuration Result
punch, no cold store silent corruption: 396 → 42, Canberra → Sydney (the failure mode that motivated the protection chain)
punch + cold store, original fingerprints only correct refusal: the punch changes the shard mtime, and the check refuses loudly instead of reading holes
punch + cold store + record-punch (dual fingerprints) everything correct — the punch is accepted as ours, a re-downloaded file would still be refused

What exists now (all opt-in, default path unchanged):

  1. cold_store.py (~300 lines, standalone): write (129.7 GiB store, 47,229 regions, per-region sha256, ~10 min), verify (hash + source fingerprint check), usage (what a start would decide), record-punch (record the post-punch shard fingerprints as accepted).
  2. cold-store.map v2: the engine's binary map — 46,077 (layer, expert, role) offsets plus per-shard dual fingerprints (original + punched), magic-checked, dims-checked against the model.
  3. An engine patch (~120 lines in src/dsv41/ds4_model.cu + a small addition to ds4_store.hpp): DS4_COLD_STORE=1 opens the pack's cold-store.bin, validates the map, copies the per-role offset tables into the store's geometry, and start_fill serves reads from the cold-store fd; misses fall back to the GGUF; fingerprint mismatch refuses loudly. No flag: nothing changes.

Why we validated before proposing code: the first implementation had six real bugs, every one of which produced a plausible-looking but wrong system — an offset-gap sizing bug that swallowed 5.7 GiB of non-expert tail data into a fake region; a manifest without tensor identity (the engine could not map (layer, expert, role)); the pack-vs-model directory confusion; mtime granularity (float seconds in the tool vs time_t integers in the engine — a fingerprint that never matched); a null dereference after std::move; and a role-order mismatch (the engine's parts = {w1, w3, w2} = gate/up/down vs the tool's w1/w2/w3, which produced NaN weights that looked like an engine bug). Three of the six only manifest as silent wrongness or a crash deep in startup — a paper design review would not have caught them.

Ready for the PR if the direction fits: the engine patch + cold_store.py + the punch integration as one PR (dsv41 only, no default change), with this round-trip as the validation data. The Qwen-engine port of the whole pattern (arena + cold store + punch) follows the #5391 shape as the second step. We can also share the per-request JSON and engine logs for every stage above.

<!-- gh-comment-id:6704893227 --> @yeyeyeason commented on GitHub (Nov 7, 2026): ## The cold store is now validated end-to-end on real hardware Following up on the design comment above: the whole scheme (tools + engine patch) is implemented and verified on this box (DeepSeek-V4.1-Flash 2.00 bpw, 2x RTX 4060 Ti, engine built from current main + the patch below). **The round-trip, measured:** | Stage | math (17*23+5) | recall (Australia's capital) | Disk | | --- | --- | --- | --- | | baseline | 396 ✓ | Canberra ✓ | full | | **47.6 GiB hole-punched + cold-store boot** | **396 ✓** | **Canberra ✓** | **-47.6 GiB** | | restored | 396 ✓ | Canberra ✓ | full | The engine's own log line: `ds4: cold store active: reads served from cold-store.bin (46077 entries; misses read the GGUF)` — the arena fills from the cold store while the GGUF's expert regions are holes. Answers are identical to the baseline. **The three states we measured — each proves one part of the design:** | Configuration | Result | | --- | --- | | punch, no cold store | silent corruption: 396 → 42, Canberra → Sydney (the failure mode that motivated the protection chain) | | punch + cold store, original fingerprints only | **correct refusal**: the punch changes the shard mtime, and the check refuses loudly instead of reading holes | | punch + cold store + `record-punch` (dual fingerprints) | everything correct — the punch is accepted as ours, a re-downloaded file would still be refused | **What exists now (all opt-in, default path unchanged):** 1. `cold_store.py` (~300 lines, standalone): `write` (129.7 GiB store, 47,229 regions, per-region sha256, ~10 min), `verify` (hash + source fingerprint check), `usage` (what a start would decide), `record-punch` (record the post-punch shard fingerprints as accepted). 2. `cold-store.map` v2: the engine's binary map — 46,077 `(layer, expert, role)` offsets plus per-shard dual fingerprints (original + punched), magic-checked, dims-checked against the model. 3. An engine patch (~120 lines in `src/dsv41/ds4_model.cu` + a small addition to `ds4_store.hpp`): `DS4_COLD_STORE=1` opens the pack's cold-store.bin, validates the map, copies the per-role offset tables into the store's geometry, and `start_fill` serves reads from the cold-store fd; misses fall back to the GGUF; fingerprint mismatch refuses loudly. No flag: nothing changes. **Why we validated before proposing code:** the first implementation had six real bugs, every one of which produced a plausible-looking but wrong system — an offset-gap sizing bug that swallowed 5.7 GiB of non-expert tail data into a fake region; a manifest without tensor identity (the engine could not map `(layer, expert, role)`); the pack-vs-model directory confusion; mtime granularity (float seconds in the tool vs `time_t` integers in the engine — a fingerprint that never matched); a null dereference after `std::move`; and a role-order mismatch (the engine's `parts = {w1, w3, w2}` = gate/up/down vs the tool's w1/w2/w3, which produced NaN weights that looked like an engine bug). Three of the six only manifest as silent wrongness or a crash deep in startup — a paper design review would not have caught them. **Ready for the PR if the direction fits:** the engine patch + `cold_store.py` + the punch integration as one PR (dsv41 only, no default change), with this round-trip as the validation data. The Qwen-engine port of the whole pattern (arena + cold store + punch) follows the #5391 shape as the second step. We can also share the per-request JSON and engine logs for every stage above.
Author
Owner

@bahooo22 commented on GitHub (Nov 7, 2026):

Data point from a single-GPU hybrid build (Windows 11, 32 GiB RAM, RTX 3060 Ti 8 GiB, qwen35moe
KAT IQ4_XS, KV q4_0):

  • The routed experts are 16.34 GiB in host memory; 37 of 41 layers fit the pinned arena, the rest
    come from the OS file cache.
  • A startup gate requires 18 GiB free RAM before the load (27.7 GiB free at the last run); below
    that the engine is not started at all.
  • The prompt chunk size is what sets the host budget: on a 25 GiB Q5 model --prefill 2048 fails
    at cudaHostAlloc(E.cpu_out) (out of memory), while --prefill 512 runs; on IQ4_XS at 128k the
    engine holds 2.17 GiB VRAM free plus a 256 MiB super-chunk buffer.
  • The number that matters for the cold tier is therefore not total RAM but the gap between the
    warm (pinned) tier and the largest prompt chunk: 18 GiB gate - 16.34 GiB experts ~= 1.7 GiB for
    KV, staging and the OS.

Per-tier accounting would already be useful here: today the only signals are the RAM gate and the
expert H2D counter.

<!-- gh-comment-id:6705132500 --> @bahooo22 commented on GitHub (Nov 7, 2026): Data point from a single-GPU hybrid build (Windows 11, 32 GiB RAM, RTX 3060 Ti 8 GiB, qwen35moe KAT IQ4_XS, KV q4_0): - The routed experts are 16.34 GiB in host memory; 37 of 41 layers fit the pinned arena, the rest come from the OS file cache. - A startup gate requires 18 GiB free RAM before the load (27.7 GiB free at the last run); below that the engine is not started at all. - The prompt chunk size is what sets the host budget: on a 25 GiB Q5 model `--prefill 2048` fails at `cudaHostAlloc(E.cpu_out)` (out of memory), while `--prefill 512` runs; on IQ4_XS at 128k the engine holds 2.17 GiB VRAM free plus a 256 MiB super-chunk buffer. - The number that matters for the cold tier is therefore not total RAM but the gap between the warm (pinned) tier and the largest prompt chunk: 18 GiB gate - 16.34 GiB experts ~= 1.7 GiB for KV, staging and the OS. Per-tier accounting would already be useful here: today the only signals are the RAM gate and the expert H2D counter.
Author
Owner

@yeyeyeason commented on GitHub (Nov 7, 2026):

Thanks — this is a useful shape of machine for the tier work, and your framing ("the gap between the warm tier and the largest prompt chunk", not total RAM) matches what our measurements see.

A few numbers from our box that map onto yours (2x RTX 4060 Ti 16 GB, 96 GiB RAM, IQ3_S with the complement at 28.5 GiB; RAM-constrained arms simulated by holding RAM):

  • The gap you describe is exactly where the failure modes we measured live. With ~11 GiB free against the 28.5 GiB complement (your class of ratio), the tier-vs-page-cache question flips by workload: long-context recall (130K-token prompt + decode) gains 16-31% from a managed 1-13 GiB pinned tier across both engine lines, while short tasks are RAM/compute-bound and show nothing.
  • The "budget must cover the complement" rule has a measured negative tail: an undersized pinned tier (13 GiB against a 59 GiB complement) measured 9% SLOWER than no tier at all — the pinning steals page cache from the experts it does not hold. Your 16.34 GiB arena against a 18 GiB gate is close to the boundary; a chunk overshoot on your machine may be pushing the same lever.
  • Per-tier accounting (reads/bytes/hits per tier + the re-read factor) is the cheapest piece of the proposal and the one that would make your 1.7 GiB gap visible at a glance instead of inferred from the gate; the counters we need all exist in the engines' logs today (the dsv41 line already reports store hits/misses/prefetch per request; the Qwen line reports VRAM/RAM/file split lines but not normalized per tier).
  • The startup gate you describe (18 GiB before load) is also where our cold-store work hooks in: the arena's source can be a dedicated cold-store file instead of the GGUF, which is what makes hole-punching the model file safe (validated end-to-end on this box, round-trip in the comment above). For your 32 GiB machine the same pattern would let the 16.34 GiB arena survive restarts without re-reading the experts from the OS cache cold.

If you get a chance to measure the re-read factor on your build (bytes actually read from the SSD per session vs the 16.34 GiB the tier holds), that is the one number that would tell whether the file tier is thrashing on your workload — our Qwen-line measurements saw 12-22x re-reads in exactly that regime when the pinned tier under-covers.

<!-- gh-comment-id:6706192932 --> @yeyeyeason commented on GitHub (Nov 7, 2026): Thanks — this is a useful shape of machine for the tier work, and your framing ("the gap between the warm tier and the largest prompt chunk", not total RAM) matches what our measurements see. A few numbers from our box that map onto yours (2x RTX 4060 Ti 16 GB, 96 GiB RAM, IQ3_S with the complement at 28.5 GiB; RAM-constrained arms simulated by holding RAM): - The gap you describe is exactly where the failure modes we measured live. With ~11 GiB free against the 28.5 GiB complement (your class of ratio), the tier-vs-page-cache question flips by workload: long-context recall (130K-token prompt + decode) gains 16-31% from a managed 1-13 GiB pinned tier across both engine lines, while short tasks are RAM/compute-bound and show nothing. - The "budget must cover the complement" rule has a measured negative tail: an undersized pinned tier (13 GiB against a 59 GiB complement) measured 9% SLOWER than no tier at all — the pinning steals page cache from the experts it does not hold. Your 16.34 GiB arena against a 18 GiB gate is close to the boundary; a chunk overshoot on your machine may be pushing the same lever. - Per-tier accounting (reads/bytes/hits per tier + the re-read factor) is the cheapest piece of the proposal and the one that would make your 1.7 GiB gap visible at a glance instead of inferred from the gate; the counters we need all exist in the engines' logs today (the dsv41 line already reports store hits/misses/prefetch per request; the Qwen line reports VRAM/RAM/file split lines but not normalized per tier). - The startup gate you describe (18 GiB before load) is also where our cold-store work hooks in: the arena's source can be a dedicated cold-store file instead of the GGUF, which is what makes hole-punching the model file safe (validated end-to-end on this box, round-trip in the comment above). For your 32 GiB machine the same pattern would let the 16.34 GiB arena survive restarts without re-reading the experts from the OS cache cold. If you get a chance to measure the re-read factor on your build (bytes actually read from the SSD per session vs the 16.34 GiB the tier holds), that is the one number that would tell whether the file tier is thrashing on your workload — our Qwen-line measurements saw 12-22x re-reads in exactly that regime when the pinned tier under-covers.
Author
Owner

@bahooo22 commented on GitHub (Nov 7, 2026):

Thanks — we measured it on our box, and the number is at the opposite end from your 12-22x.

Setup: RTX 3060 Ti 8 GiB, 32 GiB RAM, Qwen3.5-MoE 35B-A3B IQ4_XS, q4_0 KV, the 16.34 GiB arena, the q36 engine with super-chunk N=4 and FA. Three phases with psutil (process tree plus per-disk counters): right after /health (the model is not loaded yet, lazy_load), after a warm request (model loaded), after a long run.

phase 96k (86,589 tokens) 128k (121,808 tokens)
model load from disk (D:) 18.94 GiB in 94.2 s 18.55 GiB in 92.8 s
run: model disk 0.15 MiB 0.23 MiB
run: all disks 0.09 GiB 0.44 GiB
disk re-read factor (run bytes / 16.34 GiB) 0.006 0.027

Prefill took 66.1 s at 96k and 111.9 s at 128k.

So the file tier is not thrashing on our workload: the model is 18.5-19 GiB and fits the 32 GiB page cache, and after the load the experts come from RAM. Two consequences:

  • A pinned tier would not buy anything here (there is no re-read to remove), and 16.34 GiB of pinning out of 32 GiB would take memory from the page cache that currently holds the model — the negative tail you measured.
  • The lever that does apply is the cold store: the ~18.5 GiB model read repeats on every serve start (18.94 and 18.55 GiB in two back-to-back runs), so an arena that survives a restart would remove that cost.

A note on the counters: psutil.Process.io_counters().read_bytes does not see mmap reads (soft page faults do not increase ReadTransferCount) — it reported 0.35-0.53 MiB per run. For an mmap engine the per-disk counters are the ones to trust. Our numbers are warm (the page cache holds the model after the load); a cold run needs the standby list dropped with admin rights, which we have not done yet.

The question stands: on a 32 GiB machine, is hole-punching the model file safe when the arena comes from a separate cold-store file that outlives restarts?

<!-- gh-comment-id:6713233537 --> @bahooo22 commented on GitHub (Nov 7, 2026): Thanks — we measured it on our box, and the number is at the opposite end from your 12-22x. Setup: RTX 3060 Ti 8 GiB, 32 GiB RAM, Qwen3.5-MoE 35B-A3B IQ4_XS, q4_0 KV, the 16.34 GiB arena, the q36 engine with super-chunk N=4 and FA. Three phases with `psutil` (process tree plus per-disk counters): right after `/health` (the model is not loaded yet, `lazy_load`), after a warm request (model loaded), after a long run. | phase | 96k (86,589 tokens) | 128k (121,808 tokens) | | --- | ---: | ---: | | model load from disk (D:) | 18.94 GiB in 94.2 s | 18.55 GiB in 92.8 s | | run: model disk | 0.15 MiB | 0.23 MiB | | run: all disks | 0.09 GiB | 0.44 GiB | | disk re-read factor (run bytes / 16.34 GiB) | **0.006** | **0.027** | Prefill took 66.1 s at 96k and 111.9 s at 128k. So the file tier is not thrashing on our workload: the model is 18.5-19 GiB and fits the 32 GiB page cache, and after the load the experts come from RAM. Two consequences: - A pinned tier would not buy anything here (there is no re-read to remove), and 16.34 GiB of pinning out of 32 GiB would take memory from the page cache that currently holds the model — the negative tail you measured. - The lever that does apply is the cold store: the ~18.5 GiB model read repeats on every serve start (18.94 and 18.55 GiB in two back-to-back runs), so an arena that survives a restart would remove that cost. A note on the counters: `psutil.Process.io_counters().read_bytes` does not see mmap reads (soft page faults do not increase `ReadTransferCount`) — it reported 0.35-0.53 MiB per run. For an mmap engine the per-disk counters are the ones to trust. Our numbers are warm (the page cache holds the model after the load); a cold run needs the standby list dropped with admin rights, which we have not done yet. The question stands: on a 32 GiB machine, is hole-punching the model file safe when the arena comes from a separate cold-store file that outlives restarts?
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#3217
No description provided.