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 10, 01:30 UTC
[Feature] Add FIPS 140-3 compliant hash algorithm option for multimodal hashing (#32386)
Signed-off-by: Karan Bansal <karanb192@gmail.com>
Karan Bansal committed
Jan 18, 2026 at 08:32 UTC
3055232ba0b95a68b3609cd95c029f94809e8bf1
2 files changed
+46
-3
vllm/envs.py
+12
@@ -73,6 +73,7 @@ if TYPE_CHECKING:
73
VLLM_MAX_AUDIO_CLIP_FILESIZE_MB: int = 25
74
VLLM_VIDEO_LOADER_BACKEND: str = "opencv"
75
VLLM_MEDIA_CONNECTOR: str = "http"
76
+ VLLM_MM_HASHER_ALGORITHM: str = "blake3"
77
VLLM_TARGET_DEVICE: str = "cuda"
78
VLLM_MAIN_CUDA_VERSION: str = "12.9"
79
VLLM_FLOAT32_MATMUL_PRECISION: Literal["highest", "high", "medium"] = "highest"
@@ -806,6 +807,17 @@ environment_variables: dict[str, Callable[[], Any]] = {
807
# imported at runtime.
808
# If a non-existing backend is used, an AssertionError will be thrown.
809
"VLLM_MEDIA_CONNECTOR": lambda: os.getenv("VLLM_MEDIA_CONNECTOR", "http"),
810
+ # Hash algorithm for multimodal content hashing.
811
+ # - "blake3": Default, fast cryptographic hash (not FIPS 140-3 compliant)
812
+ # - "sha256": FIPS 140-3 compliant, widely supported
813
+ # - "sha512": FIPS 140-3 compliant, faster on 64-bit systems
814
+ # Use sha256 or sha512 for FIPS compliance in government/enterprise deployments
815
+ "VLLM_MM_HASHER_ALGORITHM": env_with_choices(
816
+ "VLLM_MM_HASHER_ALGORITHM",
817
+ "blake3",
818
+ ["blake3", "sha256", "sha512"],
819
+ case_sensitive=False,
820
+ ),
821
# Path to the XLA persistent cache directory.
822
# Only used for XLA devices such as TPUs.
823
"VLLM_XLA_CACHE_PATH": lambda: os.path.expanduser(
vllm/multimodal/hasher.py
+34
-3
@@ -1,15 +1,17 @@
1
# SPDX-License-Identifier: Apache-2.0
2
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
4
+import functools
5
+import hashlib
6
import pickle
7
import uuid
6
-from collections.abc import Iterable
8
+from collections.abc import Callable, Iterable
9
10
import numpy as np
11
import torch
10
-from blake3 import blake3
12
from PIL import Image
13
14
+import vllm.envs as envs
15
from vllm.logger import init_logger
16
17
from .media import MediaWithBytes
@@ -17,6 +19,34 @@ from .media import MediaWithBytes
19
logger = init_logger(__name__)
20
21
22
+@functools.lru_cache(maxsize=3)
23
+def _get_hasher_factory(algorithm: str) -> Callable[[], "hashlib._Hash"]:
24
+ """
25
+ Get the hasher factory based on the configured algorithm.
26
+
27
+ Args:
28
+ algorithm: Hash algorithm name (blake3, sha256, or sha512)
29
+
30
+ Returns a callable that creates a new hasher instance.
31
+ Supports blake3 (default), sha256, and sha512 for FIPS compliance.
32
+
33
+ See: https://github.com/vllm-project/vllm/issues/18334
34
+ """
35
+ algorithm = algorithm.lower()
36
+
37
+ if algorithm == "blake3":
38
+ from blake3 import blake3
39
+
40
+ return blake3
41
+ elif algorithm == "sha256":
42
+ return hashlib.sha256
43
+ elif algorithm == "sha512":
44
+ return hashlib.sha512
45
+ else:
46
+ # This should never happen due to env_with_choices validation
47
+ raise ValueError(f"Unsupported hash algorithm: {algorithm}")
48
+
49
+
50
class MultiModalHasher:
51
@classmethod
52
def serialize_item(cls, obj: object) -> Iterable[bytes | memoryview]:
@@ -114,7 +144,8 @@ class MultiModalHasher:
144
145
@classmethod
146
def hash_kwargs(cls, **kwargs: object) -> str:
117
- hasher = blake3()
147
+ hasher_factory = _get_hasher_factory(envs.VLLM_MM_HASHER_ALGORITHM)
148
+ hasher = hasher_factory()
149
150
for k, v in kwargs.items():
151
for bytes_ in cls.iter_item_to_bytes(k, v):