mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #1030] [CLOSED] serve: --elastic, an automatic elastic expert cache with a fixed core (opt-in, CUDA VMM) #2977
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#2977
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/1030
Author: @imanu86
Created: 10/6/2026
Status: ❌ Closed
Base:
main← Head:contrib/elastic-core-0139📝 Commits (10+)
fa16567setup: an earlier config that does not parse is skipped, not a crash; configs are written atomically (#459)749d957setup (--backend hip): a system ROCm without the HIP development files falls back to the wheels (#446)5a30024calibrate: the engine's arguments come from the server's engine_args; a failed tuning says why (#447)9f60d13serve, setup: name the small split card that caps the prompt chunk; setup recommends the big card alone (#448)eb8da1d/metrics: each request's speculative draft counts, and their sums in the totals (#457)6a09387setup (--gguf-dir): GGUFs Strata cannot run are named as such, with the --family/--model to use (#444)d6a91e2docs: the Coder is weaker outside code, Chinese/CJK text included; the unpruned sizes for that (#438)d8d4ad3Merge branch 'f-135-eng' into rel-0.1.357b600d5Merge branch 'f-135-small' into rel-0.1.35d9ab843Engine 0.1.35: Windows AMD uses its bundled HIP runtime (#468 #461), the low-RAM resident mode on Windows 32 GB PCs (#467), fixes #460 #459 #446 #447 #457 #448 #444; setup requires it📊 Changes
8 files changed (+730 additions, -21 deletions)
View changed files
📝
CMakeLists.txt(+10 -0)➕
docs/ELASTIC_CACHE.md(+66 -0)📝
include/strata/core/expert_cache.hpp(+30 -0)📝
include/strata/prefill/prefill.hpp(+4 -1)📝
src/core/expert_cache.cpp(+181 -1)📝
src/prefill/prefill.cpp(+10 -7)📝
src/program/generate.cpp(+358 -12)➕
tests/core/expert_cache_elastic_test.cpp(+71 -0)📄 Description
What
--elastic(opt-in,--serve, one CUDA GPU): the expert cache follows the free VRAM automatically while theserver runs. It complements #533's
--vram-elastic(resized on request throughPOST /v1/vram): the two never opentogether, and nothing changes when
--elasticis not given.shrinking never move the arena or the slot-offset table, so the verify plan, the prompt path and the device
residency table keep the pointers they got at startup.
cache, at most 6 GiB;
--elastic-tail-mib), which rotates, is lent, grows and shrinks. The slots before it are afixed core: never lent to the prompt path, never chosen as a swap victim and never shrunk.
--elastic-reserve-mib(500) free. Grows with the most-used missing experts (then the profile'sorder) once the room has lasted
--elastic-stable-ms(5000; doubles after a shrink that follows a growth, back tothe base after 5 minutes without one).
Shrinks at once when the room is gone, at most
--elastic-shrink-step-mib(1024) per check, moving the tail'shottest experts into colder slots first, never a flush. Checked every
--elastic-period-ms(1000) at the decode'ssafe point and at each request's start; the prompt path replans its loan after a resize.
split, peer/remote tiers, the resident CPU complement and HIP keep the fixed cache; no VMM -> the plain arena.
ExpertCache::elastic_grow/elastic_shrink/elastic_mapped_bytes, apart from #533's byte-sizedgrow/shrinkon the segmented arena.Files:
src/core/expert_cache.cpp+ header (VMM arena),src/program/generate.cpp(options, core/tail, policy,loan),
src/prefill/prefill.{hpp,cpp}(host buffers sized for the largest chunk a later relayout can ask for),tests/core/expert_cache_elastic_test.cpp,docs/ELASTIC_CACHE.md,CMakeLists.txt(driver library link, test).Tests (RTX 2080 Ti 22 GB, Windows 11, CUDA 12.6, Release sm_75)
expert_cache_elastic_test(real VMM: grow, shrink, regrow, stable addresses/offsets, preserved bytes,zeroed new slots, unchanged state after rejected requests, fixed reopen),
expert_cache_per_layer_test,expert_profile_save_test,expert_cache_segmented_test: 4/4.--elasticthe output is bit-identical to upstream 0.1.39: teacher forcing with a fixed expertplacement on a code and an explain task, per-position log-probabilities byte for byte equal.
--elasticthe cache started at 6781 slots (core 3357 /tail 3424) and grew +300 experts while VRAM was free; L01 49.4 tok/s, L02 45.8 tok/s, prefill 153.9 s - against
upstream's fixed cache 47.3 / 46.3 tok/s, 153.1 s (run-to-run noise). The gain is not on an idle machine but when
other programs take and return VRAM: the fixed cache must be sized for the worst moment.
Full logs, scripts and the first port on 0.1.38 (numeric gate, 131k/250k dialogues):
https://github.com/imanu86/Strata-2080Ti/tree/evidence/elastic-cache
Origin
Written for the community Strata-2080Ti fork (https://github.com/imanu86/Strata-2080Ti), where it has been the
daily build's default since late September 2026 on a modified RTX 2080 Ti shared with desktop programs. This PR
isolates it from the fork's other changes on top of 0.1.39.
🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.