vllm-network-storage-weight-loading-optimizer 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. vllm_network_storage_weight_loading_optimizer-0.1.0/CITATION.cff +19 -0
  2. vllm_network_storage_weight_loading_optimizer-0.1.0/LICENSE +177 -0
  3. vllm_network_storage_weight_loading_optimizer-0.1.0/MANIFEST.in +4 -0
  4. vllm_network_storage_weight_loading_optimizer-0.1.0/PKG-INFO +122 -0
  5. vllm_network_storage_weight_loading_optimizer-0.1.0/README.md +92 -0
  6. vllm_network_storage_weight_loading_optimizer-0.1.0/pyproject.toml +40 -0
  7. vllm_network_storage_weight_loading_optimizer-0.1.0/setup.cfg +4 -0
  8. vllm_network_storage_weight_loading_optimizer-0.1.0/src/vllm_network_storage_weight_loading_optimizer/__init__.py +2 -0
  9. vllm_network_storage_weight_loading_optimizer-0.1.0/src/vllm_network_storage_weight_loading_optimizer/cli.py +160 -0
  10. vllm_network_storage_weight_loading_optimizer-0.1.0/src/vllm_network_storage_weight_loading_optimizer/doctor.py +500 -0
  11. vllm_network_storage_weight_loading_optimizer-0.1.0/src/vllm_network_storage_weight_loading_optimizer/fit.py +54 -0
  12. vllm_network_storage_weight_loading_optimizer-0.1.0/src/vllm_network_storage_weight_loading_optimizer/k8s.py +79 -0
  13. vllm_network_storage_weight_loading_optimizer-0.1.0/src/vllm_network_storage_weight_loading_optimizer/loaders.py +237 -0
  14. vllm_network_storage_weight_loading_optimizer-0.1.0/src/vllm_network_storage_weight_loading_optimizer/make.py +101 -0
  15. vllm_network_storage_weight_loading_optimizer-0.1.0/src/vllm_network_storage_weight_loading_optimizer/memlimit.py +94 -0
  16. vllm_network_storage_weight_loading_optimizer-0.1.0/src/vllm_network_storage_weight_loading_optimizer/report.py +395 -0
  17. vllm_network_storage_weight_loading_optimizer-0.1.0/src/vllm_network_storage_weight_loading_optimizer/runner.py +357 -0
  18. vllm_network_storage_weight_loading_optimizer-0.1.0/src/vllm_network_storage_weight_loading_optimizer/storage.py +267 -0
  19. vllm_network_storage_weight_loading_optimizer-0.1.0/src/vllm_network_storage_weight_loading_optimizer/worker.py +186 -0
  20. vllm_network_storage_weight_loading_optimizer-0.1.0/src/vllm_network_storage_weight_loading_optimizer/workloads.py +256 -0
  21. vllm_network_storage_weight_loading_optimizer-0.1.0/src/vllm_network_storage_weight_loading_optimizer.egg-info/PKG-INFO +122 -0
  22. vllm_network_storage_weight_loading_optimizer-0.1.0/src/vllm_network_storage_weight_loading_optimizer.egg-info/SOURCES.txt +25 -0
  23. vllm_network_storage_weight_loading_optimizer-0.1.0/src/vllm_network_storage_weight_loading_optimizer.egg-info/dependency_links.txt +1 -0
  24. vllm_network_storage_weight_loading_optimizer-0.1.0/src/vllm_network_storage_weight_loading_optimizer.egg-info/entry_points.txt +3 -0
  25. vllm_network_storage_weight_loading_optimizer-0.1.0/src/vllm_network_storage_weight_loading_optimizer.egg-info/requires.txt +15 -0
  26. vllm_network_storage_weight_loading_optimizer-0.1.0/src/vllm_network_storage_weight_loading_optimizer.egg-info/top_level.txt +1 -0
  27. vllm_network_storage_weight_loading_optimizer-0.1.0/tests/test_coldload.py +239 -0
