Skip to content

report a complete load once llama-server is healthy - #6790

Merged
Imagineer99 merged 8 commits into
unslothai:mainfrom
hakanbaysal:fix/studio-load-progress-ready-fraction
Jul 3, 2026
Merged

Imagineer99 merged 8 commits into
unslothai:mainfrom
hakanbaysal:fix/studio-load-progress-ready-fraction

Conversation

@hakanbaysal

Copy link
Copy Markdown
Contributor

load_progress() derived its fraction purely from the llama-server's VmRSS over the GGUF shard total. With layers offloaded to VRAM (-ngl) the process releases the mmap'd weight pages after upload, so VmRSS sinks back well below the shard total: the fraction climbs toward ~1.0 during mmap, then collapses to a small value (~8%) once the weights are on the GPU. A fraction-driven progress bar therefore restarts and sticks there indefinitely even though the model is loaded and serving, which reads as a hang at "Starting model...".

Once the server is healthy the load is complete by definition, so report fraction 1.0 (and bytes_loaded == bytes_total) in the ready phase regardless of resident set size. The VmRSS read is factored into _read_rss_bytes() with its original semantics preserved (0 on a missing VmRSS line, None when /proc is unavailable) so it can be unit-tested off Linux.

Fixes #5740

load_progress() derived its fraction purely from the llama-server's VmRSS over the GGUF shard total. With layers offloaded to VRAM (-ngl) the process releases the mmap'd weight pages after upload, so VmRSS sinks back well below the shard total: the fraction climbs toward ~1.0 during mmap, then collapses to a small value (~8%) once the weights are on the GPU. A fraction-driven progress bar therefore restarts and sticks there indefinitely even though the model is loaded and serving, which reads as a hang at "Starting model...".

Once the server is healthy the load is complete by definition, so report
fraction 1.0 (and bytes_loaded == bytes_total) in the ready phase regardless of resident set size. The VmRSS read is factored into _read_rss_bytes() with its original semantics preserved (0 on a missing VmRSS line, None when /proc is unavailable) so it can be unit-tested off Linux.

Fixes unslothai#5740

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bd68f4c2cd

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the resident set size (VmRSS) reading logic into a static method _read_rss_bytes and ensures that once the llama-server is healthy, the progress fraction is reported as 1.0 to prevent the progress bar from freezing when layers are offloaded to VRAM. It also adds comprehensive unit tests. The review feedback correctly identifies a potential IndexError when parsing the /proc/<pid>/status file if a line starting with VmRSS: is malformed, and suggests catching IndexError to improve robustness.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

hakanbaysal and others added 5 commits July 1, 2026 17:24
Two review fixes:

1. The new test imported core.inference.llama_cpp at module top, which pulls in
   loggers/structlog/httpx and fails collection with ModuleNotFoundError in the
   lightweight backend test env when the file is run on its own. Stub loggers,
   structlog and httpx via sys.modules.setdefault before the import, mirroring
   test_llama_cpp_load_progress_matrix.py; setdefault keeps the real modules when installed. Verified the file now collects and passes with only pytest present.

2. Catch IndexError in _read_rss_bytes: a "VmRSS:" line with no value column
   would make line.split()[1] raise and crash a load-progress poll. Return None
   instead, with a test for the valueless line.
…nslothai#5740)

load_progress() now holds a per-process VmRSS high-water mark, so the bar
no longer regresses to ~8% when -ngl offloads the weights and frees the
mmap pages mid-load.

A live server that never returns 200 on /health now gets a specific error
(context/VRAM too large, or a local proxy/VPN intercepting the loopback
probe) instead of the generic invalid-GGUF/out-of-memory message.
@danielhanchen

danielhanchen commented Jul 2, 2026 •

Copy link
Copy Markdown
Member

Pushed e3837a1 with two follow-ups on top of the fraction change.

Context: the "stuck at Starting model..." hang in #5740 is gated on _wait_for_health() seeing HTTP 200 from the local /health. In the reporter's logs the frontend keeps polling load-progress forever, which only happens while phase != "ready", so _healthy never flipped. For a user behind a VPN or HTTP proxy that is the loopback probe getting routed through the proxy, which is already fixed on main by #6752 (trust_env=False). The ready-phase fraction is not what unsticks that case (the poller stops on phase == "ready" before it reads fraction), so I left that as is and fixed the two facets that are still reachable:

  1. Monotonic progress. load_progress() now holds a per-process VmRSS high-water mark. Once -ngl offloads the weights and the mmap pages are freed, RSS collapses and the raw fraction fell back toward ~8% mid-load (the "restarts and sticks" symptom). Holding the peak keeps the bar from regressing no matter how a consumer reads it.

  2. Clear error on a never-healthy load. When the server stays alive but never returns 200 within the timeout, _classify_llama_start_failure was falling through to the generic "invalid GGUF or not enough memory" message. It now names the real causes: the context/VRAM/projector being too large for the card, or a local proxy/VPN intercepting the loopback probe.

Tests: added coverage for the monotonic bar, the health-timeout marker, and the new classification. The full test_load_progress_*, test_llama_cpp_wait_for_health, and test_llama_cpp_start_failure_classification suites pass (96 tests).

The remaining root cause for non-proxy users, the over-optimistic VRAM fit estimate that judges a marginal vision/MTP model to fit and launches it full-offload (-ngl -1), is already tracked in #6682 and addressed by #6718 (reserve CUDA context and mmproj/MTP soft overhead in the fit budget), so it is out of scope here.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@Imagineer99

Copy link
Copy Markdown
Member

Ran a focused fork check for the llama-server load-progress changes: https://github.com/Imagineer99/unsloth/actions/runs/28659980873

Covers ready progress, monotonic RSS progress, and the health-timeout classification path. Passed on the fork.

@Imagineer99

Copy link
Copy Markdown
Member

CI passing except for 3 inherited from main failures.
image

@Imagineer99
Imagineer99 merged commit abdc968 into unslothai:main Jul 3, 2026
1 check passed
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.

[Bug] Model loading stuck at "Starting model..." in Unsloth Studio

3 participants