Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

[Windows] Disk offload crashes with access violation after DiskMap.flush_files() (apparent use-after-free)

Open
#1,563 0 comments 0 reactions 0 assignees View on GitHub

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

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 via pip 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

  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.

More from modelscope/DiffSynth-Studio

All issues in modelscope/DiffSynth-Studio

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.