Skip to content

Conversation

@gogurtenjoyer
Copy link
Contributor

Summary

Windows treats file handles differently than MacOS and Linux - Model Manager v3 has exposed some issues here, so here's a few patches to solve this. I wrote more but then the power went out, and I'm not rewriting all of that, but I wanted to make sure to thank @skunkworxdark for catching and fixing a serious memory issue.

Related Issues / Discussions

Closes:
#8644
#8636
#8628
#8627

QA Instructions

To test, import various models from Starter Models and elsewhere: GGUF files, Safetensors files, particularly large ones, and Diffusers multi-file models. This fix is specifically for Windows, but the changes should benefit every OS and not break anything on MacOS and Linux. Tested on MacOS and Windows so far.

Merge Plan

Changes the GGUF loader, and import_state_dict in model_on_disk.py - shouldn't conflict with anything; mostly small/remote changes.

Checklist

  • The PR has a short but descriptive title, suitable for a changelog
  • Tests added / updated (if applicable) (n/a)
  • ❗Changes to a redux slice have a corresponding migration (not sure what this is)
  • Documentation added / updated (if applicable) (n/a)
  • Updated What's New copy (if doing a release after this PR)

Wrap gguf.GGUFReader and then use a context manager to load memory-mapped GGUF files, so that they will automatically close properly when no longer needed. Should prevent the 'file in use in another process' errors on Windows.
Additional check for cached state_dict as path is now optional - should solve model manager 'missing' this and the resultant memory errors.
@github-actions github-actions bot added python PRs that change python files backend PRs that change backend files labels Nov 3, 2025
@gogurtenjoyer
Copy link
Contributor Author

I'm sorry but I can't seem to appease ruff here, even when configuring mine with this repo's pyproject.toml.

@gogurtenjoyer gogurtenjoyer changed the title Fix installing models on Windows Fix memory issues when installing models on Windows Nov 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend PRs that change backend files python PRs that change python files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant