[PR #2196] [CLOSED] serve: the image encoder only while there are pictures ("elastic": true in the vision section) #3917

Closed
opened 2026-11-07 15:31:39 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/2196
Author: @i-Vladimir-i
Created: 10/13/2026
Status: ❌ Closed

Base: main ← Head: vision-elastic


📝 Commits (2)

  • f879660 serve: the image encoder only while there are pictures ("elastic": true in the vision section)
  • 6ef3384 serve: the elastic encoder's VRAM figure after the driver's counter caught up

📊 Changes

4 files changed (+255 additions, -8 deletions)

View changed files

📝 docs/DETAILS.md (+10 -0)
📝 docs/VRAM_ELASTIC.md (+19 -0)
📝 serve/server.py (+103 -8)
➕ serve/test_vision_elastic.py (+123 -0)

📄 Description

serve: the image encoder only while there are pictures ("elastic": true in the "vision" section, opt-in)

A GPU image encoder holds its VRAM (~1.3-1.5 GB here) for as long as the server runs, so the expert cache is smaller
for every request, with or without pictures. With "vram_elastic": true (#533) the engine can give VRAM back between
requests, so the server can lend the encoder its VRAM only while pictures come.

What it changes (serve/server.py, opt-in; docs in docs/VRAM_ELASTIC.md and the images part of docs/DETAILS.md)

  • "elastic": true in the "vision" section, with the config's "vram_elastic": true: the encoder does not start with
    the server or with a load. "elastic_mib" (default 2048) and "elastic_idle_s" (default 120) set its share and how
    long it stays without a picture. Without "vram_elastic" the server says so and starts the encoder as before.
  • A picture's turn (the FIFO turn an encode already takes, so nothing runs on the GPU beside it): if the encoder is not
    running, the engine's VRAM first keeps elastic_mib free on top of the reserve (the last POST /v1/vram, or 0),
    then the encoder starts. If the cache cannot shrink (the resident low-RAM mode, no --vram-elastic) the encoder
    starts anyway and the log says why.
  • Idle: a thread stops the encoder between requests after elastic_idle_s without a picture and sends VRAM with
    the reserve again; 0 when none was asked, because null (the start's reserve) left the cache a segment or more below
    the size it had (measured: 10446 of 10736 slots with null, 10736 with 0).
  • POST /v1/vram while the encoder runs keeps the asked reserve on top of its share; an unload stops it too.
    Service._vision_down() no longer counts a stopped elastic encoder as down, so a load never starts it.

What it leaves alone: everything without the key (the encoder starts as before; the 725 server tests that were
there pass unchanged), the engine, setup, the CPU encoder.

Checked

  • serve/test_vision_elastic.py (7 tests, fake engine and encoder): the first picture shrinks then starts, later ones
    reuse it, idle stops and grows back to the full size (and not while a request holds the turn or a picture came
    recently), the reserve stacks, an engine that cannot shrink still gets its encoder, an unload lets go, the load never
    starts it, the config keys. Four mutations, each caught: no start in the image turn, growing back to the start's
    reserve (null), the load restarting an elastic encoder, the reserve not stacking.
  • The whole server suite: 732 tests OK (11 skipped; 725 before plus these 7), on this branch (base a0116b2).
  • Live on an R9700 32 GB (gfx1201, ROCm 7.14.1, Linux; HIP's virtual memory from #2189), UD-IQ4_XS with every expert in
    RAM, the BF16 encoder at up to 1,024 tokens: the first picture made the cache keep 2 GiB free and the encoder started
    in 4.7 s taking 1,339 MiB; a request with one picture took 8.6 s including that start (5.0 s on a later cold start,
    the encoder starting in 2.7 s); 2 / 5 / 10 pictures with the encoder running took 3.8 / 5.6 / 9.0 s (~0.45 s to encode
    each, the same as the encoder on a second card); after 60 s idle it stopped and the cache grew back to its full
    size (21,704 of 21,702 MiB).

Not tested: NVIDIA live (the server path is the same; the engine's VRAM there is the existing #533), Windows,
several requests with pictures at once with --parallel (the turn is the same FIFO turn an encode takes today).

A note found on the way: --vram-elastic turns --kv-grow off (the engine says so), so a config with both runs with the
whole K/V in VRAM; on this box that was 9,405 cache slots instead of 10,818. Making the two work together is a separate
change.

🤖 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/2196 **Author:** [@i-Vladimir-i](https://github.com/i-Vladimir-i) **Created:** 10/13/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `vision-elastic` --- ### 📝 Commits (2) - [`f879660`](https://github.com/Niko1221/Strata/commit/f87966021472c1d494a8b7abc98cd70475b1a858) serve: the image encoder only while there are pictures ("elastic": true in the vision section) - [`6ef3384`](https://github.com/Niko1221/Strata/commit/6ef338448626b3657bb8421ddc06c30a168885ce) serve: the elastic encoder's VRAM figure after the driver's counter caught up ### 📊 Changes **4 files changed** (+255 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `docs/DETAILS.md` (+10 -0) 📝 `docs/VRAM_ELASTIC.md` (+19 -0) 📝 `serve/server.py` (+103 -8) ➕ `serve/test_vision_elastic.py` (+123 -0) </details> ### 📄 Description **serve: the image encoder only while there are pictures (`"elastic": true` in the `"vision"` section, opt-in)** A GPU image encoder holds its VRAM (~1.3-1.5 GB here) for as long as the server runs, so the expert cache is smaller for every request, with or without pictures. With `"vram_elastic": true` (#533) the engine can give VRAM back between requests, so the server can lend the encoder its VRAM only while pictures come. **What it changes** (`serve/server.py`, opt-in; docs in `docs/VRAM_ELASTIC.md` and the images part of `docs/DETAILS.md`) - `"elastic": true` in the `"vision"` section, with the config's `"vram_elastic": true`: the encoder does not start with the server or with a load. `"elastic_mib"` (default 2048) and `"elastic_idle_s"` (default 120) set its share and how long it stays without a picture. Without `"vram_elastic"` the server says so and starts the encoder as before. - **A picture's turn** (the FIFO turn an encode already takes, so nothing runs on the GPU beside it): if the encoder is not running, the engine's `VRAM` first keeps `elastic_mib` free on top of the reserve (the last `POST /v1/vram`, or 0), then the encoder starts. If the cache cannot shrink (the resident low-RAM mode, no `--vram-elastic`) the encoder starts anyway and the log says why. - **Idle:** a thread stops the encoder between requests after `elastic_idle_s` without a picture and sends `VRAM` with the reserve again; 0 when none was asked, because `null` (the start's reserve) left the cache a segment or more below the size it had (measured: 10446 of 10736 slots with `null`, 10736 with 0). - `POST /v1/vram` while the encoder runs keeps the asked reserve on top of its share; an unload stops it too. `Service._vision_down()` no longer counts a stopped elastic encoder as down, so a load never starts it. **What it leaves alone:** everything without the key (the encoder starts as before; the 725 server tests that were there pass unchanged), the engine, setup, the CPU encoder. **Checked** - `serve/test_vision_elastic.py` (7 tests, fake engine and encoder): the first picture shrinks then starts, later ones reuse it, idle stops and grows back to the full size (and not while a request holds the turn or a picture came recently), the reserve stacks, an engine that cannot shrink still gets its encoder, an unload lets go, the load never starts it, the config keys. Four mutations, each caught: no start in the image turn, growing back to the start's reserve (`null`), the load restarting an elastic encoder, the reserve not stacking. - The whole server suite: 732 tests OK (11 skipped; 725 before plus these 7), on this branch (base `a0116b2`). - Live on an R9700 32 GB (gfx1201, ROCm 7.14.1, Linux; HIP's virtual memory from #2189), UD-IQ4_XS with every expert in RAM, the BF16 encoder at up to 1,024 tokens: the first picture made the cache keep 2 GiB free and the encoder started in 4.7 s taking 1,339 MiB; a request with one picture took 8.6 s including that start (5.0 s on a later cold start, the encoder starting in 2.7 s); 2 / 5 / 10 pictures with the encoder running took 3.8 / 5.6 / 9.0 s (~0.45 s to encode each, the same as the encoder on a second card); after 60 s idle it stopped and the cache grew back to its full size (21,704 of 21,702 MiB). **Not tested:** NVIDIA live (the server path is the same; the engine's `VRAM` there is the existing #533), Windows, several requests with pictures at once with `--parallel` (the turn is the same FIFO turn an encode takes today). A note found on the way: `--vram-elastic` turns `--kv-grow` off (the engine says so), so a config with both runs with the whole K/V in VRAM; on this box that was 9,405 cache slots instead of 10,818. Making the two work together is a separate change. 🤖 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-07 15:31:39 +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#3917
No description provided.