Studio: fix host memory checks and improve logging for GGUF image loads by VTplus · Pull Request #14514 · unslothai/unsloth · GitHub
Skip to content

Studio: fix host memory checks and improve logging for GGUF image loads - #14514

Open
VTplus wants to merge 9 commits into
unslothai:mainfrom
VTplus:studio-host-ram-guard
Open

VTplus wants to merge 9 commits into
unslothai:mainfrom
VTplus:studio-host-ram-guard

Conversation

@VTplus

@VTplus VTplus commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Summary

GGUF image loads can exhaust Windows system commit while the small-host guard considers dense loading safe. This corrects the estimates and available-memory reading so affected loads take the existing low-memory route or return the existing RAM refusal.

Fixes #14513

Changes

  • Include the GGUF transformer's file size in both the dense and low-memory estimates. The transformer is already built before companion loading and was excluded from the snapshot-based estimate.
  • Apply a 1.5× transient margin to the existing dense-conversion estimate. Pre-built bytes receive no margin.
  • On Windows, cap available memory by commit headroom using K32GetPerformanceInfo, falling back to the existing physical-memory reading if unavailable.
  • Log measured decisions, including cases where dense loading fits, with physical-memory and Windows commit-headroom readings. Early returns without measurements remain unchanged.
  • Add UNSLOTH_DIFFUSION_HOST_RAM_LIMIT_MIB to cap the total and available memory values supplied to the guard for testing. It does not enforce a process memory limit.

Known limitations

  • The conversion margin applies on all platforms and may send borderline dense loads through the slower low-memory route, with an int8 denoiser where applicable.
  • The available-memory reading may already reflect the pre-built checkpoint, so adding its file size can conservatively overcount that memory.
  • Diagnostic readings are sampled separately; the decision text reports the effective capped availability.
  • The replacement/reload crash described in the issue remains outside this change. Loading peaks and the timing of host-memory release need separate investigation.
  • The video loading path is unchanged.

Testing

Regression coverage in studio/backend/tests/test_diffusion_small_host.py includes pre-built memory accounting, fits/LoRA metadata, routing and refusal, memory caps, the Windows API reader, and logging of measured fits decisions. The API reader test runs on Windows and skips elsewhere.

On the original 48 GB Windows host, the previously failing Turbo load took the low-memory route, completed successfully, and generated images. The physical-memory and commit-headroom log fields were also observed during subsequent load testing.

…Windows commit headroom in the small-host guard
…ync branch with upstream

67 upstream commit(s) since the branch base; see git log for the range.
…ync branch with upstream

5 upstream commit(s) since the branch base; see git log for the range.
…ync branch with upstream

493 upstream commit(s) since the branch base; see git log for the range.
…ync branch with upstream

42 upstream commit(s) since the branch base; see git log for the range.
@VTplus
VTplus requested a review from danielhanchen as a code owner October 21, 2026 13:15

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Studio: GGUF loads can crash the server on Windows instead of taking the low-memory route

1 participant