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, 22:00 UTC
[Misc] Add generated git commit hash as `vllm.__commit__` (#6386)
Michael Goin committed
Jul 12, 2024 at 18:52 UTC
111fc6e7ecb8e5eb665606cf79209495e874479b
5 files changed
+47
-1
.gitignore
+3
@@ -1,3 +1,6 @@
1
+# vllm commit id, generated by setup.py
2
+vllm/commit_id.py
3
+
4
# Byte-compiled / optimized / DLL files
5
__pycache__/
6
*.py[cod]
setup.py
+24
@@ -5,6 +5,7 @@ import os
5
import re
6
import subprocess
7
import sys
8
+import warnings
9
from shutil import which
10
from typing import Dict, List
11
@@ -26,6 +27,29 @@ def load_module_from_path(module_name, path):
27
ROOT_DIR = os.path.dirname(__file__)
28
logger = logging.getLogger(__name__)
29
30
+
31
+def embed_commit_hash():
32
+ try:
33
+ commit_id = subprocess.check_output(["git", "rev-parse", "HEAD"],
34
+ encoding="utf-8").strip()
35
+ commit_contents = f'__commit__ = "{commit_id}"\n'
36
+
37
+ version_file = os.path.join(ROOT_DIR, "vllm", "commit_id.py")
38
+ with open(version_file, "w", encoding="utf-8") as f:
39
+ f.write(commit_contents)
40
+
41
+ except subprocess.CalledProcessError as e:
42
+ warnings.warn(f"Failed to get commit hash:\n{e}",
43
+ RuntimeWarning,
44
+ stacklevel=2)
45
+ except Exception as e:
46
+ warnings.warn(f"Failed to embed commit hash:\n{e}",
47
+ RuntimeWarning,
48
+ stacklevel=2)
49
+
50
+
51
+embed_commit_hash()
52
+
53
# cannot import envs directly because it depends on vllm,
54
# which is not installed yet
55
envs = load_module_from_path('envs', os.path.join(ROOT_DIR, 'vllm', 'envs.py'))
tests/test_embedded_commit.py
new
+7
@@ -0,0 +1,7 @@
1
+import vllm
2
+
3
+
4
+def test_embedded_commit_defined():
5
+ assert vllm.__commit__ != "COMMIT_HASH_PLACEHOLDER"
6
+ # 7 characters is the length of a short commit hash
7
+ assert len(vllm.__commit__) >= 7
vllm/__init__.py
+2
-1
@@ -12,9 +12,10 @@ from vllm.outputs import (CompletionOutput, EmbeddingOutput,
12
from vllm.pooling_params import PoolingParams
13
from vllm.sampling_params import SamplingParams
14
15
-from .version import __version__
15
+from .version import __commit__, __version__
16
17
__all__ = [
18
+ "__commit__",
19
"__version__",
20
"LLM",
21
"ModelRegistry",
vllm/version.py
+11
@@ -1 +1,12 @@
1
+import warnings
2
+
3
+try:
4
+ import vllm.commit_id
5
+ __commit__ = vllm.commit_id.__commit__
6
+except Exception as e:
7
+ warnings.warn(f"Failed to read commit hash:\n{e}",
8
+ RuntimeWarning,
9
+ stacklevel=2)
10
+ __commit__ = "COMMIT_HASH_PLACEHOLDER"
11
+
12
__version__ = "0.5.1"