mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #208] [CLOSED] server: optional idle unload, /unload and /load, a free-VRAM guard (share the GPU with other programs) #2507
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#2507
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/208
Author: @bytethecookie
Created: 9/30/2026
Status: ❌ Closed
Base:
main← Head:idle-unload📝 Commits (3)
ae40c71server: optional idle unload, POST /unload and /load, a free-VRAM guard and a before_load hooka5f49b5server: the image encoder unloads and loads with the engine; docs for sharing the GPUa57f1f8server: review fixes - load() counts as activity, unload() asks the engine to QUIT first, docs: the VRAM check looks at the first GPU📊 Changes
3 files changed (+393 additions, -14 deletions)
View changed files
📝
docs/DETAILS.md(+21 -0)📝
serve/server.py(+199 -13)📝
serve/test_server.py(+173 -1)📄 Description
What
Optional support for sharing the GPU with other programs: Strata can unload the model when it is idle and load it again on the next request. Everything is off by default — without the new options the server behaves exactly as before.
--idle-unload SECONDSidle_unload_s--min-free-vram-mib Nmin_free_vram_mib503"the GPU is in use by another program"--before-load CMDbefore_load(string or list)Plus
POST /unload(409while a request is running) andPOST /load;/healthgains"loaded",/v1/modelslists the model with statusunloaded(like llama.cpp's router, building on #122's endpoints),/propssetsis_sleeping, and/metricsreports the stateunloaded.Why
Strata fills all free VRAM and holds it until the window is closed. On a PC that also games, runs ComfyUI or another model server, that means stopping and starting Strata by hand. With these options it can stay up permanently next to them.
How
restart()path from #27 — the "engine died, start it again" check inrun()now goes through oneensure_loaded()that also handles a deliberate unload.503rather than an error mid-stream._Nvmlclass intelemetry.py; if it can't be read, nothing is refused.busy/queued).Measured
RTX 5060 Ti 16 GB, i5-12400F, 48 GB DDR4, Linux (Docker), Q2_0 with
--mmap-experts, files in the OS cache:POST /unloadreturns after ~0.33 s with the VRAM free (15.7 GB -> 0.76 GB used)--min-free-vram-mib 11000:503after the 15 s wait, model stays unloadedI run it this way next to llama.cpp's router and ComfyUI:
--idle-unload 120 --min-free-vram-mib 11000 --before-load "<script that unloads llama-server's models>".Tests
python -m unittest serve.test_server: the 39 existing tests pass unchanged, plus 9 new ones inSharingTheGpu(unload then reload on the next request,/load, refused while busy, idle unload, the VRAM guard refusing and then loading, unreadable VRAM never refusing,before_loadrunning first, the encoder unloading and starting first, off by default).Notes for review
POST /unloadand/loadfollow the API-key check like the other POST routes but not the_own_pagecheck that/settingshas, since other programs on the machine are the intended callers. The worst a cross-site request could do is unload an idle model.terminate()on Windows is a hard kill, which should be fine for a process between requests, but it is untested.docs/DETAILS.md. Setup does not ask about any of this; it seemed better left as an advanced option.🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.