Understand the VRAM policy and ModelStore
masterThe project manages GPU memory through a ModelStore using two distinct modes controlled by a single flag. This determines how modules (LM, DiT, VAE, etc.) are loaded and evicted from VRAM.
VRAM Modes
- Default Mode (Optimizes VRAM): Uses a
STRICTeviction policy. At most one GPU module is resident at a time. When a new module is requested, the previous one is evicted. This allows the full stack to run on consumer-grade hardware by swapping weights (e.g., DiT loads, then evicts; VAE loads, then evicts). --keep-loadedMode (Optimizes Latency): Uses aNEVEReviction policy. Everything stays resident in VRAM across requests. This is intended for workstations with high VRAM capacity to eliminate reload overhead.
ModelStore Mechanics
- Module Keys: Modules are keyed to prevent redundant loading.
- LM: Keyed by
(path, max_seq, n_kv_sets). This ensuresace-lmandace-understandshare the same single LM instance. - DiT: Keyed by
(path, adapter_path, adapter_scale). - Others: Keyed by
(path).
- LM: Keyed by
- RAII Management: The system uses
ModelHandle(an RAII handle) to ensure that when a pipeline finishes using a module, it is correctly released back to the store, triggering the appropriate eviction policy.