mirror of
https://github.com/mw00/project-maya.git
synced 2026-12-03 21:08:26 +07:00
[PR #250] [MERGED] Server: unload the model after an idle time (--idle-unload / "idle_unload_s", as Strata's), off by default #425
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
mw00/project-maya#425
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/mw00/project-maya/pull/250
Author: @cryptedy
Created: 10/17/2026
Status: ✅ Merged
Merged: 10/20/2026
Merged by: @mw00
Base:
main← Head:pr/idle-unload📝 Commits (2)
368496bServer: unload the model after an idle time (--idle-unload / "idle_unload_s", as Strata's)2cb1c04Idle unload: tests (a lifecycle mock engine) and docs/SETUP.md📊 Changes
3 files changed (+171 additions, -14 deletions)
View changed files
📝
docs/SETUP.md(+19 -0)📝
serve/server.py(+82 -14)📝
serve/test_server.py(+70 -0)📄 Description
What
"idle_unload_s": Nin the config (or--idle-unload Non the server's command line): after N seconds with no request running or waiting, the engine ends, giving back its GPU memory and its pinned RAM tier. The next request starts it again. It is Strata'sidle_unload_s, for a PC that shares its GPU with other programs (another model server, games).0(the default): never; nothing changes.Service.unload(idle_for)takes every FIFO place without waiting and refuses (busy) while a request runs or waits, a context reload is on, or a request ended less thanidle_forago. It then ends the engine withStrataEngine.close(QUIT; withSTRATA_GLM_SLOT_KEEP=1the conversation in the model is written first) and waits for the GPU memory. A thread checks everymin(30, N/4)s.Service.ensure_engine()starts the engine again before a request and before a picture is encoded, since the encoder borrows the engine's memory. It is the restart after a crash (#27), moved into one place./v1/modelsstill lists the model with"status": {"value": "unloaded"}(as Strata's);/healthhas"unloaded": true;unloaded;/propsanswers.docs/SETUP.md: a short section.A note on
StrataEngine.stopStrataEnginedefinesstoptwice:stop(timeout)(QUIT, wait, then wait for the GPU memory) and laterstop()(the request's STOP). The second shadows the first, soself.engine.stop()only stops the request in flight. This is why the unload usesclose()._restart_with(the dashboard's context change) also callsstop()and relies onrestart()killing the process. That works, but it skips the graceful QUIT. This PR leaves it as is.Checked
RTX 3090, Ryzen 7 9700X, Windows 11, Maya-S24,
--idle-unload 60,STRATA_GLM_SLOT_KEEP=1:/v1/modelslists the model asunloaded;/healthsaysunloaded: true.maya.pywith the config key:[maya] the model unloads after 900 s without requests.serve/test_server.pygetsIdleUnload(a mock engine with the lifecycle): an idle unload and the next request's start,busywhile a request is recent, holds the FIFO or waits,unsupportedfor an engine without it.check_hip_compatpasses. The other Python tests show only the Windows-only errors unmodifiedmainshows here. Not run on Linux.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.