feat(api): report model memory placement in memory endpoint

Add a model section to /sdapi/v1/memory with loaded-model bytes summed
per pipeline component and device, so clients can tell resident weights
from offloaded ones and loop-critical components from edge ones.

- walk components over parameters and buffers, dedupe shared storages,
  key by component name then device type
- read the raw model slot so a memory poll never triggers a model load
- section is exception-isolated like ram and cuda; reports an error
  string if the walk races a reload
This commit is contained in:
CalamitousFelicitousness
2026-07-18 20:12:23 +01:00
parent 7cd9fbc321
commit b12cbcb523
2 changed files with 32 additions and 1 deletions
+1
View File
@@ -552,6 +552,7 @@ class ResEmbeddings(BaseModel):
class ResMemory(BaseModel):
ram: dict = Field(title="RAM", description="System memory stats")
cuda: dict = Field(title="CUDA", description="nVidia CUDA memory stats")
model: dict = Field(default={}, title="Model", description="Loaded model bytes per component and device")
class ResScripts(BaseModel):
txt2img: list[str] = Field(title="Txt2img", description="Titles of scripts (txt2img)")