diff --git a/tests/compile/piecewise/test_toy_llama.py b/tests/compile/piecewise/test_toy_llama.py index 7307f44b6184..d4551b1cc3ae 100644 --- a/tests/compile/piecewise/test_toy_llama.py +++ b/tests/compile/piecewise/test_toy_llama.py @@ -63,7 +63,8 @@ def compute_hash(self) -> str: factors.append((k, v)) factors.sort() import hashlib - return hashlib.md5(str(factors).encode()).hexdigest() + return hashlib.md5(str(factors).encode(), + usedforsecurity=False).hexdigest() def __post_init__(self): assert self.mlp_size >= self.hidden_size diff --git a/vllm/compilation/backends.py b/vllm/compilation/backends.py index cdae42fe4fce..658989c36112 100644 --- a/vllm/compilation/backends.py +++ b/vllm/compilation/backends.py @@ -376,8 +376,8 @@ def __call__(self, graph: fx.GraphModule, example_inputs) -> Callable: with open(filepath) as f: hash_content.append(f.read()) import hashlib - code_hash = hashlib.md5( - "\n".join(hash_content).encode()).hexdigest() + code_hash = hashlib.md5("\n".join(hash_content).encode(), + usedforsecurity=False).hexdigest() factors.append(code_hash) # 3. compiler hash @@ -385,7 +385,8 @@ def __call__(self, graph: fx.GraphModule, example_inputs) -> Callable: factors.append(compiler_hash) # combine all factors to generate the cache dir - hash_key = hashlib.md5(str(factors).encode()).hexdigest()[:10] + hash_key = hashlib.md5(str(factors).encode(), + usedforsecurity=False).hexdigest()[:10] cache_dir = os.path.join( envs.VLLM_CACHE_ROOT, diff --git a/vllm/compilation/compiler_interface.py b/vllm/compilation/compiler_interface.py index b45c694fd7f8..571e2b832e95 100644 --- a/vllm/compilation/compiler_interface.py +++ b/vllm/compilation/compiler_interface.py @@ -139,7 +139,8 @@ def compute_hash(self, vllm_config: VllmConfig) -> str: from torch._inductor.codecache import torch_key torch_factors = torch_key() factors.append(torch_factors) - hash_str = hashlib.md5(str(factors).encode()).hexdigest()[:10] + hash_str = hashlib.md5(str(factors).encode(), + usedforsecurity=False).hexdigest()[:10] return hash_str def initialize_cache(self, cache_dir: str, disable_cache: bool = False): diff --git a/vllm/config.py b/vllm/config.py index 1f7147f7cfd4..4aa7d9c3b58b 100644 --- a/vllm/config.py +++ b/vllm/config.py @@ -1093,7 +1093,8 @@ def compute_hash(self) -> str: factors: list[Any] = [] factors.append(self.cache_dtype) # `cpu_offload_gb` does not use `torch.compile` yet. - hash_str = hashlib.md5(str(factors).encode()).hexdigest() + hash_str = hashlib.md5(str(factors).encode(), + usedforsecurity=False).hexdigest() return hash_str def __init__( @@ -1220,7 +1221,8 @@ def compute_hash(self) -> str: # no factors to consider. # this config will not affect the computation graph. factors: list[Any] = [] - hash_str = hashlib.md5(str(factors).encode()).hexdigest() + hash_str = hashlib.md5(str(factors).encode(), + usedforsecurity=False).hexdigest() return hash_str def __post_init__(self): @@ -1324,7 +1326,8 @@ def compute_hash(self) -> str: # no factors to consider. # this config will not affect the computation graph. factors: list[Any] = [] - hash_str = hashlib.md5(str(factors).encode()).hexdigest() + hash_str = hashlib.md5(str(factors).encode(), + usedforsecurity=False).hexdigest() return hash_str def __post_init__(self): @@ -1644,7 +1647,8 @@ def compute_hash(self) -> str: # no factors to consider. # this config will not affect the computation graph. factors: list[Any] = [] - hash_str = hashlib.md5(str(factors).encode()).hexdigest() + hash_str = hashlib.md5(str(factors).encode(), + usedforsecurity=False).hexdigest() return hash_str def __post_init__(self) -> None: @@ -1780,7 +1784,8 @@ def compute_hash(self) -> str: # the device/platform information will be summarized # by torch/vllm automatically. factors: list[Any] = [] - hash_str = hashlib.md5(str(factors).encode()).hexdigest() + hash_str = hashlib.md5(str(factors).encode(), + usedforsecurity=False).hexdigest() return hash_str def __init__(self, device: str = "auto") -> None: @@ -1826,7 +1831,8 @@ def compute_hash(self) -> str: # no factors to consider. # spec decode does not use `torch.compile` yet. factors: list[Any] = [] - hash_str = hashlib.md5(str(factors).encode()).hexdigest() + hash_str = hashlib.md5(str(factors).encode(), + usedforsecurity=False).hexdigest() return hash_str @staticmethod @@ -2311,7 +2317,8 @@ def compute_hash(self) -> str: factors.append(self.lora_extra_vocab_size) factors.append(self.long_lora_scaling_factors) factors.append(self.bias_enabled) - hash_str = hashlib.md5(str(factors).encode()).hexdigest() + hash_str = hashlib.md5(str(factors).encode(), + usedforsecurity=False).hexdigest() return hash_str def __post_init__(self): @@ -2383,7 +2390,8 @@ def compute_hash(self) -> str: # no factors to consider. # this config will not affect the computation graph. factors: list[Any] = [] - hash_str = hashlib.md5(str(factors).encode()).hexdigest() + hash_str = hashlib.md5(str(factors).encode(), + usedforsecurity=False).hexdigest() return hash_str def __post_init__(self): @@ -2428,7 +2436,8 @@ def compute_hash(self) -> str: # no factors to consider. # this config will not affect the computation graph. factors: list[Any] = [] - hash_str = hashlib.md5(str(factors).encode()).hexdigest() + hash_str = hashlib.md5(str(factors).encode(), + usedforsecurity=False).hexdigest() return hash_str def get_limit_per_prompt(self, modality: str) -> int: @@ -2494,7 +2503,8 @@ def compute_hash(self) -> str: # no factors to consider. # this config will not affect the computation graph. factors: list[Any] = [] - hash_str = hashlib.md5(str(factors).encode()).hexdigest() + hash_str = hashlib.md5(str(factors).encode(), + usedforsecurity=False).hexdigest() return hash_str @staticmethod @@ -2775,7 +2785,8 @@ def compute_hash(self) -> str: # no factors to consider. # this config will not affect the computation graph. factors: list[Any] = [] - hash_str = hashlib.md5(str(factors).encode()).hexdigest() + hash_str = hashlib.md5(str(factors).encode(), + usedforsecurity=False).hexdigest() return hash_str def __post_init__(self): @@ -2820,7 +2831,8 @@ def compute_hash(self) -> str: # no factors to consider. # this config will not affect the computation graph. factors: list[Any] = [] - hash_str = hashlib.md5(str(factors).encode()).hexdigest() + hash_str = hashlib.md5(str(factors).encode(), + usedforsecurity=False).hexdigest() return hash_str def __post_init__(self): @@ -2882,7 +2894,8 @@ def compute_hash(self) -> str: # no factors to consider. # this config will not affect the computation graph. factors: list[Any] = [] - hash_str = hashlib.md5(str(factors).encode()).hexdigest() + hash_str = hashlib.md5(str(factors).encode(), + usedforsecurity=False).hexdigest() return hash_str @classmethod @@ -3379,7 +3392,8 @@ def compute_hash(self) -> str: vllm_factors.append("None") factors.append(vllm_factors) - hash_str = hashlib.md5(str(factors).encode()).hexdigest()[:10] + hash_str = hashlib.md5(str(factors).encode(), + usedforsecurity=False).hexdigest()[:10] return hash_str def pad_for_cudagraph(self, batch_size: int) -> int: