@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / ccd7207191
Fork 0

A high-throughput and memory-efficient inference and serving engine for LLMs

Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git

Synced Nov 16, 17:00 UTC

chore: Update check-wheel-size.py to read MAX_SIZE_MB from env (#8103)

TimWang committed Sep 4, 2024 at 14:17 UTC ccd72071911951a3eb73b52a1578c8e6e51130d7
2 files changed +31 -17
.buildkite/check-wheel-size.py
+21 -14
@@ -1,36 +1,43 @@
1 import os
2 +import sys
3 import zipfile
4
4 -MAX_SIZE_MB = 250
5 +# Read the VLLM_MAX_SIZE_MB environment variable, defaulting to 250 MB
6 +VLLM_MAX_SIZE_MB = int(os.environ.get('VLLM_MAX_SIZE_MB', 250))
7
8
9 def print_top_10_largest_files(zip_file):
10 + """Print the top 10 largest files in the given zip file."""
11 with zipfile.ZipFile(zip_file, 'r') as z:
12 file_sizes = [(f, z.getinfo(f).file_size) for f in z.namelist()]
13 file_sizes.sort(key=lambda x: x[1], reverse=True)
14 for f, size in file_sizes[:10]:
12 - print(f"{f}: {size/(1024*1024)} MBs uncompressed.")
15 + print(f"{f}: {size / (1024 * 1024):.2f} MBs uncompressed.")
16
17
18 def check_wheel_size(directory):
19 + """Check the size of .whl files in the given directory."""
20 for root, _, files in os.walk(directory):
17 - for f in files:
18 - if f.endswith(".whl"):
19 - wheel_path = os.path.join(root, f)
20 - wheel_size = os.path.getsize(wheel_path)
21 - wheel_size_mb = wheel_size / (1024 * 1024)
22 - if wheel_size_mb > MAX_SIZE_MB:
23 - print(
24 - f"Wheel {wheel_path} is too large ({wheel_size_mb} MB) "
25 - f"compare to the allowed size ({MAX_SIZE_MB} MB).")
21 + for file_name in files:
22 + if file_name.endswith(".whl"):
23 + wheel_path = os.path.join(root, file_name)
24 + wheel_size_mb = os.path.getsize(wheel_path) / (1024 * 1024)
25 + if wheel_size_mb > VLLM_MAX_SIZE_MB:
26 + print(f"Not allowed: Wheel {wheel_path} is larger "
27 + f"({wheel_size_mb:.2f} MB) than the limit "
28 + f"({VLLM_MAX_SIZE_MB} MB).")
29 print_top_10_largest_files(wheel_path)
30 return 1
31 else:
32 print(f"Wheel {wheel_path} is within the allowed size "
30 - f"({wheel_size_mb} MB).")
33 + f"({wheel_size_mb:.2f} MB).")
34 return 0
35
36
37 if __name__ == "__main__":
35 - import sys
36 - sys.exit(check_wheel_size(sys.argv[1]))
38 + if len(sys.argv) < 2:
39 + print("Usage: python check-wheel-size.py <directory>")
40 + sys.exit(1)
41 +
42 + directory = sys.argv[1]
43 + sys.exit(check_wheel_size(directory))
\ No newline at end of file
Dockerfile
+10 -3
@@ -108,10 +108,17 @@ RUN --mount=type=cache,target=/root/.cache/ccache \
108 python3 setup.py bdist_wheel --dist-dir=dist --py-limited-api=cp38; \
109 fi
110
111 -# check the size of the wheel, we cannot upload wheels larger than 100MB
111 +# Check the size of the wheel if RUN_WHEEL_CHECK is true
112 COPY .buildkite/check-wheel-size.py check-wheel-size.py
113 -RUN python3 check-wheel-size.py dist
114 -
113 +# Default max size of the wheel is 250MB
114 +ARG VLLM_MAX_SIZE_MB=250
115 +ENV VLLM_MAX_SIZE_MB=$VLLM_MAX_SIZE_MB
116 +ARG RUN_WHEEL_CHECK=true
117 +RUN if [ "$RUN_WHEEL_CHECK" = "true" ]; then \
118 + python3 check-wheel-size.py dist; \
119 + else \
120 + echo "Skipping wheel size check."; \
121 + fi
122 #################### EXTENSION Build IMAGE ####################
123
124 #################### DEV IMAGE ####################