Skip to content

Conversation

Copy link

Copilot AI commented Nov 14, 2025

Downloads interrupted by network issues or user cancellation currently restart from scratch. When pulling large models (e.g., ai/smollm2:135M-Q4_0), interrupting and resuming results in downloading from 0 bytes again instead of continuing from the partial download.

Changes

ResumableTransport wrapper (pkg/distribution/internal/store/resume.go)

  • Intercepts blob GET requests and adds Range: bytes=N- headers based on partial file size
  • Detects when server returns 416 or 200 (doesn't support Range) and retries without Range header
  • Tracks resume success via DidResume() to coordinate with file writing logic

Store layer modifications (pkg/distribution/internal/store/blobs.go)

  • Detects .incomplete files before initiating downloads
  • New writeBlobResumable() appends to partial files when resume succeeds, overwrites when server doesn't support Range
  • writeLayer() coordinates resume offset between transport and file I/O

Distribution client wiring (pkg/distribution/distribution/client.go)

  • Wraps base HTTP transport with ResumableTransport
  • Injects wrapped transport into both registry client and local store

Fetcher compatibility (pkg/go-containerregistry/pkg/v1/remote/fetcher.go)

  • Accepts both HTTP 200 and 206 status codes
  • Properly handles Content-Length for partial content responses

Behavior

$ ./model-cli pull ai/smollm2:135M-Q4_0
384a89bd054c: Downloading [========>                  ]  16.22MB/91.73MB
^C  # Interrupt

$ ./model-cli pull ai/smollm2:135M-Q4_0
384a89bd054c: Downloading [========>                  ]  16.22MB/91.73MB  # Resumes from 16.22MB

Gracefully falls back to full download when registry doesn't support Range requests (returns 416 or ignores Range header).

Original prompt

Implement resumable downloads

When someone executes:

./model-cli pull ai/smollm2:135M-Q4_0

And that pull gets interrupted. If we pull again, it should resume where we left off.

It can be tested like so it currently doesn't work, when I start a pull, stop it with Ctrl-C and start it again, it doesn't resume, it
downloads from scratch again:

$ MODEL_RUNNER_HOST=http://localhost:13434 cmd/cli/model-cli pull ai/smollm2:135M-Q4_0
384a89bd054c: Downloading [========> ] 16.22MB/91.73MB
$ MODEL_RUNNER_HOST=http://localhost:13434 cmd/cli/model-cli pull ai/smollm2:135M-Q4_0
384a89bd054c: Downloading [=> ] 2.306MB/91.73MB


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Add resumable download feature to model-cli Implement resumable downloads using HTTP Range requests Nov 14, 2025
Copilot AI requested a review from ericcurtin November 14, 2025 13:09
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.

2 participants