[Windows] Disk offload crashes with access violation after DiskMap.flush_files() (apparent use-after-free)
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 55/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- python
- Domain
- backend, performance
Research direction
Read diffsynth/core/vram/disk_map.py and diffsynth/core/vram/layers.py, starting with DiskMap.getitem, flush_files(), and _load_from_disk. Run examples/minimax_h3/model_inference_low_vram/MiniMax-H3-NF4-FL2VA.py on Windows with the default disk buffer and verify that prompt encoding and the full 50-step generation complete without an access violation.
Written by the indexing model from the issue text.
Description
Environment
- OS: Windows 11 (x64)
- GPU: RTX 4060 Laptop 8 GB (driver 610.62)
- Python 3.12.10, torch 2.11.0+cu128, safetensors 0.8.0, bitsandbytes 0.50.0
- DiffSynth-Studio: current
main, installed viapip install -e ".[quant]"(2026-08-03)
Reproduction
Run the official low-VRAM example examples/minimax_h3/model_inference_low_vram/MiniMax-H3-NF4-FL2VA.py on Windows (disk-offload vram_config with offload_device="disk").
The pipeline loads fine and prompt encoding starts, then the process dies with a hard native crash (no Python exception) while onloading the text encoder layers:
Windows fatal exception: access violation
Current thread 0x00017240 (most recent call first):
File "torch\storage.py", line 471 in __getitem__
File "diffsynth\core\vram\disk_map.py", line 62 in __getitem__
File "diffsynth\core\vram\layers.py", line 496 in _load_from_disk
File "diffsynth\core\vram\layers.py", line 520 in onload
File "diffsynth\diffusion\base_pipeline.py", line 180 in load_models_to_device
File "diffsynth\pipelines\minimax_h3_audio_video.py", line 382 in process
Analysis
DiskMap.__getitem__ calls flush_files() once num_params > buffer_size (default 1e9), which drops the open safe_open handles and re-opens them. Tensors previously returned by get_tensor may still reference the old mmap, so the next access after a flush is a use-after-free. On Windows this surfaces as an access violation inside torch.storage.__getitem__ instead of a catchable Python error.
Workaround
Setting DIFFSYNTH_DISK_MAP_BUFFER_SIZE=1000000000000 (effectively disabling the periodic flush) avoids the crash entirely — a full 50-step MiniMax-H3 generation then completes successfully.
Maybe flush_files() should not invalidate handles while tensors fetched from them can still be alive, or get_tensor results should be fully detached from the mmap before any flush can happen.
- Dominant language
- Python
- Stars
- 13.2k
- Forks
- 1.3k
- Avg merge
- 22h 15m
- Merged PRs (30d)
- 31
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from modelscope/DiffSynth-Studio
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
modelscope/DiffSynth-Studio#1707 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 1-3 hours Newbie friendliness 78/100
modelscope/DiffSynth-Studio#1668 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
modelscope/DiffSynth-Studio#1499 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
modelscope/DiffSynth-Studio#1373 · 5 comments · 1 reaction ·
Maintainers usually reply within 1 day
-
[Reproducibility] Training script / config for MiniMax-H3-TrainingAdapter (DeCFG adapter) itselfOpen
Difficulty 5/5 Over a week Newbie friendliness 35/100
modelscope/DiffSynth-Studio#1713 · 1 comment ·
Maintainers usually reply within 1 day
All issues in modelscope/DiffSynth-Studio
Similar issues
-
New InternshipOpennew_internship
Difficulty 1/5 Under an hour Newbie friendliness 70/100
-
[BUG] Reports tab: "Unban" button tooltip shows raw `{{ip}}` placeholder instead of the IP addressOpenbug javascript ui
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
bunkerity/bunkerweb#4001 · 1 comment ·
Maintainers usually reply within 1 day
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 92/100
PedestrianDynamics/pyFDS-Evac#476 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
google/differential-privacy#516 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
adobe-fonts/source-serif#153 ·