@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / 7a6d45bc8a
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 15, 17:15 UTC

Support FIPS enabled machines with MD5 hashing (#15299)

Signed-off-by: Matthew Vine <32849887+MattTheCuber@users.noreply.github.com>

Matthew Vine committed Mar 26, 2025 at 20:19 UTC 7a6d45bc8a201623c646627becd837afd6b35bc7
4 files changed +36 -19
tests/compile/piecewise/test_toy_llama.py
+2 -1
@@ -63,7 +63,8 @@ class LlamaConfig:
63 factors.append((k, v))
64 factors.sort()
65 import hashlib
66 - return hashlib.md5(str(factors).encode()).hexdigest()
66 + return hashlib.md5(str(factors).encode(),
67 + usedforsecurity=False).hexdigest()
68
69 def __post_init__(self):
70 assert self.mlp_size >= self.hidden_size
vllm/compilation/backends.py
+4 -3
@@ -381,8 +381,8 @@ class VllmBackend:
381 with open(filepath) as f:
382 hash_content.append(f.read())
383 import hashlib
384 - code_hash = hashlib.md5(
385 - "\n".join(hash_content).encode()).hexdigest()
384 + code_hash = hashlib.md5("\n".join(hash_content).encode(),
385 + usedforsecurity=False).hexdigest()
386 factors.append(code_hash)
387
388 # 3. compiler hash
@@ -390,7 +390,8 @@ class VllmBackend:
390 factors.append(compiler_hash)
391
392 # combine all factors to generate the cache dir
393 - hash_key = hashlib.md5(str(factors).encode()).hexdigest()[:10]
393 + hash_key = hashlib.md5(str(factors).encode(),
394 + usedforsecurity=False).hexdigest()[:10]
395
396 cache_dir = os.path.join(
397 envs.VLLM_CACHE_ROOT,
vllm/compilation/compiler_interface.py
+2 -1
@@ -139,7 +139,8 @@ class InductorAdaptor(CompilerInterface):
139 from torch._inductor.codecache import torch_key
140 torch_factors = torch_key()
141 factors.append(torch_factors)
142 - hash_str = hashlib.md5(str(factors).encode()).hexdigest()[:10]
142 + hash_str = hashlib.md5(str(factors).encode(),
143 + usedforsecurity=False).hexdigest()[:10]
144 return hash_str
145
146 def initialize_cache(self, cache_dir: str, disable_cache: bool = False):
vllm/config.py
+28 -14
@@ -1111,7 +1111,8 @@ class CacheConfig:
1111 factors: list[Any] = []
1112 factors.append(self.cache_dtype)
1113 # `cpu_offload_gb` does not use `torch.compile` yet.
1114 - hash_str = hashlib.md5(str(factors).encode()).hexdigest()
1114 + hash_str = hashlib.md5(str(factors).encode(),
1115 + usedforsecurity=False).hexdigest()
1116 return hash_str
1117
1118 def __init__(
@@ -1243,7 +1244,8 @@ class TokenizerPoolConfig:
1244 # no factors to consider.
1245 # this config will not affect the computation graph.
1246 factors: list[Any] = []
1246 - hash_str = hashlib.md5(str(factors).encode()).hexdigest()
1247 + hash_str = hashlib.md5(str(factors).encode(),
1248 + usedforsecurity=False).hexdigest()
1249 return hash_str
1250
1251 def __post_init__(self):
@@ -1354,7 +1356,8 @@ class LoadConfig:
1356 # no factors to consider.
1357 # this config will not affect the computation graph.
1358 factors: list[Any] = []
1357 - hash_str = hashlib.md5(str(factors).encode()).hexdigest()
1359 + hash_str = hashlib.md5(str(factors).encode(),
1360 + usedforsecurity=False).hexdigest()
1361 return hash_str
1362
1363 def __post_init__(self):
@@ -1674,7 +1677,8 @@ class SchedulerConfig:
1677 # no factors to consider.
1678 # this config will not affect the computation graph.
1679 factors: list[Any] = []
1677 - hash_str = hashlib.md5(str(factors).encode()).hexdigest()
1680 + hash_str = hashlib.md5(str(factors).encode(),
1681 + usedforsecurity=False).hexdigest()
1682 return hash_str
1683
1684 def __post_init__(self) -> None:
@@ -1810,7 +1814,8 @@ class DeviceConfig:
1814 # the device/platform information will be summarized
1815 # by torch/vllm automatically.
1816 factors: list[Any] = []
1813 - hash_str = hashlib.md5(str(factors).encode()).hexdigest()
1817 + hash_str = hashlib.md5(str(factors).encode(),
1818 + usedforsecurity=False).hexdigest()
1819 return hash_str
1820
1821 def __init__(self, device: str = "auto") -> None:
@@ -1983,7 +1988,8 @@ class SpeculativeConfig:
1988 # no factors to consider.
1989 # spec decode does not use `torch.compile` yet.
1990 factors: list[Any] = []
1986 - hash_str = hashlib.md5(str(factors).encode()).hexdigest()
1991 + hash_str = hashlib.md5(str(factors).encode(),
1992 + usedforsecurity=False).hexdigest()
1993 return hash_str
1994
1995 @classmethod
@@ -2358,7 +2364,8 @@ class LoRAConfig:
2364 factors.append(self.lora_extra_vocab_size)
2365 factors.append(self.long_lora_scaling_factors)
2366 factors.append(self.bias_enabled)
2361 - hash_str = hashlib.md5(str(factors).encode()).hexdigest()
2367 + hash_str = hashlib.md5(str(factors).encode(),
2368 + usedforsecurity=False).hexdigest()
2369 return hash_str
2370
2371 def __post_init__(self):
@@ -2424,7 +2431,8 @@ class PromptAdapterConfig:
2431 # no factors to consider.
2432 # this config will not affect the computation graph.
2433 factors: list[Any] = []
2427 - hash_str = hashlib.md5(str(factors).encode()).hexdigest()
2434 + hash_str = hashlib.md5(str(factors).encode(),
2435 + usedforsecurity=False).hexdigest()
2436 return hash_str
2437
2438 def __post_init__(self):
@@ -2469,7 +2477,8 @@ class MultiModalConfig:
2477 # no factors to consider.
2478 # this config will not affect the computation graph.
2479 factors: list[Any] = []
2472 - hash_str = hashlib.md5(str(factors).encode()).hexdigest()
2480 + hash_str = hashlib.md5(str(factors).encode(),
2481 + usedforsecurity=False).hexdigest()
2482 return hash_str
2483
2484 def get_limit_per_prompt(self, modality: str) -> int:
@@ -2535,7 +2544,8 @@ class PoolerConfig:
2544 # no factors to consider.
2545 # this config will not affect the computation graph.
2546 factors: list[Any] = []
2538 - hash_str = hashlib.md5(str(factors).encode()).hexdigest()
2547 + hash_str = hashlib.md5(str(factors).encode(),
2548 + usedforsecurity=False).hexdigest()
2549 return hash_str
2550
2551 @staticmethod
@@ -2816,7 +2826,8 @@ class DecodingConfig:
2826 # no factors to consider.
2827 # this config will not affect the computation graph.
2828 factors: list[Any] = []
2819 - hash_str = hashlib.md5(str(factors).encode()).hexdigest()
2829 + hash_str = hashlib.md5(str(factors).encode(),
2830 + usedforsecurity=False).hexdigest()
2831 return hash_str
2832
2833 def __post_init__(self):
@@ -2866,7 +2877,8 @@ class ObservabilityConfig:
2877 # no factors to consider.
2878 # this config will not affect the computation graph.
2879 factors: list[Any] = []
2869 - hash_str = hashlib.md5(str(factors).encode()).hexdigest()
2880 + hash_str = hashlib.md5(str(factors).encode(),
2881 + usedforsecurity=False).hexdigest()
2882 return hash_str
2883
2884 def __post_init__(self):
@@ -2928,7 +2940,8 @@ class KVTransferConfig(BaseModel):
2940 # no factors to consider.
2941 # this config will not affect the computation graph.
2942 factors: list[Any] = []
2931 - hash_str = hashlib.md5(str(factors).encode()).hexdigest()
2943 + hash_str = hashlib.md5(str(factors).encode(),
2944 + usedforsecurity=False).hexdigest()
2945 return hash_str
2946
2947 @classmethod
@@ -3425,7 +3438,8 @@ class VllmConfig:
3438 vllm_factors.append("None")
3439 factors.append(vllm_factors)
3440
3428 - hash_str = hashlib.md5(str(factors).encode()).hexdigest()[:10]
3441 + hash_str = hashlib.md5(str(factors).encode(),
3442 + usedforsecurity=False).hexdigest()[:10]
3443 return hash_str
3444
3445 def pad_for_cudagraph(self, batch_size: int) -> int: