Skip to content

Commit 7a6d45b

Browse files
authored
Support FIPS enabled machines with MD5 hashing (#15299)
Signed-off-by: Matthew Vine <[email protected]>
1 parent e74ff40 commit 7a6d45b

File tree

4 files changed

+36
-19
lines changed

4 files changed

+36
-19
lines changed

tests/compile/piecewise/test_toy_llama.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ def compute_hash(self) -> str:
6363
factors.append((k, v))
6464
factors.sort()
6565
import hashlib
66-
return hashlib.md5(str(factors).encode()).hexdigest()
66+
return hashlib.md5(str(factors).encode(),
67+
usedforsecurity=False).hexdigest()
6768

6869
def __post_init__(self):
6970
assert self.mlp_size >= self.hidden_size

vllm/compilation/backends.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -381,16 +381,17 @@ def __call__(self, graph: fx.GraphModule, example_inputs) -> Callable:
381381
with open(filepath) as f:
382382
hash_content.append(f.read())
383383
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()
386386
factors.append(code_hash)
387387

388388
# 3. compiler hash
389389
compiler_hash = self.compiler_manager.compute_hash(vllm_config)
390390
factors.append(compiler_hash)
391391

392392
# 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]
394395

395396
cache_dir = os.path.join(
396397
envs.VLLM_CACHE_ROOT,

vllm/compilation/compiler_interface.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ def compute_hash(self, vllm_config: VllmConfig) -> str:
139139
from torch._inductor.codecache import torch_key
140140
torch_factors = torch_key()
141141
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]
143144
return hash_str
144145

145146
def initialize_cache(self, cache_dir: str, disable_cache: bool = False):

vllm/config.py

+28-14
Original file line numberDiff line numberDiff line change
@@ -1111,7 +1111,8 @@ def compute_hash(self) -> str:
11111111
factors: list[Any] = []
11121112
factors.append(self.cache_dtype)
11131113
# `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()
11151116
return hash_str
11161117

11171118
def __init__(
@@ -1243,7 +1244,8 @@ def compute_hash(self) -> str:
12431244
# no factors to consider.
12441245
# this config will not affect the computation graph.
12451246
factors: list[Any] = []
1246-
hash_str = hashlib.md5(str(factors).encode()).hexdigest()
1247+
hash_str = hashlib.md5(str(factors).encode(),
1248+
usedforsecurity=False).hexdigest()
12471249
return hash_str
12481250

12491251
def __post_init__(self):
@@ -1354,7 +1356,8 @@ def compute_hash(self) -> str:
13541356
# no factors to consider.
13551357
# this config will not affect the computation graph.
13561358
factors: list[Any] = []
1357-
hash_str = hashlib.md5(str(factors).encode()).hexdigest()
1359+
hash_str = hashlib.md5(str(factors).encode(),
1360+
usedforsecurity=False).hexdigest()
13581361
return hash_str
13591362

13601363
def __post_init__(self):
@@ -1674,7 +1677,8 @@ def compute_hash(self) -> str:
16741677
# no factors to consider.
16751678
# this config will not affect the computation graph.
16761679
factors: list[Any] = []
1677-
hash_str = hashlib.md5(str(factors).encode()).hexdigest()
1680+
hash_str = hashlib.md5(str(factors).encode(),
1681+
usedforsecurity=False).hexdigest()
16781682
return hash_str
16791683

16801684
def __post_init__(self) -> None:
@@ -1810,7 +1814,8 @@ def compute_hash(self) -> str:
18101814
# the device/platform information will be summarized
18111815
# by torch/vllm automatically.
18121816
factors: list[Any] = []
1813-
hash_str = hashlib.md5(str(factors).encode()).hexdigest()
1817+
hash_str = hashlib.md5(str(factors).encode(),
1818+
usedforsecurity=False).hexdigest()
18141819
return hash_str
18151820

18161821
def __init__(self, device: str = "auto") -> None:
@@ -1983,7 +1988,8 @@ def compute_hash(self) -> str:
19831988
# no factors to consider.
19841989
# spec decode does not use `torch.compile` yet.
19851990
factors: list[Any] = []
1986-
hash_str = hashlib.md5(str(factors).encode()).hexdigest()
1991+
hash_str = hashlib.md5(str(factors).encode(),
1992+
usedforsecurity=False).hexdigest()
19871993
return hash_str
19881994

19891995
@classmethod
@@ -2358,7 +2364,8 @@ def compute_hash(self) -> str:
23582364
factors.append(self.lora_extra_vocab_size)
23592365
factors.append(self.long_lora_scaling_factors)
23602366
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()
23622369
return hash_str
23632370

23642371
def __post_init__(self):
@@ -2424,7 +2431,8 @@ def compute_hash(self) -> str:
24242431
# no factors to consider.
24252432
# this config will not affect the computation graph.
24262433
factors: list[Any] = []
2427-
hash_str = hashlib.md5(str(factors).encode()).hexdigest()
2434+
hash_str = hashlib.md5(str(factors).encode(),
2435+
usedforsecurity=False).hexdigest()
24282436
return hash_str
24292437

24302438
def __post_init__(self):
@@ -2469,7 +2477,8 @@ def compute_hash(self) -> str:
24692477
# no factors to consider.
24702478
# this config will not affect the computation graph.
24712479
factors: list[Any] = []
2472-
hash_str = hashlib.md5(str(factors).encode()).hexdigest()
2480+
hash_str = hashlib.md5(str(factors).encode(),
2481+
usedforsecurity=False).hexdigest()
24732482
return hash_str
24742483

24752484
def get_limit_per_prompt(self, modality: str) -> int:
@@ -2535,7 +2544,8 @@ def compute_hash(self) -> str:
25352544
# no factors to consider.
25362545
# this config will not affect the computation graph.
25372546
factors: list[Any] = []
2538-
hash_str = hashlib.md5(str(factors).encode()).hexdigest()
2547+
hash_str = hashlib.md5(str(factors).encode(),
2548+
usedforsecurity=False).hexdigest()
25392549
return hash_str
25402550

25412551
@staticmethod
@@ -2816,7 +2826,8 @@ def compute_hash(self) -> str:
28162826
# no factors to consider.
28172827
# this config will not affect the computation graph.
28182828
factors: list[Any] = []
2819-
hash_str = hashlib.md5(str(factors).encode()).hexdigest()
2829+
hash_str = hashlib.md5(str(factors).encode(),
2830+
usedforsecurity=False).hexdigest()
28202831
return hash_str
28212832

28222833
def __post_init__(self):
@@ -2866,7 +2877,8 @@ def compute_hash(self) -> str:
28662877
# no factors to consider.
28672878
# this config will not affect the computation graph.
28682879
factors: list[Any] = []
2869-
hash_str = hashlib.md5(str(factors).encode()).hexdigest()
2880+
hash_str = hashlib.md5(str(factors).encode(),
2881+
usedforsecurity=False).hexdigest()
28702882
return hash_str
28712883

28722884
def __post_init__(self):
@@ -2928,7 +2940,8 @@ def compute_hash(self) -> str:
29282940
# no factors to consider.
29292941
# this config will not affect the computation graph.
29302942
factors: list[Any] = []
2931-
hash_str = hashlib.md5(str(factors).encode()).hexdigest()
2943+
hash_str = hashlib.md5(str(factors).encode(),
2944+
usedforsecurity=False).hexdigest()
29322945
return hash_str
29332946

29342947
@classmethod
@@ -3425,7 +3438,8 @@ def compute_hash(self) -> str:
34253438
vllm_factors.append("None")
34263439
factors.append(vllm_factors)
34273440

3428-
hash_str = hashlib.md5(str(factors).encode()).hexdigest()[:10]
3441+
hash_str = hashlib.md5(str(factors).encode(),
3442+
usedforsecurity=False).hexdigest()[:10]
34293443
return hash_str
34303444

34313445
def pad_for_cudagraph(self, batch_size: int) -> int:

0 commit comments

Comments
 (0)