[PR #805] [CLOSED] Lazy vision encoder: per-GPU elastic expert caches #2841

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

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/805
Author: @jmnargi
Created: 10/4/2026
Status: ❌ Closed

Base: main ← Head: feat/lazy-vision


📝 Commits (10+)

  • 3292cea Add Tesla V100 support and deployment benchmarks
  • 3c6e0d4 Fix Volta prefill GEMM corruption
  • cb708c7 Prefill fast path for Volta: FP16 tensor-core GEMMs, io_uring PLE reads, NVMe storage
  • 648713f Enable Q2_0 MMQ prefill path
  • ecccc8c Limit prefill QSA scoring to live blocks
  • c665c39 Merge pull request #1 from jmnargi/prefill-speed-v100
  • cb96f13 Re-benchmark the V100 fast path on merged main; add the benchmark tool
  • 4686c0f Merge upstream multi-GPU support with V100 compatibility
  • 695a1c2 Remove local identifiers and add benchmark index
  • c05eb32 decode: batch the verify window's per-token kernels (bit-identical)

📊 Changes

274 files changed (+147813 additions, -2103 deletions)

View changed files

📝 .gitignore (+1 -0)
➖ AGENTS.md (+0 -23)
📝 CMakeLists.txt (+62 -20)
📝 README.md (+124 -162)
➕ bench/results/2026-09-28-v100-fastpath/README.md (+46 -0)
➕ bench/results/2026-09-28-v100-fastpath/matrix.json (+80 -0)
➕ bench/results/2026-09-29-baseline-long/matrix.json (+30 -0)
➕ bench/results/2026-09-29-baseline-short/matrix.json (+58 -0)
➕ bench/results/2026-09-29-cool-short/matrix.json (+58 -0)
➕ bench/results/2026-09-29-final-long/matrix.json (+30 -0)
➕ bench/results/2026-09-29-final-s8-128k/matrix.json (+16 -0)
➕ bench/results/2026-09-29-new-long/matrix.json (+30 -0)
➕ bench/results/2026-09-29-new-short/matrix.json (+58 -0)
➕ bench/results/2026-09-29-pr139-triage/baseline-pass1.json (+30 -0)
➕ bench/results/2026-09-29-pr139-triage/baseline-pass2.json (+30 -0)
➕ bench/results/2026-09-29-pr139-triage/ctrl-final-pass1.json (+30 -0)
➕ bench/results/2026-09-29-pr139-triage/ctrl-final-pass2.json (+30 -0)
➕ bench/results/2026-09-29-pr139-triage/ctrl-new-pass1.json (+30 -0)
➕ bench/results/2026-09-29-pr139-triage/ctrl-new-pass2.json (+30 -0)
➕ bench/results/2026-09-29-pr139-triage/notes.md (+68 -0)

...and 80 more files

📄 Description

What

The image encoder (strata-vision, ~1.74 GiB across the GPUs) no longer has to sit in VRAM 24/7. With "lazy": true in the config's "vision" section (plus "vram_elastic": true), it starts on the first image request and unloads after "idle_s" seconds without one — its VRAM stays with the expert caches the rest of the time.

Verified on the 2xV100 service

State Resident experts (both GPUs)
Before (resident vision) 12,688
Lazy boot, vision idle 14,005 (+1,317)
During an image request (vision up) 12,427
60 s idle after it (vision unloaded, caches regrown) 14,005

Image request answered cold in 5.9 s (zero-warm "Red square shape"): per-GPU hand-back → spawn → encode → reply. /metrics expert_slots/expert_cache_mib aggregate across GPUs at every stage.

Engine changes (src/program/generate.cpp, src/core/expert_cache.*)

  • --vram-elastic now segments every layer-split stage cache (it was disabled with a split: "a layer split has a cache per GPU"). Also themed: per-GPU reserves, so the caches can return VRAM to the image encoder (or any other program) and take it back.
  • The VRAM command takes one reserve per GPU: VRAM <r0> [<r1> ...] (CUDA0's, then each stage's; missing values keep the startup reserve). Reply fields are comma lists, one value per cache.
  • Shrink evicts only the layers each cache owns — host_res is one global table whose slot values index whichever cache owns the layer, so an eviction loop over all rows would hit stage-owned slots with the wrong cache's live count.
  • ExpertCache::keep_bytes_for_free: shrink keeps whole segments, so a release request smaller than the tail segment used to round up past the arena and free nothing (GPU1's 412 MiB tail); now the command releases the right segment.
  • Bare VRAM reverts the caches to their full start-up size (the reserve is only the sizing target), so the vision idle-unload path regrows completely — including a short tail segment the conservative grow would otherwise leave unmapped forever.
  • relend() reshapes the prompt-path loan of every part against its own cache (was: the drive's part only).

Server changes (serve/server.py)

  • "vision": {"lazy": true} skips the boot spawn; prepare() starts the encoder inside the request FIFO after the per-GPU VRAM hand-back (the engine is idle; text requests never touch the vision path).
  • Vision idle thread: unloads the encoder after "idle_s"s without image requests and issues a bare VRAM, regrowing both caches to full. Defaults: "vram_mib" [1700, 600] for a layer split, [1800] for one GPU (measured with the shipped BF16 mmproj).
  • POST /v1/vram and the served vram() accept a per-GPU list.
  • /metrics aggregation fix: after a VRAM reply the engine info now sums expert_slots/expert_cache_mib across GPUs (the engine's own INFO line reports the total; a per-GPU reply had reduced it to CUDA0's value).

Docs

docs/DETAILS.md: #533 (per-GPU reserves, bare = full start-up size), new "Lazy vision" section; --vram-elastic help.

Notes/limits: the lazy vision hand-back requires one-request-at-a-time (no "parallel") — documented; VRAM still refuses with --peer-device, the helper caches or the resident low-RAM mode.


🔄 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/805 **Author:** [@jmnargi](https://github.com/jmnargi) **Created:** 10/4/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feat/lazy-vision` --- ### 📝 Commits (10+) - [`3292cea`](https://github.com/Niko1221/Strata/commit/3292cea0ea18b21ce8e24365496b424153d03066) Add Tesla V100 support and deployment benchmarks - [`3c6e0d4`](https://github.com/Niko1221/Strata/commit/3c6e0d42d21ae4fa4f28ed1271818684504b99b2) Fix Volta prefill GEMM corruption - [`cb708c7`](https://github.com/Niko1221/Strata/commit/cb708c735c3bc4d298bd9cd2a67aabf77f84ba18) Prefill fast path for Volta: FP16 tensor-core GEMMs, io_uring PLE reads, NVMe storage - [`648713f`](https://github.com/Niko1221/Strata/commit/648713fb1d34e07082e6a9baf7c67c6138a50032) Enable Q2_0 MMQ prefill path - [`ecccc8c`](https://github.com/Niko1221/Strata/commit/ecccc8c7350225144892778a3535b3defc00cda2) Limit prefill QSA scoring to live blocks - [`c665c39`](https://github.com/Niko1221/Strata/commit/c665c39ef1d0938b3812efe755806ce0e504c23a) Merge pull request #1 from jmnargi/prefill-speed-v100 - [`cb96f13`](https://github.com/Niko1221/Strata/commit/cb96f131ecac76fa5c6200f24eb734f02fcfa922) Re-benchmark the V100 fast path on merged main; add the benchmark tool - [`4686c0f`](https://github.com/Niko1221/Strata/commit/4686c0f1e1388b63d62d1bdef1cb66efa1613fe9) Merge upstream multi-GPU support with V100 compatibility - [`695a1c2`](https://github.com/Niko1221/Strata/commit/695a1c218845ac921d8875f4ec08d357359dbca0) Remove local identifiers and add benchmark index - [`c05eb32`](https://github.com/Niko1221/Strata/commit/c05eb32d65bb6e8487040228cff255035fb765cf) decode: batch the verify window's per-token kernels (bit-identical) ### 📊 Changes **274 files changed** (+147813 additions, -2103 deletions) <details> <summary>View changed files</summary> 📝 `.gitignore` (+1 -0) ➖ `AGENTS.md` (+0 -23) 📝 `CMakeLists.txt` (+62 -20) 📝 `README.md` (+124 -162) ➕ `bench/results/2026-09-28-v100-fastpath/README.md` (+46 -0) ➕ `bench/results/2026-09-28-v100-fastpath/matrix.json` (+80 -0) ➕ `bench/results/2026-09-29-baseline-long/matrix.json` (+30 -0) ➕ `bench/results/2026-09-29-baseline-short/matrix.json` (+58 -0) ➕ `bench/results/2026-09-29-cool-short/matrix.json` (+58 -0) ➕ `bench/results/2026-09-29-final-long/matrix.json` (+30 -0) ➕ `bench/results/2026-09-29-final-s8-128k/matrix.json` (+16 -0) ➕ `bench/results/2026-09-29-new-long/matrix.json` (+30 -0) ➕ `bench/results/2026-09-29-new-short/matrix.json` (+58 -0) ➕ `bench/results/2026-09-29-pr139-triage/baseline-pass1.json` (+30 -0) ➕ `bench/results/2026-09-29-pr139-triage/baseline-pass2.json` (+30 -0) ➕ `bench/results/2026-09-29-pr139-triage/ctrl-final-pass1.json` (+30 -0) ➕ `bench/results/2026-09-29-pr139-triage/ctrl-final-pass2.json` (+30 -0) ➕ `bench/results/2026-09-29-pr139-triage/ctrl-new-pass1.json` (+30 -0) ➕ `bench/results/2026-09-29-pr139-triage/ctrl-new-pass2.json` (+30 -0) ➕ `bench/results/2026-09-29-pr139-triage/notes.md` (+68 -0) _...and 80 more files_ </details> ### 📄 Description ## What The image encoder (strata-vision, ~1.74 GiB across the GPUs) no longer has to sit in VRAM 24/7. With `"lazy": true` in the config's `"vision"` section (plus `"vram_elastic": true`), it starts on the **first image request** and unloads after `"idle_s"` seconds without one — its VRAM stays with the expert caches the rest of the time. ## Verified on the 2xV100 service | State | Resident experts (both GPUs) | | --- | --- | | Before (resident vision) | 12,688 | | Lazy boot, vision idle | **14,005** (+1,317) | | During an image request (vision up) | 12,427 | | 60 s idle after it (vision unloaded, caches regrown) | **14,005** | Image request answered cold in 5.9 s (zero-warm "Red square shape"): per-GPU hand-back → spawn → encode → reply. `/metrics` `expert_slots`/`expert_cache_mib` aggregate across GPUs at every stage. ## Engine changes (src/program/generate.cpp, src/core/expert_cache.*) - `--vram-elastic` now segments **every layer-split stage cache** (it was disabled with a split: "a layer split has a cache per GPU"). Also themed: per-GPU reserves, so the caches can return VRAM to the image encoder (or any other program) and take it back. - The `VRAM` command takes **one reserve per GPU**: `VRAM <r0> [<r1> ...]` (CUDA0's, then each stage's; missing values keep the startup reserve). Reply fields are comma lists, one value per cache. - Shrink evicts only the layers each cache owns — `host_res` is one global table whose slot values index whichever cache owns the layer, so an eviction loop over all rows would hit stage-owned slots with the wrong cache's `live` count. - `ExpertCache::keep_bytes_for_free`: shrink keeps whole segments, so a release request smaller than the tail segment used to round up past the arena and free **nothing** (GPU1's 412 MiB tail); now the command releases the right segment. - Bare `VRAM` reverts the caches to their **full start-up size** (the reserve is only the sizing target), so the vision idle-unload path regrows completely — including a short tail segment the conservative grow would otherwise leave unmapped forever. - `relend()` reshapes the prompt-path loan of **every** part against its own cache (was: the drive's part only). ## Server changes (serve/server.py) - `"vision": {"lazy": true}` skips the boot spawn; `prepare()` starts the encoder inside the request FIFO after the per-GPU `VRAM` hand-back (the engine is idle; text requests never touch the vision path). - Vision idle thread: unloads the encoder after `"idle_s"`s without image requests and issues a bare `VRAM`, regrowing both caches to full. Defaults: `"vram_mib"` `[1700, 600]` for a layer split, `[1800]` for one GPU (measured with the shipped BF16 mmproj). - `POST /v1/vram` and the served `vram()` accept a per-GPU list. - `/metrics` aggregation fix: after a VRAM reply the engine info now sums `expert_slots`/`expert_cache_mib` across GPUs (the engine's own INFO line reports the total; a per-GPU reply had reduced it to CUDA0's value). ## Docs `docs/DETAILS.md`: #533 (per-GPU reserves, bare = full start-up size), new "Lazy vision" section; `--vram-elastic` help. Notes/limits: the lazy vision hand-back requires one-request-at-a-time (no `"parallel"`) — documented; `VRAM` still refuses with `--peer-device`, the helper caches or the resident low-RAM mode. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-04 02:03:30 +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#2841
No description provided.