Skip to content

fix(studio): stop showing manifest-less cache entries as downloading (#7858) - #7864

Merged
oobabooga merged 2 commits into
unslothai:mainfrom
Anai-Guo:fix/cached-progress-99-percent-7858
Aug 7, 2026
Merged

oobabooga merged 2 commits into
unslothai:mainfrom
Anai-Guo:fix/cached-progress-99-percent-7858

Conversation

@Anai-Guo

@Anai-Guo Anai-Guo commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Fixes #7858.

The problem

snapshot_progress.py reports 1.0 only when complete_on_disk succeeds, and that
check requires a readable Studio download manifest. Cache entries created outside
Studio — or before the manifest system existed — never have one, so they stay
unverified and the reported fraction is capped at 0.99.

The training-start overlay labels anything under 100% as Downloading, and its
cached-state coercion bailed out whenever downloadedBytes > 0 && percent < 100.
That is exactly the shape of a fully cached resource, so it sat at
Downloading — 99% forever with no worker running (reproduced with
unsloth/alpaca-cleaned: 42.3 MB / 42.3 MB, no active dataset download).

The fix

The progress response already carries the field that separates the two cases:

# Finalized-blob bytes only (no ``.incomplete``).
completed_bytes: int = 0

Every expected byte being finalized means nothing is in flight, so the remaining
gap is verification rather than transfer. The overlay now carries completed_bytes
through and lets it settle the cached state.

Crucially this keeps the case the 0.99 cap exists for: on resume, finalized bytes
can approach the total while .incomplete blobs are still growing, so
completedBytes < totalBytes and the row keeps reporting progress.

state completed / total before after
cached, no manifest 42.3 MB / 42.3 MB Downloading 99% Ready
resuming, blobs incomplete 19.9 GB / 20 GB Downloading 99% Downloading 99%
ordinary transfer 4.8 GB / 20 GB Downloading 25% Downloading 25%

The state type and coercion move into download-state.ts so the rule can be
exercised without mounting the overlay; the overlay is otherwise unchanged.

Tests

studio/frontend/tests/training-start-cached-progress.test.ts — 5 cases covering
the cached entry, the resumed download, an ordinary transfer, an uncached resource,
and a cached entry of unknown size.

Verified in both directions: with the previous guard restored the cached-entry case
fails, and the two "still downloading" cases pass either way, so the change does not
weaken the cap.

✔ a cache entry with no manifest reads as ready, not as a transfer
✔ a resumed download still reports progress while blobs are incomplete
✔ an ordinary in-flight download is left alone
✔ a resource with no cache path is never coerced
✔ a cached entry of unknown size still settles instead of hanging
ℹ pass 5  ℹ fail 0

Not addressed here: #7858 also suggests surfacing "cached but unverified" as a
distinct third state. That is a UX/i18n decision rather than a bug fix, so this PR
only stops the misreport.

🤖 Generated with Claude Code

The backend caps reported progress at 0.99 until a Studio download manifest
verifies the snapshot on disk. Hugging Face cache entries created outside
Studio -- or before the manifest system existed -- never have one, so they stay
unverified with every byte already present, and the training-start overlay,
which labels anything under 100% as Downloading, showed them as an active
transfer indefinitely (42.3 MB / 42.3 MB, no worker running).

The progress response already distinguishes the two: completed_bytes counts
finalized blobs only, so all of them being present means nothing is in flight
and the remaining gap is verification, not transfer. Carry that field through
and let it settle the cached state. A resumed download, where finalized bytes
can approach the total while .incomplete blobs still grow, keeps reporting
progress -- which is what the 0.99 cap exists to protect.

Moves the state type and coercion into their own module so the rule can be
tested without mounting the overlay.

@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: c8385041ad

ℹ️ 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".

total > 0 ? Math.min(100, Math.round(ratio * 100)) : 0;
setState({
downloadedBytes: downloaded,
completedBytes: prog.completed_bytes ?? 0,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Add completed_bytes to the chat progress type

In this polling path prog is typed as DownloadProgressResponse from features/chat/api/chat-api, but that interface still only declares downloaded_bytes, expected_bytes, progress, and cache_path. Since the frontend build runs tsc -b before Vite, this new prog.completed_bytes access fails typechecking whenever the overlay is compiled; add the field to the chat API response type or share the existing hub progress type.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Confirmed and fixed in ccca1ea. The chat-api mirror of /api/models/download-progress was missing the field, so prog.completed_bytes would have failed tsc -b before Vite ran.

The backend has been returning it all along — compute_snapshot_progress puts completed_bytes in every return path (studio/backend/hub/services/snapshot_progress.py), and the hub download-manager's mirror of the same endpoint already declares completed_bytes: number (features/hub/download-manager/api.ts). So this was a stale copy of the response shape rather than a field I invented; I've added it with a note on what separates it from downloaded_bytes.

Worth recording why the fix reads completed_bytes and not the complete_on_disk flag sitting next to it, since that looks like the more direct signal: _snapshot_complete_on_disk returns False whenever read_manifest finds no manifest, and cache entries created outside Studio never have one — that is the 99% in #7858. Finalized bytes are the only field that distinguishes "verification is missing" from "bytes are still arriving".

The chat-api mirror of /api/models/download-progress omitted completed_bytes,
so the overlay's new read of it failed tsc -b. The backend has always returned
the field (studio/backend/hub/services/snapshot_progress.py), and the hub
download-manager mirror of the same endpoint already declares it.
@oobabooga

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: ccca1eaa9a

ℹ️ 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".

@oobabooga
oobabooga merged commit 8d7b5ca into unslothai:main Aug 7, 2026
35 of 36 checks 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] Training overlay shows cached resources as Downloading at 99% without an active download

2 participants