Skip to content

Commit be22bb6

Browse files
authored
Run:ai model streamer add GCS package support (vllm-project#24909)
Signed-off-by: Peter Schuurman <[email protected]>
1 parent 169313b commit be22bb6

File tree

6 files changed

+54
-9
lines changed

6 files changed

+54
-9
lines changed

docs/models/extensions/runai_model_streamer.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ vllm serve s3://core-llm/Llama-3-8b \
2424
--load-format runai_streamer
2525
```
2626

27+
To run model from Google Cloud Storage run:
28+
29+
```bash
30+
vllm serve gs://core-llm/Llama-3-8b \
31+
--load-format runai_streamer
32+
```
33+
2734
To run model from a S3 compatible object store run:
2835

2936
```bash

requirements/nightly_torch_test.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@ tritonclient==2.51.0
4343
numba == 0.60.0; python_version == '3.9' # v0.61 doesn't support Python 3.9. Required for N-gram speculative decoding
4444
numba == 0.61.2; python_version > '3.9'
4545
numpy
46-
runai-model-streamer[s3]==0.14.0
46+
runai-model-streamer[s3,gcs]==0.14.0
4747
fastsafetensors>=0.1.10
4848
pydantic>=2.10 # 2.9 leads to error on python 3.10

requirements/rocm.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ tensorizer==2.10.1
1313
packaging>=24.2
1414
setuptools>=77.0.3,<80.0.0
1515
setuptools-scm>=8
16-
runai-model-streamer[s3]==0.14.0
16+
runai-model-streamer[s3,gcs]==0.14.0
1717
conch-triton-kernels==1.2.1
18-
timm>=1.0.17
18+
timm>=1.0.17

requirements/test.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ tritonclient==2.51.0
5151
numba == 0.60.0; python_version == '3.9' # v0.61 doesn't support Python 3.9. Required for N-gram speculative decoding
5252
numba == 0.61.2; python_version > '3.9'
5353
numpy
54-
runai-model-streamer[s3]==0.14.0
54+
runai-model-streamer[s3,gcs]==0.14.0
5555
fastsafetensors>=0.1.10
5656
pydantic>=2.10 # 2.9 leads to error on python 3.10
5757
decord==0.6.0

requirements/test.txt

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,11 +251,27 @@ gitdb==4.0.12
251251
gitpython==3.1.44
252252
# via mlflow-skinny
253253
google-api-core==2.24.2
254-
# via opencensus
254+
# via
255+
# google-cloud-core
256+
# google-cloud-storage
257+
# opencensus
255258
google-auth==2.40.2
256259
# via
257260
# databricks-sdk
258261
# google-api-core
262+
# google-cloud-core
263+
# google-cloud-storage
264+
# runai-model-streamer-gcs
265+
google-cloud-core==2.4.3
266+
# via google-cloud-storage
267+
google-cloud-storage==3.4.0
268+
# via runai-model-streamer-gcs
269+
google-crc32c==1.7.1
270+
# via
271+
# google-cloud-storage
272+
# google-resumable-media
273+
google-resumable-media==2.7.2
274+
# via google-cloud-storage
259275
googleapis-common-protos==1.70.0
260276
# via google-api-core
261277
graphene==3.4.3
@@ -890,6 +906,7 @@ requests==2.32.3
890906
# docker
891907
# evaluate
892908
# google-api-core
909+
# google-cloud-storage
893910
# huggingface-hub
894911
# lightly
895912
# lm-eval
@@ -929,6 +946,8 @@ rtree==1.4.0
929946
# via torchgeo
930947
runai-model-streamer==0.14.0
931948
# via -r requirements/test.in
949+
runai-model-streamer-gcs==0.14.0
950+
# via runai-model-streamer
932951
runai-model-streamer-s3==0.14.0
933952
# via runai-model-streamer
934953
s3transfer==0.10.3

tests/model_executor/model_loader/runai_model_streamer/test_runai_utils.py

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
22
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
33

44
import glob
5+
import hashlib
56
import os
67
import tempfile
78

89
import huggingface_hub.constants
910

1011
from vllm.model_executor.model_loader.weight_utils import (
1112
download_weights_from_hf)
12-
from vllm.transformers_utils.runai_utils import (is_runai_obj_uri,
13+
from vllm.transformers_utils.runai_utils import (ObjectStorageModel,
14+
is_runai_obj_uri,
1315
list_safetensors)
1416

1517

@@ -34,6 +36,23 @@ def test_runai_list_safetensors_local():
3436
assert len(safetensors) == len(files)
3537

3638

37-
if __name__ == "__main__":
38-
test_is_runai_obj_uri()
39-
test_runai_list_safetensors_local()
39+
def test_runai_pull_files_gcs(monkeypatch):
40+
monkeypatch.setenv("RUNAI_STREAMER_GCS_USE_ANONYMOUS_CREDENTIALS", "true")
41+
# Bypass default project lookup by setting GOOGLE_CLOUD_PROJECT
42+
monkeypatch.setenv("GOOGLE_CLOUD_PROJECT", "fake-project")
43+
filename = "LT08_L1GT_074061_20130309_20170505_01_T2_MTL.txt"
44+
gcs_bucket = "gs://gcp-public-data-landsat/LT08/01/074/061/LT08_L1GT_074061_20130309_20170505_01_T2/"
45+
gcs_url = f"{gcs_bucket}/{filename}"
46+
model = ObjectStorageModel(gcs_url)
47+
model.pull_files(gcs_bucket, allow_pattern=[f"*{filename}"])
48+
# To re-generate / change URLs:
49+
# gsutil ls -L gs://<gcs-url> | grep "Hash (md5)" | tr -d ' ' \
50+
# | cut -d":" -f2 | base64 -d | xxd -p
51+
expected_checksum = "f60dea775da1392434275b311b31a431"
52+
hasher = hashlib.new("md5")
53+
with open(os.path.join(model.dir, filename), 'rb') as f:
54+
# Read the file in chunks to handle large files efficiently
55+
for chunk in iter(lambda: f.read(4096), b''):
56+
hasher.update(chunk)
57+
actual_checksum = hasher.hexdigest()
58+
assert actual_checksum == expected_checksum

0 commit comments

Comments
 (0)