modelscope / modelscope/DiffSynth-Studio

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

Open
#1,564 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
13.1k
Forks
1.3k
Avg merge
13h 12m
Merged PRs (30d)
45

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce a long denoising run with the official disk-offload vram_config while recording per-step RSS. Inspect _load_from_disk in layers.py, especially module.load_state_dict(state, assign=True), then follow offload() and quantize.unflatten_state_dict() to identify retained CPU-side state. Done means repeated reload/offload cycles keep host RAM roughly stable and avoid the reported slowdown.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
machine-learning, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.