Skip to content

Add byte-progress reporting for safetensors file loading#427

Open
aleroot wants to merge 1 commit into
ml-explore:mainfrom
aleroot:loading_progress
Open

Add byte-progress reporting for safetensors file loading#427
aleroot wants to merge 1 commit into
ml-explore:mainfrom
aleroot:loading_progress

Conversation

@aleroot

@aleroot aleroot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Proposed changes

Adds byte-level progress reporting for safetensors file loading so upper layers can drive precise model-loading progress UI.

This PR depends on ml-explore/mlx#3734.

The progress API in mlx-swift can report byte-level safetensors loading progress, but the truncated/failed-read correctness path needs the upstream MLX fix first. Without ml-explore/mlx#3734, CPU lazy-load read failures can be swallowed before they reach Swift.

Once ml-explore/mlx#3734 eventaully lands, I’ll update the MLX submodule reference here and rerun the mlx-swift test suite.

Checklist

Put an x in the boxes that apply.

  • I have read the CONTRIBUTING document
  • I have run pre-commit run --all-files to format my code / installed pre-commit prior to committing changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have updated the necessary documentation (if needed)

Introduces LoadProgress and new loadArrays(url:stream:progressHandler:) and
loadArraysAndMetadata(url:stream:progressHandler:) overloads that report
bytes read as lazy arrays are evaluated. Uses a custom mlx_io_reader vtable
backed by pread() so progress callbacks can be invoked from MLX worker
threads. Includes a unit test verifying monotonic progress from 0 to 1.
@aleroot

aleroot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

This now depends on ml-explore/mlx#3742 , I will update this PR when that one is going to be merged.

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.

1 participant