[PR #1117] [CLOSED] serve: --elastic, an automatic elastic expert cache with a fixed core (opt-in; resubmission of #1030 on the new main) #3039

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

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/1117
Author: @imanu86
Created: 10/6/2026
Status: ❌ Closed

Base: main ← Head: contrib/elastic-core-040


📝 Commits (1)

  • c7f2b44 OPUS-CACHE-Porta su upstream 0.1.40 la cache elastica automatica con nucleo fisso

📊 Changes

8 files changed (+768 additions, -24 deletions)

View changed files

📝 CMakeLists.txt (+10 -0)
➕ docs/ELASTIC_CACHE.md (+72 -0)
📝 include/strata/core/expert_cache.hpp (+30 -0)
📝 include/strata/prefill/prefill.hpp (+4 -1)
📝 src/core/expert_cache.cpp (+182 -2)
📝 src/prefill/prefill.cpp (+10 -7)
📝 src/program/generate.cpp (+389 -14)
➕ tests/core/expert_cache_elastic_test.cpp (+71 -0)

📄 Description

Resubmission of #1030 (closed by the history cleanup), cherry-picked onto the new main (82f46a8) as you suggested,
and brought up to 0.1.40.

What it is. --elastic (opt-in): an automatic elastic expert cache for a card that is shared with desktop programs
whose VRAM use comes and goes while the server runs. The cache is a VMM arena: a fixed core filled from the profile,
plus a tail that grows when VRAM has stayed free and shrinks (in steps, between decode rounds) when it is needed back,
keeping a reserve free. It never opens together with --vram-elastic (#533), which stays the manual control.
Design notes: docs/ELASTIC_CACHE.md.

Since #1030

  • rebased on 0.1.40: the cache's flag is elastic_vmm_ (0.1.40 added std::unique_ptr<VmmRange> vmm_);
  • works with --batch: the elastic step also runs between two batch windows (refused only with --batch-groups > 1);
  • at startup an arena that does not fit (the last chunks' cuMemCreate out of memory) retries up to 4 times, 512 MiB
    smaller each, before falling back to the fixed cache;
  • --kv-grow stays off with --elastic (the K/V would be sized before the arena that it grows into).

Verified (RTX 2080 Ti 22 GB, sm_75, Windows, CUDA 12.6, Qwen3.8-Flash-Next IQ3_XXS):

  • without --elastic, fixed-placement teacher forcing (two prompts, 169 and 595 positions) is byte-identical to
    upstream 0.1.40;
  • the cache CTests pass (expert_cache_elastic_test, _per_layer_test, _segmented_test, expert_profile_save_test);
  • on our fork the same code has run as the daily default since September 30; under a 3 GB allocation by another
    process the tail shrinks between rounds (8.3 -> 5.7 GB) while two answers keep going, then grows back.

Happy to split it into smaller pieces if you prefer (for example the arena alone).

🤖 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/1117 **Author:** [@imanu86](https://github.com/imanu86) **Created:** 10/6/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `contrib/elastic-core-040` --- ### 📝 Commits (1) - [`c7f2b44`](https://github.com/Niko1221/Strata/commit/c7f2b447c34353ab8f7cd6a3fd54581de1a8761b) OPUS-CACHE-Porta su upstream 0.1.40 la cache elastica automatica con nucleo fisso ### 📊 Changes **8 files changed** (+768 additions, -24 deletions) <details> <summary>View changed files</summary> 📝 `CMakeLists.txt` (+10 -0) ➕ `docs/ELASTIC_CACHE.md` (+72 -0) 📝 `include/strata/core/expert_cache.hpp` (+30 -0) 📝 `include/strata/prefill/prefill.hpp` (+4 -1) 📝 `src/core/expert_cache.cpp` (+182 -2) 📝 `src/prefill/prefill.cpp` (+10 -7) 📝 `src/program/generate.cpp` (+389 -14) ➕ `tests/core/expert_cache_elastic_test.cpp` (+71 -0) </details> ### 📄 Description Resubmission of #1030 (closed by the history cleanup), cherry-picked onto the new `main` (82f46a8) as you suggested, and brought up to 0.1.40. **What it is.** `--elastic` (opt-in): an automatic elastic expert cache for a card that is shared with desktop programs whose VRAM use comes and goes while the server runs. The cache is a VMM arena: a fixed core filled from the profile, plus a tail that grows when VRAM has stayed free and shrinks (in steps, between decode rounds) when it is needed back, keeping a reserve free. It never opens together with `--vram-elastic` (#533), which stays the manual control. Design notes: `docs/ELASTIC_CACHE.md`. **Since #1030** - rebased on 0.1.40: the cache's flag is `elastic_vmm_` (0.1.40 added `std::unique_ptr<VmmRange> vmm_`); - works with `--batch`: the elastic step also runs between two batch windows (refused only with `--batch-groups > 1`); - at startup an arena that does not fit (the last chunks' `cuMemCreate` out of memory) retries up to 4 times, 512 MiB smaller each, before falling back to the fixed cache; - `--kv-grow` stays off with `--elastic` (the K/V would be sized before the arena that it grows into). **Verified** (RTX 2080 Ti 22 GB, sm_75, Windows, CUDA 12.6, Qwen3.8-Flash-Next IQ3_XXS): - without `--elastic`, fixed-placement teacher forcing (two prompts, 169 and 595 positions) is byte-identical to upstream 0.1.40; - the cache CTests pass (`expert_cache_elastic_test`, `_per_layer_test`, `_segmented_test`, `expert_profile_save_test`); - on our fork the same code has run as the daily default since September 30; under a 3 GB allocation by another process the tail shrinks between rounds (8.3 -> 5.7 GB) while two answers keep going, then grows back. Happy to split it into smaller pieces if you prefer (for example the arena alone). 🤖 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-04 02:05:08 +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#3039
No description provided.