feat: reveal all hidden shapes with Shift+H, release SAM3 VRAM on idle and on demand (REQ-191, REQ-192)

This commit is contained in:
asus committed 2026-10-07 11:55:00 +07:00
1 parent f5be7880b0
commit fd608848bf
16 files changed
+290 -20

No files matched your search

+25
View File
@@ -0,0 +1,25 @@
"""SAM3 engine control routes (REQ-192)."""
from fastapi import APIRouter, HTTPException
from backend import jobs
router = APIRouter(prefix="/api/sam3", tags=["sam3"])
@router.post("/release")
def release() -> dict:
"""Free the SAM3 model's VRAM now — never while the card is busy.
The same non-blocking `gpu_lock` rule as an interactive assist (REQ-065):
a job or assist in flight wins, and the caller is told to try again.
"""
if not jobs.gpu_lock.acquire(blocking=False):
raise HTTPException(409, "GPU busy — assist or job in flight, try again in a moment")
try:
from backend import sam3_engine
released = sam3_engine.release_engine()
return {"released": released, "model_loaded": sam3_engine.engine_is_loaded()}
finally:
jobs.gpu_lock.release()