Skip to content

Disk offload mode leaks host RAM during denoising (RSS grows every step, >15x slowdown from swap thrashing) #1564

Description

@zhouxixiong4

Environment

  • OS: Windows 11 (x64), 24 GB RAM
  • GPU: RTX 4060 Laptop 8 GB
  • Python 3.12.10, torch 2.11.0+cu128, bitsandbytes 0.50.0
  • DiffSynth-Studio: current main, installed via pip install -e ".[quant]" (2026-08-03)
  • Model: DiffSynth-Studio/MiniMax-H3-NF4 (disk-offload low-VRAM path)

Observation

Running MiniMax-H3 NF4 FL2VA with the official disk-offload vram_config (offload_device="disk", onload_device="cpu", preparing_device="cuda", computation_device="cuda"), host RAM usage of the python process grows monotonically with every denoising step and is never reclaimed:

  • After the text-encoder phase (which alone peaks at ~15 GB), the process working set keeps climbing during denoising — ~11.3 GB by step 39/50 and still growing
  • On a 24 GB machine this pushes the OS into swap thrashing: per-step time degrades from ~65-75 s/step (steps 1-3) to ~1000-1100 s/step (step 39+), i.e. a >15x slowdown
  • A 50-step 5-second 640x640 video took ~10 hours instead of the ~1 hour the early-step speed would suggest

Expectation

In disk offload mode, weights that _load_from_disk loads into CPU RAM (module.load_state_dict(state, assign=True) in layers.py) should be released when the layer is offloaded again (offload() re-creates a quantized shell). Host RAM should stay roughly constant across steps, but it looks like the CPU-side copies or the rebuilt quant state from quantize.unflatten_state_dict() are kept alive somewhere, so each step's reloads accumulate.

Impact

This disproportionately affects exactly the audience the disk-offload path targets: low-VRAM and low-RAM machines (the model card advertises ~6 GB VRAM as enough). Short runs (<= 8 steps) finish before the leak hits the wall, which masks the issue in quick tests; any 50-step or long-video run degrades severely.

Happy to provide py-spy dumps, tracemalloc snapshots, or per-step RSS logs if helpful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions