feat: add fsspec streaming weight loader for fast GCS transport#1
Merged
ahmeda14960 merged 2 commits intomarinfrom Mar 22, 2026
Merged
feat: add fsspec streaming weight loader for fast GCS transport#1ahmeda14960 merged 2 commits intomarinfrom
ahmeda14960 merged 2 commits intomarinfrom
Conversation
Add an fsspec-based streaming weight loader that bypasses the slow RunAI
single-threaded HTTP path (53 MiB/s) by using fsspec byte-range downloads.
Weights are streamed shard-by-shard, chunk-by-chunk with bounded RAM (~2 GiB
peak per chunk) and all arrays materialized on CPU to avoid TPU HBM pressure.
Changes:
- New streaming_weights.py: fsspec iterator ported from Levanter's
fsspec_safetensor.py (header parsing, chunk building, shard discovery)
- TpuBootstrapConfig: add weight_loader field ("default" | "fsspec_streamer")
- model_loader: fsspec_streamer branch in _build_abstract_model_and_load_weights
- weight_utils: lazy torchax init + jax.Array/torch.Tensor type dispatch
- requirements.txt: add fsspec, gcsfs dependencies
- Tests for config parsing, dispatch, and streaming iterator
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
DescriptionStart with a short description of what the PR does and how this is a change from The rest of the description includes relevant details and context, examples:
If the change fixes a Github issue, please include a link, e.g.,: TestsPlease describe how you tested this change, and include any instructions and/or ChecklistBefore submitting this PR, please make sure:
|
…patch The test_load_hf_weights_rejects_ndarray test used a MagicMock as model, but load_hf_weights() calls nnx.state(model) first which fails on a non-Module. Patch nnx.state and nnx.get_named_sharding so the test actually exercises the iterator type-dispatch branch. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
streaming_weights.py) that bypasses slow RunAI single-threaded HTTP (53 MiB/s) using fsspec byte-range downloads from GCSTpuBootstrapConfigwithweight_loaderfield ("default"|"fsspec_streamer")load_hf_weights()iterator path support bothjax.Array(fsspec) andtorch.Tensor(RunAI) with lazy torchax initfsspecandgcsfsdependenciesTest plan
weight_loaderfield_build_abstract_model_and_load_weightsnp.ndarrayrejected withTypeError--engine-kwargs-json '{"additional_config": {"tpu_bootstrap": {"model_bootstrap": "abstract_load", "weight_loader": "fsspec_streamer"}}}'🤖 Generated with Claude Code