Skip to content

Studio: resume paused and interrupted model downloads on Windows - #16828

Merged
danielhanchen merged 5 commits into
unslothai:mainfrom
NilayYadav:download-never-resumes
Nov 6, 2026
Merged

danielhanchen merged 5 commits into
unslothai:mainfrom
NilayYadav:download-never-resumes

Conversation

@NilayYadav

@NilayYadav NilayYadav commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

On Windows, a model download that was paused, cut off by a network drop, or stopped by a crash or restart never continues where it left off. Pressing Continue shows "The earlier partial can't be resumed, so this download is starting over." and the whole file is fetched again from zero.

Studio reuses a partial file only when it can show that no second process writes it at the same time and that the current account wrote it. Both checks only existed for Linux and macOS. On Windows they now use the byte-range lock huggingface_hub itself takes there, and the file owner read from the open handle, with no new dependency. A partial owned by another account is still refused, and network drives still start over. Linux and macOS are unchanged.

Fixes #16810

Screenshots

Real Studio on windows-latest (staging CI), HTTP download of unsloth/Qwen3-1.7B-GGUF BF16, interrupted partway, then Continue.

Before (main) After (this PR)

danielhanchen added a commit that referenced this pull request Nov 6, 2026
… stops early (#16861)

## Summary

`Chat UI Tests (chat)` on Linux has started failing on unrelated PRs
with the same assertion in the floating monitor geometry check:

```
tests/studio/playwright_chat_ui.py:956, in exercise_floating_monitor_geometry
AssertionError: [ui] FAIL: resize width: expected 296, got 260
```

It failed 3 of the last 17 completed `Unsloth UI CI` runs (#16858, which
only touches the bookmarks test, plus `inprocess-native-tool-formats`
and `download-speed-limit`, the #16828 branch, which only touches
backend hub code). #16828 also hit it once more with `got 256`, and a
rerun passed. Playwright and Chromium are the same version (1.64.1) in
passing and failing runs, and nothing under `studio/frontend` merged in
the window where it started.

The numbers point at the pointer drag, not the resize logic. The check
drags the native grip with `mouse.move(..., steps = 10)` from 8 px
inside the corner to 40 px past it. 260 is 256 plus the first 4 px step,
and 256 is no step at all. So the native resize took at most the first
pointer step and dropped the rest. The same step passes in the other 14
runs on the same code.

## Change

`tests/studio/playwright_chat_ui.py`, the "resize width / height" step
only. The drag target is an absolute point, so if the box is not at the
wanted size after the drag, the test drags the grip again from wherever
the corner is now, up to three drags, and logs a line when it retries.
The width, height, left edge and top edge assertions after it are
unchanged, so a resize that really stops following the grip still fails
after the third drag.

## Testing

- `python -m py_compile tests/studio/playwright_chat_ui.py`.
- This PR's own `Unsloth UI CI` run exercises the step on Linux.
- I could not reproduce the dropped steps locally. The change only adds
the retry, so it cannot make a passing run fail.
@danielhanchen danielhanchen self-assigned this Nov 6, 2026
shimmyshimmer pushed a commit to shimmyshimmer/unsloth-staging-4 that referenced this pull request Nov 6, 2026
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-06T08:29:37.155931Z 1da6c09 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@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: 2771406d76

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

owned = _owned_by_this_account(descriptor)
except Exception: # noqa: BLE001 - an owner that cannot be read is not ours
owned = False
return None if owned else "owned by another user"

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 Reject link swaps before accepting Windows partials

On a Windows cache writable by another account that can create file symlinks (for example, with Developer Mode enabled), this can accept a handle obtained by following a swapped-in link. _open_stable_partial() only calls lstat() before os.open() when O_NOFOLLOW is unavailable, so an attacker can replace the checked partial with a symlink to a downloader-owned file between those calls; this ownership check then passes for the target. The resumed writer appends to, or truncates, that unrelated file before _still_the_written_file() runs, so the publication check cannot prevent the damage. Open Windows partials with atomic no-follow semantics and reject reparse points before enabling the shared writer.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Fixed in cdf21f9: without O_NOFOLLOW the open is now followed by an lstat identity check against the opened handle, so a link swapped in during the race is refused before any byte is written (O_APPEND, no truncate), with a regression test.

@danielhanchen

Copy link
Copy Markdown
Member

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

shimmyshimmer pushed a commit to shimmyshimmer/unsloth-staging-4 that referenced this pull request Nov 6, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 1da6c09309

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen
danielhanchen merged commit 628b0c9 into unslothai:main Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Download never resumes

2 participants