@@ -0,0 +1,19 @@
1
+ cff-version: 1.2.0
2
+ message: "If you use vllm-network-storage-weight-loading-optimizer, please cite it as below."
3
+ title: "vllm-network-storage-weight-loading-optimizer: Load vLLM model weights from network storage (EFS, NFS, S3) fastest, within your memory limit."
4
+ type: software
5
+ authors:
6
+ - family-names: "Pattan"
7
+ given-names: "Ameerul Ali Shah"
8
+ version: 0.1.0
9
+ date-released: 2026-11-22
10
+ license: Apache-2.0
11
+ repository-code: "https://github.com/AmeerulShah/vllm-network-storage-weight-loading-optimizer"
12
+ keywords:
13
+ - large language models
14
+ - inference
15
+ - cold start
16
+ - model loading
17
+ - safetensors
18
+ - storage
19
+ - benchmark
@@ -0,0 +1,177 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
@@ -0,0 +1,4 @@
1
+ include LICENSE CITATION.cff README.md
2
+ prune results
3
+ prune netfs/vendor
4
+ prune src/vllm_network_storage_weight_loading_optimizer/bin
@@ -0,0 +1,122 @@
1
+ Metadata-Version: 2.4
2
+ Name: vllm-network-storage-weight-loading-optimizer
3
+ Version: 0.1.0
4
+ Summary: Load vLLM model weights from network storage (EFS, NFS, S3) fastest, within your memory limit.
5
+ Author: Ameerul Ali Shah Pattan
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/AmeerulShah/vllm-network-storage-weight-loading-optimizer
8
+ Project-URL: Issues, https://github.com/AmeerulShah/vllm-network-storage-weight-loading-optimizer/issues
9
+ Keywords: llm,inference,cold start,model loading,safetensors,benchmark,storage
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Operating System :: POSIX :: Linux
12
+ Classifier: Topic :: System :: Benchmark
13
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
14
+ Requires-Python: >=3.10
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE
17
+ Requires-Dist: numpy>=1.24
18
+ Requires-Dist: xxhash>=3
19
+ Requires-Dist: torch>=2.1
20
+ Requires-Dist: safetensors>=0.4
21
+ Provides-Extra: loaders
22
+ Requires-Dist: runai-model-streamer>=0.15; extra == "loaders"
23
+ Requires-Dist: fastsafetensors>=0.1; extra == "loaders"
24
+ Requires-Dist: tensorizer>=2.9; extra == "loaders"
25
+ Provides-Extra: report
26
+ Requires-Dist: matplotlib>=3.7; extra == "report"
27
+ Provides-Extra: dev
28
+ Requires-Dist: pytest>=7; extra == "dev"
29
+ Dynamic: license-file
30
+
31
+ # vllm-network-storage-weight-loading-optimizer
32
+
33
+ <p align="center"><img src="docs/poster.png" alt="vllm-network-storage-weight-loading-optimizer" width="720"></p>
34
+
35
+ **Load vLLM model weights from network storage (EFS, NFS, S3) fastest, within your memory limit.**
36
+
37
+ **Built for teams serving LLMs with vLLM in containers, with weights on network or object storage** (EFS, NFS, Lustre, gcsfuse, Mountpoint for S3). Two problems keep hitting them:
38
+
39
+ 1. **Slow loads.** A 480B model took 45 minutes on EFS while vLLM's default loader used 18% of the bandwidth ([modelplane#204](https://github.com/modelplaneai/modelplane/issues/204)); loads from FSx in Kubernetes were slow ([vllm#16433](https://github.com/vllm-project/vllm/issues/16433)).
40
+ 2. **Pods OOM-killed while loading.** Run:ai Model Streamer's default 40 GB buffer can exceed the pod's limit ([model-streamer#357](https://github.com/dsx-ai-factory/model-streamer/issues/357)); every tensor-parallel worker held its own copy of the checkpoint ([vllm#44430](https://github.com/vllm-project/vllm/issues/44430)).
41
+
42
+ The two pull in opposite directions: the fastest loader on network storage is the one that needs the most RAM at its defaults. **`wload doctor` finds the fastest loader that fits your memory limit, on your checkpoint and storage, and prints the exact `vllm serve` command and container size.** One command:
43
+
44
+ ```bash
45
+ pip install "vllm-network-storage-weight-loading-optimizer[loaders]"
46
+ wload doctor /models/my-model # any directory of .safetensors files
47
+ ```
48
+
49
+ In Kubernetes, run it where your server runs: same image, model volume, memory limit and node type.
50
+
51
+ ```bash
52
+ wload k8s --image vllm/vllm-openai:v0.23.0 --pvc model-cache --model-path my-model \
53
+ --memory 64Gi --workers 8 > wload-doctor.yaml
54
+ kubectl apply -f wload-doctor.yaml && kubectl logs -f job/wload-doctor
55
+ ```
56
+
57
+ It times each loader on one shard of your checkpoint with a cold cache, inside your memory limit, predicts each one's RAM for the full model, and ends with what to run: the `vllm serve` command and the Kubernetes `args`, `env` and memory limit. It measures one loading process per visible GPU, as tensor parallelism runs, and only recommends options your installed vLLM supports. Below, the hardest case: a 100 ms object-store mount and a 3 GiB container, smaller than the checkpoint (real output, path shortened):
58
+
59
+ ```text
60
+ wload doctor: /mnt/models/qwen3-30b-slice
61
+
62
+ Checkpoint: 3.5 GiB in 4 files, 1,179 tensors (median 3.0 MiB), dtypes {'BF16': 1179}
63
+ Host: 2 CPUs, 7.8 GiB RAM, container limit 3.0 GiB, file system fuseblk, THP madvise, free page reporting off, first-touch 7.23 GB/s
64
+
65
+ Measuring (cold cache, one shard):
66
+ measuring storage on model-00003-of-00004.safetensors (1.12 GiB, 378 tensors)
67
+ safetensors 0.02 GB/s (4% of storage), extra RAM 0.00x
68
+ safetensors-prefetch 0.16 GB/s (33% of storage), extra RAM 0.22x
69
+ runai-streamer 0.38 GB/s (80% of storage), extra RAM 1.00x
70
+ fastsafetensors 0.08 GB/s (17% of storage), extra RAM 1.01x
71
+ runai-streamer[memory_limit=768MiB] 0.39 GB/s (82% of storage), extra RAM 0.79 GiB (bounded)
72
+ runai-streamer[concurrency=32] 0.38 GB/s (tuning, no clear gain; keeping the default)
73
+ runai-streamer[concurrency=64] 0.38 GB/s (tuning, no clear gain; keeping the default)
74
+
75
+ Recommendation:
76
+ - Use runai-streamer[memory_limit=768MiB]. It is 0.39 GB/s here; the exact settings are below.
77
+ - Run:ai's default buffer (up to 40 GB) would hold the whole 3.5 GiB checkpoint in RAM (4.1 GiB), over this limit. Capping it with RUNAI_STREAMER_MEMORY_LIMIT=805306368 keeps it under 1.4 GiB at any model size and keeps its speed.
78
+ - Expected weight-load time for the full 3.5 GiB checkpoint: about 10 s at 0.39 GB/s. If your server takes much longer than that to become ready, the extra time is not storage or the loader: look at torch.compile, CUDA graph capture, or GPU-side weight processing (vLLM logs each stage).
79
+ - Storage is the bottleneck: the best loader reaches 82% of what this storage delivered (0.48 GB/s). A different loader will not help much; a faster tier (local NVMe cache, more bandwidth) will.
80
+ - Slowest here: safetensors (0.02 GB/s), 21.7x slower than runai-streamer[memory_limit=768MiB].
81
+ - Prefetch was not recommended: the full checkpoint (3.5 GiB) does not fit in 90% of the page cache available here (2.4 GiB), so prefetched data would be evicted before it is read (vLLM applies the same rule).
82
+ - Memory: runai-streamer (4.1 GiB), fastsafetensors (4.1 GiB) would need more than 90% of the 3.0 GiB container memory limit for this model and risk an OOM kill mid-load.
83
+ - Host RAM to load the full model: safetensors 0.6 GiB, runai-streamer[memory_limit=768MiB] 1.4 GiB, safetensors-prefetch 4.1 GiB incl. page cache, runai-streamer 4.1 GiB, fastsafetensors 4.1 GiB (your container memory limit: 3.0 GiB).
84
+ - If your server starts several loading processes on this node (for example one per GPU with tensor parallelism), rerun with --workers N: this loader holds its memory in every process.
85
+ - Transparent huge pages are in 'madvise' mode; the chosen loader copies into new memory, and on the reference host setting THP to 'always' cut its page faults ~200x and load time up to 24%.
86
+ - The checkpoint is on a FUSE mount (readahead 1024 KiB). On object-store FUSE mounts, mmap-based loading is latency-bound; parallel loaders keep many requests in flight.
87
+
88
+ Run this:
89
+ export RUNAI_STREAMER_MEMORY_LIMIT=805306368
90
+ vllm serve /mnt/models/qwen3-30b-slice --load-format runai_streamer
91
+ # Kubernetes container spec:
92
+ # args: ["--load-format", "runai_streamer"]
93
+ # env: [{name: RUNAI_STREAMER_MEMORY_LIMIT, value: "805306368"}]
94
+ # resources.limits.memory: at least 2Gi for loading, plus your server's own needs
95
+ # Avoid --safetensors-load-strategy eager in tight containers: it reads whole files into RAM.
96
+
97
+ Covers the weight-loading stage, storage to host memory, where slow network or object storage and container OOM kills happen.
98
+ (doctor took 213 s)
99
+ ```
100
+
101
+ ## Proof
102
+
103
+ Checked against full loads of a 3.5 GiB, 4-file checkpoint on network mounts emulated to match real clients, every load checksum-verified ([details](docs/VALIDATION.md)):
104
+
105
+ | Case | vLLM default | Doctor's pick | Result |
106
+ |---|---:|---:|---|
107
+ | Object-store mount (100 ms per request) | 202 s | 8.2 s | 24.5x faster |
108
+ | Same mount, 3 GiB container | 233 s (fastest loader at defaults: OOM-killed) | 8.2 s, 1.6 GiB peak | 28x faster, no OOM kill |
109
+ | Pick vs. full-model winner, 4 storage types | | | within 2% every time |
110
+ | RAM prediction vs. real cgroup limits | | | never under-predicted |
111
+
112
+ Five real users' cases, rebuilt and solved end to end (EFS and FSx loads, Run:ai buffer over the pod limit, one loading process per GPU, a MoE model on fast NFS): [docs/CASES.md](docs/CASES.md).
113
+
114
+ The benchmark behind the advice: [docs/BENCHMARK.md](docs/BENCHMARK.md). Method: [docs/METHODOLOGY.md](docs/METHODOLOGY.md).
115
+
116
+ ## What it covers
117
+
118
+ The weight-loading stage of startup, storage to host memory, where both problems happen. Doctor chooses among the loaders vLLM ships (`safetensors` lazy or prefetch, Run:ai Model Streamer, fastsafetensors) and tunes them: Run:ai's buffer cap and concurrency, and a container size that keeps prefetch at full speed. Its expected load time also tells you when a slow start is coming from somewhere else, such as `torch.compile` or CUDA graph capture.
119
+
120
+ ## Contributing
121
+
122
+ Doctor results from your own storage (NFS, Lustre, EFS, object-store mounts) make the advice better for everyone; see [docs/CONTRIBUTING.md](docs/CONTRIBUTING.md). License: Apache-2.0. Cite: [CITATION.cff](CITATION.cff).
@@ -0,0 +1,92 @@
1
+ # vllm-network-storage-weight-loading-optimizer
2
+
3
+ <p align="center"><img src="docs/poster.png" alt="vllm-network-storage-weight-loading-optimizer" width="720"></p>
4
+
5
+ **Load vLLM model weights from network storage (EFS, NFS, S3) fastest, within your memory limit.**
6
+
7
+ **Built for teams serving LLMs with vLLM in containers, with weights on network or object storage** (EFS, NFS, Lustre, gcsfuse, Mountpoint for S3). Two problems keep hitting them:
8
+
9
+ 1. **Slow loads.** A 480B model took 45 minutes on EFS while vLLM's default loader used 18% of the bandwidth ([modelplane#204](https://github.com/modelplaneai/modelplane/issues/204)); loads from FSx in Kubernetes were slow ([vllm#16433](https://github.com/vllm-project/vllm/issues/16433)).
10
+ 2. **Pods OOM-killed while loading.** Run:ai Model Streamer's default 40 GB buffer can exceed the pod's limit ([model-streamer#357](https://github.com/dsx-ai-factory/model-streamer/issues/357)); every tensor-parallel worker held its own copy of the checkpoint ([vllm#44430](https://github.com/vllm-project/vllm/issues/44430)).
11
+
12
+ The two pull in opposite directions: the fastest loader on network storage is the one that needs the most RAM at its defaults. **`wload doctor` finds the fastest loader that fits your memory limit, on your checkpoint and storage, and prints the exact `vllm serve` command and container size.** One command:
13
+
14
+ ```bash
15
+ pip install "vllm-network-storage-weight-loading-optimizer[loaders]"
16
+ wload doctor /models/my-model # any directory of .safetensors files
17
+ ```
18
+
19
+ In Kubernetes, run it where your server runs: same image, model volume, memory limit and node type.
20
+
21
+ ```bash
22
+ wload k8s --image vllm/vllm-openai:v0.23.0 --pvc model-cache --model-path my-model \
23
+ --memory 64Gi --workers 8 > wload-doctor.yaml
24
+ kubectl apply -f wload-doctor.yaml && kubectl logs -f job/wload-doctor
25
+ ```
26
+
27
+ It times each loader on one shard of your checkpoint with a cold cache, inside your memory limit, predicts each one's RAM for the full model, and ends with what to run: the `vllm serve` command and the Kubernetes `args`, `env` and memory limit. It measures one loading process per visible GPU, as tensor parallelism runs, and only recommends options your installed vLLM supports. Below, the hardest case: a 100 ms object-store mount and a 3 GiB container, smaller than the checkpoint (real output, path shortened):
28
+
29
+ ```text
30
+ wload doctor: /mnt/models/qwen3-30b-slice
31
+
32
+ Checkpoint: 3.5 GiB in 4 files, 1,179 tensors (median 3.0 MiB), dtypes {'BF16': 1179}
33
+ Host: 2 CPUs, 7.8 GiB RAM, container limit 3.0 GiB, file system fuseblk, THP madvise, free page reporting off, first-touch 7.23 GB/s
34
+
35
+ Measuring (cold cache, one shard):
36
+ measuring storage on model-00003-of-00004.safetensors (1.12 GiB, 378 tensors)
37
+ safetensors 0.02 GB/s (4% of storage), extra RAM 0.00x
38
+ safetensors-prefetch 0.16 GB/s (33% of storage), extra RAM 0.22x
39
+ runai-streamer 0.38 GB/s (80% of storage), extra RAM 1.00x
40
+ fastsafetensors 0.08 GB/s (17% of storage), extra RAM 1.01x
41
+ runai-streamer[memory_limit=768MiB] 0.39 GB/s (82% of storage), extra RAM 0.79 GiB (bounded)
42
+ runai-streamer[concurrency=32] 0.38 GB/s (tuning, no clear gain; keeping the default)
43
+ runai-streamer[concurrency=64] 0.38 GB/s (tuning, no clear gain; keeping the default)
44
+
45
+ Recommendation:
46
+ - Use runai-streamer[memory_limit=768MiB]. It is 0.39 GB/s here; the exact settings are below.
47
+ - Run:ai's default buffer (up to 40 GB) would hold the whole 3.5 GiB checkpoint in RAM (4.1 GiB), over this limit. Capping it with RUNAI_STREAMER_MEMORY_LIMIT=805306368 keeps it under 1.4 GiB at any model size and keeps its speed.
48
+ - Expected weight-load time for the full 3.5 GiB checkpoint: about 10 s at 0.39 GB/s. If your server takes much longer than that to become ready, the extra time is not storage or the loader: look at torch.compile, CUDA graph capture, or GPU-side weight processing (vLLM logs each stage).
49
+ - Storage is the bottleneck: the best loader reaches 82% of what this storage delivered (0.48 GB/s). A different loader will not help much; a faster tier (local NVMe cache, more bandwidth) will.
50
+ - Slowest here: safetensors (0.02 GB/s), 21.7x slower than runai-streamer[memory_limit=768MiB].
51
+ - Prefetch was not recommended: the full checkpoint (3.5 GiB) does not fit in 90% of the page cache available here (2.4 GiB), so prefetched data would be evicted before it is read (vLLM applies the same rule).
52
+ - Memory: runai-streamer (4.1 GiB), fastsafetensors (4.1 GiB) would need more than 90% of the 3.0 GiB container memory limit for this model and risk an OOM kill mid-load.
53
+ - Host RAM to load the full model: safetensors 0.6 GiB, runai-streamer[memory_limit=768MiB] 1.4 GiB, safetensors-prefetch 4.1 GiB incl. page cache, runai-streamer 4.1 GiB, fastsafetensors 4.1 GiB (your container memory limit: 3.0 GiB).
54
+ - If your server starts several loading processes on this node (for example one per GPU with tensor parallelism), rerun with --workers N: this loader holds its memory in every process.
55
+ - Transparent huge pages are in 'madvise' mode; the chosen loader copies into new memory, and on the reference host setting THP to 'always' cut its page faults ~200x and load time up to 24%.
56
+ - The checkpoint is on a FUSE mount (readahead 1024 KiB). On object-store FUSE mounts, mmap-based loading is latency-bound; parallel loaders keep many requests in flight.
57
+
58
+ Run this:
59
+ export RUNAI_STREAMER_MEMORY_LIMIT=805306368
60
+ vllm serve /mnt/models/qwen3-30b-slice --load-format runai_streamer
61
+ # Kubernetes container spec:
62
+ # args: ["--load-format", "runai_streamer"]
63
+ # env: [{name: RUNAI_STREAMER_MEMORY_LIMIT, value: "805306368"}]
64
+ # resources.limits.memory: at least 2Gi for loading, plus your server's own needs
65
+ # Avoid --safetensors-load-strategy eager in tight containers: it reads whole files into RAM.
66
+
67
+ Covers the weight-loading stage, storage to host memory, where slow network or object storage and container OOM kills happen.
68
+ (doctor took 213 s)
69
+ ```
70
+
71
+ ## Proof
72
+
73
+ Checked against full loads of a 3.5 GiB, 4-file checkpoint on network mounts emulated to match real clients, every load checksum-verified ([details](docs/VALIDATION.md)):
74
+
75
+ | Case | vLLM default | Doctor's pick | Result |
76
+ |---|---:|---:|---|
77
+ | Object-store mount (100 ms per request) | 202 s | 8.2 s | 24.5x faster |
78
+ | Same mount, 3 GiB container | 233 s (fastest loader at defaults: OOM-killed) | 8.2 s, 1.6 GiB peak | 28x faster, no OOM kill |
79
+ | Pick vs. full-model winner, 4 storage types | | | within 2% every time |
80
+ | RAM prediction vs. real cgroup limits | | | never under-predicted |
81
+
82
+ Five real users' cases, rebuilt and solved end to end (EFS and FSx loads, Run:ai buffer over the pod limit, one loading process per GPU, a MoE model on fast NFS): [docs/CASES.md](docs/CASES.md).
83
+
84
+ The benchmark behind the advice: [docs/BENCHMARK.md](docs/BENCHMARK.md). Method: [docs/METHODOLOGY.md](docs/METHODOLOGY.md).
85
+
86
+ ## What it covers
87
+
88
+ The weight-loading stage of startup, storage to host memory, where both problems happen. Doctor chooses among the loaders vLLM ships (`safetensors` lazy or prefetch, Run:ai Model Streamer, fastsafetensors) and tunes them: Run:ai's buffer cap and concurrency, and a container size that keeps prefetch at full speed. Its expected load time also tells you when a slow start is coming from somewhere else, such as `torch.compile` or CUDA graph capture.
89
+
90
+ ## Contributing
91
+
92
+ Doctor results from your own storage (NFS, Lustre, EFS, object-store mounts) make the advice better for everyone; see [docs/CONTRIBUTING.md](docs/CONTRIBUTING.md). License: Apache-2.0. Cite: [CITATION.cff](CITATION.cff).
@@ -0,0 +1,40 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "vllm-network-storage-weight-loading-optimizer"
7
+ version = "0.1.0"
8
+ description = "Load vLLM model weights from network storage (EFS, NFS, S3) fastest, within your memory limit."
9
+ readme = "README.md"
10
+ license = "Apache-2.0"
11
+ requires-python = ">=3.10"
12
+ authors = [{ name = "Ameerul Ali Shah Pattan" }]
13
+ keywords = ["llm", "inference", "cold start", "model loading", "safetensors", "benchmark", "storage"]
14
+ classifiers = [
15
+ "Programming Language :: Python :: 3",
16
+ "Operating System :: POSIX :: Linux",
17
+ "Topic :: System :: Benchmark",
18
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
19
+ ]
20
+ dependencies = ["numpy>=1.24", "xxhash>=3", "torch>=2.1", "safetensors>=0.4"]
21
+
22
+ [project.optional-dependencies]
23
+ loaders = ["runai-model-streamer>=0.15", "fastsafetensors>=0.1", "tensorizer>=2.9"]
24
+ report = ["matplotlib>=3.7"]
25
+ dev = ["pytest>=7"]
26
+
27
+ [project.urls]
28
+ Homepage = "https://github.com/AmeerulShah/vllm-network-storage-weight-loading-optimizer"
29
+ Issues = "https://github.com/AmeerulShah/vllm-network-storage-weight-loading-optimizer/issues"
30
+
31
+ [project.scripts]
32
+ wload = "vllm_network_storage_weight_loading_optimizer.cli:main"
33
+ vllm-network-storage-weight-loading-optimizer = "vllm_network_storage_weight_loading_optimizer.cli:main"
34
+
35
+ [tool.setuptools.packages.find]
36
+ where = ["src"]
37
+
38
+
39
+ [tool.setuptools.exclude-package-data]
40
+ wload = ["bin/*"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,2 @@
1
+ """wload: a neutral benchmark for how fast LLM weights load from storage at cold start."""
2
+ __version__ = "0.1.0"
@@ -0,0 +1,160 @@
1
+ """wload command line."""
2
+ from __future__ import annotations
3
+
4
+ import argparse
5
+ import json
6
+ import os
7
+ import sys
8
+
9
+ from . import __version__
10
+
11
+
12
+ def _csv(s):
13
+ return [x for x in s.split(",") if x]
14
+
15
+
16
+ def _opts(items):
17
+ out = {}
18
+ for it in items or []:
19
+ loader, kv = it.split(":", 1)
20
+ k, v = kv.split("=", 1)
21
+ try:
22
+ v = json.loads(v)
23
+ except ValueError:
24
+ pass
25
+ out.setdefault(loader, {})[k] = v
26
+ return out
27
+
28
+
29
+ def main(argv=None):
30
+ from .loaders import LOADERS
31
+ from .storage import PROFILES
32
+ from .workloads import REGISTRY, get
33
+
34
+ ap = argparse.ArgumentParser(prog="wload", description=__doc__)
35
+ ap.add_argument("--version", action="version", version=__version__)
36
+ sub = ap.add_subparsers(dest="cmd", required=True)
37
+
38
+ sub.add_parser("list", help="list workloads, loaders and storage profiles")
39
+
40
+ m = sub.add_parser("make", help="generate a workload checkpoint")
41
+ m.add_argument("workloads", type=_csv)
42
+ m.add_argument("--data", required=True)
43
+ m.add_argument("--formats", type=_csv, default=["safetensors"],
44
+ help="also build: torch-bin, tensorizer")
45
+
46
+ r = sub.add_parser("run", help="run the benchmark matrix")
47
+ r.add_argument("--workloads", type=_csv, default=["qwen3-0.6b"])
48
+ r.add_argument("--loaders", type=_csv, default=["all"])
49
+ r.add_argument("--profiles", type=_csv, default=["local"])
50
+ r.add_argument("--reps", type=int, default=5)
51
+ r.add_argument("--data", required=True, help="directory holding the checkpoints "
52
+ "(put it on the storage you want to measure)")
53
+ r.add_argument("--out", default="results/results.jsonl")
54
+ r.add_argument("--mnt", default=None, help="mountpoint for emulated profiles")
55
+ r.add_argument("--opt", action="append", help="tuned division knob, e.g. runai-streamer:concurrency=32")
56
+ r.add_argument("--timeout", type=int, default=900)
57
+ r.add_argument("--seed", type=int, default=0)
58
+ r.add_argument("--no-verify", action="store_true")
59
+ r.add_argument("--no-ceiling", action="store_true")
60
+
61
+ dr = sub.add_parser("doctor", help="diagnose loading for your checkpoint, storage and host, and recommend a loader")
62
+ dr.add_argument("model_dir", help="directory with the model's .safetensors files")
63
+ dr.add_argument("--reps", type=int, default=2)
64
+ dr.add_argument("--json", default=None, help="also write the full diagnosis as JSON")
65
+ dr.add_argument("--workers", type=int, default=None,
66
+ help="processes that load the model at once on this node, e.g. the tensor-parallel size "
67
+ "(default: one per visible GPU)")
68
+
69
+ k = sub.add_parser("k8s", help="print a Kubernetes Job that runs doctor next to your vLLM deployment")
70
+ k.add_argument("--image", required=True, help="the image your vLLM deployment runs, e.g. vllm/vllm-openai:v0.23.0")
71
+ k.add_argument("--pvc", required=True, help="PersistentVolumeClaim holding the model")
72
+ k.add_argument("--model-path", required=True, help="model directory, absolute or relative to --mount-path")
73
+ k.add_argument("--mount-path", default="/models")
74
+ k.add_argument("--memory", required=True, help="the deployment's memory limit, e.g. 64Gi")
75
+ k.add_argument("--workers", type=int, default=1, help="the deployment's tensor-parallel size")
76
+ k.add_argument("--cpu", default="8")
77
+ k.add_argument("--name", default="wload-doctor")
78
+ k.add_argument("--namespace", default=None)
79
+ k.add_argument("--node-selector", action="append", default=[],
80
+ help="key=value, to run on the same node type as the deployment")
81
+
82
+ f = sub.add_parser("fit", help="smallest container memory limit each loader can load a model in")
83
+ f.add_argument("--workload", default="qwen3-0.6b")
84
+ f.add_argument("--loaders", type=_csv, default=["all"])
85
+ f.add_argument("--data", required=True)
86
+ f.add_argument("--out", default="results/fit.jsonl")
87
+ f.add_argument("--limits", type=_csv, default=None, help="explicit limits to try, in GiB, e.g. 1,1.5,2,2.5")
88
+
89
+ rp = sub.add_parser("report", help="summarize results into tables, figures and a leaderboard")
90
+ rp.add_argument("results", nargs="+")
91
+ rp.add_argument("--out", default="report")
92
+
93
+ a = ap.parse_args(argv)
94
+
95
+ if a.cmd == "list":
96
+ print("Workloads:")
97
+ for w in REGISTRY.values():
98
+ s = w.summary()
99
+ print(f" {w.name:24s} {s['bytes'] / 2**30:6.2f} GiB {s['tensors']:6d} tensors {w.description}")
100
+ print("\nLoaders:")
101
+ for k, v in LOADERS.items():
102
+ print(f" {k:22s} {v['desc']}")
103
+ print("\nStorage profiles:")
104
+ for k, v in PROFILES.items():
105
+ print(f" {k:12s} {v.note}")
106
+ return 0
107
+
108
+ if a.cmd == "make":
109
+ from . import make
110
+ for wn in a.workloads:
111
+ d = os.path.join(a.data, wn)
112
+ make.write(get(wn), d)
113
+ for f in a.formats:
114
+ if f != "safetensors":
115
+ make.convert(d, f)
116
+ print(f"{wn}: {d}")
117
+ return 0
118
+
119
+ if a.cmd == "run":
120
+ from . import runner
121
+ loaders = list(LOADERS) if a.loaders == ["all"] else a.loaders
122
+ for l in loaders:
123
+ if l not in LOADERS:
124
+ sys.exit(f"unknown loader {l!r}")
125
+ runner.run(a.workloads, loaders, a.profiles, a.reps, a.data, a.out, mnt_root=a.mnt,
126
+ opts=_opts(a.opt), seed=a.seed, timeout=a.timeout, verify=not a.no_verify,
127
+ ceiling=not a.no_ceiling)
128
+ return 0
129
+
130
+ if a.cmd == "k8s":
131
+ from . import k8s
132
+ sel = dict(kv.split("=", 1) for kv in a.node_selector)
133
+ print(k8s.render(image=a.image, pvc=a.pvc, model_path=a.model_path, mount_path=a.mount_path,
134
+ memory=a.memory, workers=a.workers, cpu=a.cpu, name=a.name, namespace=a.namespace,
135
+ node_selector=sel), end="")
136
+ return
137
+ if a.cmd == "doctor":
138
+ from . import doctor
139
+ doctor.run(a.model_dir, reps=a.reps, as_json=a.json, workers=a.workers)
140
+ return 0
141
+
142
+ if a.cmd == "fit":
143
+ from . import fit as fitmod
144
+ loaders = [l for l in LOADERS if LOADERS[l]["fmt"] == "safetensors"] if a.loaders == ["all"] else a.loaders
145
+ res = fitmod.fit(a.workload, loaders, a.data, a.out,
146
+ limits_gib=[float(x) for x in a.limits] if a.limits else None)
147
+ print("\nSmallest memory limit that loaded and verified (cold cache, page cache charged):")
148
+ for r in sorted(res, key=lambda r: r["min_limit_bytes"] or 1 << 62):
149
+ lim = f"{r['min_limit_bytes'] / 2**30:.2f} GiB ({r['min_multiple']}x model)" if r["min_limit_bytes"] else "did not fit in the tested range"
150
+ print(f" {r['loader']:22s} {lim}")
151
+ return 0
152
+
153
+ if a.cmd == "report":
154
+ from . import report
155
+ report.build(a.results, a.out)
156
+ return 0
157
+
158
+
159
+ if __name__ == "__main__":
160
+ sys.exit(main())