Skip to content
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
5e167cf
return factors; fix comments
Nov 20, 2025
dc5980a
refactored code
WorldExplored Nov 20, 2025
7b7fe2e
fixed vllm.py
WorldExplored Nov 20, 2025
f602d96
refactor compute_hash() to compile_factors()
Nov 20, 2025
ce5fc7e
check if .compile_factors exists on the subobject
Nov 20, 2025
f99a273
Merge branch 'main' into hash
Nov 20, 2025
5eed2d7
fix recusion
Nov 20, 2025
fd33225
envs.py update
Nov 20, 2025
77eed45
fix precommit
Nov 20, 2025
76c2761
precommit
Nov 20, 2025
9cdc0d7
addressed reviewer concerns
WorldExplored Nov 20, 2025
b3bca07
factors can be a list of recursive dicts, and we can call hash_factor…
Nov 21, 2025
3ab19fc
fix
Nov 21, 2025
755e864
fixed precommit
WorldExplored Nov 21, 2025
03ac8c4
Merge branch 'main' into hash
WorldExplored Nov 21, 2025
bdbfcb0
added split shared compilation helpers PR code
WorldExplored Nov 21, 2025
caab640
use hash_factors
Nov 21, 2025
e4dc2b7
fix returning factors
Nov 21, 2025
a23a880
fixed precommit
WorldExplored Nov 22, 2025
fc17f5a
Merge branch 'main' into hash
WorldExplored Nov 25, 2025
0b7477b
Merge branch 'main' into hash
WorldExplored Nov 26, 2025
ce55893
addressed reviewer concerns
WorldExplored Nov 26, 2025
9998552
fixed precommit
WorldExplored Nov 26, 2025
991a335
reviewer feedback
Nov 26, 2025
b026819
HashResult- CompileFactor
Nov 26, 2025
78e9060
accept proper dict
Nov 27, 2025
5e0a992
fixed pre-commit
WorldExplored Nov 27, 2025
fec924d
Merge branch 'main' into hash
WorldExplored Nov 27, 2025
4c6a0d1
Update vllm/config/vllm.py
WorldExplored Nov 28, 2025
8470733
Update vllm/config/vllm.py
WorldExplored Nov 28, 2025
a91542d
Merge branch 'main' into hash
WorldExplored Nov 29, 2025
42390f4
fixed pre-comm + reviewer feedback
WorldExplored Nov 29, 2025
69c780b
have adaptors pass dicts.
Dec 1, 2025
90df680
pre-com
Dec 1, 2025
89370fc
Merge branch 'main' into hash
WorldExplored Dec 2, 2025
0662dee
Merge branch 'main' into hash
WorldExplored Dec 3, 2025
9ef5ebc
Update vllm/config/utils.py
WorldExplored Dec 4, 2025
d643f93
Update vllm/config/vllm.py
WorldExplored Dec 4, 2025
00185c6
Update vllm/compilation/caching.py
WorldExplored Dec 4, 2025
0cb98a1
Merge branch 'main' into hash
WorldExplored Dec 8, 2025
1269570
fixed precommit
WorldExplored Dec 8, 2025
b0341df
Merge branch 'main' into hash
Dec 8, 2025
70ec192
fixed precomit
WorldExplored Dec 8, 2025
e282b67
Merge branch 'main' into hash
WorldExplored Dec 10, 2025
7c76f79
Merge branch 'main' into hash
WorldExplored Dec 10, 2025
883f3a5
Merge branch 'main' into hash
WorldExplored Dec 11, 2025
e97c1d5
Merge branch 'main' into hash
Dec 16, 2025
0ee4834
fix assert & precom
Dec 16, 2025
9587a86
precom
Dec 16, 2025
54c0e10
pre-com
Dec 16, 2025
b7dae52
Merge branch 'main' into hash
WorldExplored Dec 19, 2025
33f0410
Merge branch 'main' into hash
Dec 23, 2025
5673536
cleanup compilation config, merge, etc .,
Dec 23, 2025
ef957b7
fix passconfig
Dec 24, 2025
af811f5
Merge branch 'main' into hash
WorldExplored Dec 27, 2025
fbcaf9e
fixed circular imporrt
WorldExplored Dec 28, 2025
cd168a7
fixing cache breaks.
WorldExplored Dec 28, 2025
c46827e
Merge branch 'main' into hash
Jan 7, 2026
fee0ee8
fixed precom
WorldExplored Jan 8, 2026
7fbc6a6
Merge branch 'main' into hash
WorldExplored Jan 12, 2026
929d2f7
Merge branch 'main' into hash
WorldExplored Jan 12, 2026
a0b60a4
precom fix
WorldExplored Jan 12, 2026
8f3d1af
fixed cursor comments
WorldExplored Jan 13, 2026
dd759a0
Update vllm/config/utils.py
WorldExplored Jan 13, 2026
7558451
Addressed Reviewer Comments
WorldExplored Jan 13, 2026
6c212a3
Addressed concerns
WorldExplored Jan 14, 2026
a5da83c
Merge branch 'main' into hash
WorldExplored Jan 14, 2026
114a170
precom
Jan 14, 2026
2137afa
Merge branch 'main' into hash
Jan 16, 2026
4ebf938
Merge branch 'main' into hash
WorldExplored Jan 19, 2026
a6b1afd
fixed precom
WorldExplored Jan 20, 2026
8e85a2d
Merge branch 'main' into hash
WorldExplored Jan 22, 2026
ef3b3b1
fixed precom
WorldExplored Jan 22, 2026
b807f05
addressed comments
WorldExplored Jan 23, 2026
316f087
Merge branch 'main' into hash
WorldExplored Jan 26, 2026
662fae0
add factor
Jan 26, 2026
a1973c5
updated compilation
WorldExplored Jan 27, 2026
8a8d890
fixed json
WorldExplored Jan 27, 2026
2202b48
Merge branch 'main' into hash
Jan 27, 2026
4a19484
Merge branch 'main' into hash
WorldExplored Jan 27, 2026
97b3826
Merge branch 'main' into hash
WorldExplored Jan 31, 2026
b35d63a
fixed precom
WorldExplored Feb 1, 2026
8842e87
precom
WorldExplored Feb 1, 2026
56a914e
Merge branch 'main' into hash
WorldExplored Feb 2, 2026
ba09ff7
Merge branch 'main' into hash
WorldExplored Feb 3, 2026
e2ab420
Merge branch 'main' into hash
Feb 3, 2026
c9326f3
fixed premmit
WorldExplored Feb 4, 2026
c8cfbea
precom
WorldExplored Feb 4, 2026
a7dfc63
Merge upstream/main into hash
WorldExplored Mar 25, 2026
9881aac
Merge branch 'main' into hash
WorldExplored Mar 28, 2026
1095bd4
Merge branch 'main' into hash
WorldExplored Mar 31, 2026
fca44e3
Merge branch 'main' into hash
WorldExplored Apr 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/compile/fullgraph/test_toy_llama.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class LlamaConfig:
tractable_init: bool = False
random_seed: int = 0

def compute_hash(self) -> str:
def compile_factors(self) -> str:
Comment thread
This conversation was marked as resolved.
Outdated
factors: list[Any] = []
for k, v in self.__dict__.items():
if k == "random_seed":
Expand Down
8 changes: 4 additions & 4 deletions tests/config/test_config_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import pytest

from vllm.config.utils import get_hash_factors, hash_factors, normalize_value
from vllm.config.utils import get_compile_factors, hash_factors, normalize_value

# Helpers

Expand All @@ -25,7 +25,7 @@ def expected_path(p_str: str = ".") -> str:
return p.expanduser().resolve().as_posix()


# Minimal dataclass to test get_hash_factors.
# Minimal dataclass to test get_compile_factors.
# Avoid importing heavy vLLM configs.
@dataclass
class SimpleConfig:
Expand Down Expand Up @@ -136,8 +136,8 @@ def test_enum_vs_int_disambiguation():
assert enum_val == "raw_logits"

# Build factor dicts from configs with int vs enum
f_int = get_hash_factors(SimpleConfig(1), set())
f_enum = get_hash_factors(SimpleConfig(DummyLogprobsMode.RAW_LOGITS), set())
f_int = get_compile_factors(SimpleConfig(1), set())
f_enum = get_compile_factors(SimpleConfig(DummyLogprobsMode.RAW_LOGITS), set())
# The int case remains a primitive value
assert f_int["a"] == 1
# The enum case becomes a tagged tuple ("module.QualName", "raw_logits")
Expand Down
4 changes: 2 additions & 2 deletions tests/config/test_multimodal_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ def test_mm_encoder_attn_backend_invalid():


def test_mm_encoder_attn_backend_hash_updates():
base_hash = MultiModalConfig().compute_hash()
base_hash = MultiModalConfig().compile_factors()
overridden_hash = MultiModalConfig(
mm_encoder_attn_backend=AttentionBackendEnum.FLASH_ATTN
).compute_hash()
).compile_factors()
assert base_hash != overridden_hash
Comment thread
This conversation was marked as resolved.
Outdated
10 changes: 5 additions & 5 deletions vllm/compilation/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ def __init__(self, compilation_config: CompilationConfig):
self.compilation_config = compilation_config
self.compiler = make_compiler(compilation_config)

def compute_hash(self, vllm_config: VllmConfig) -> str:
return self.compiler.compute_hash(vllm_config)
def compile_factors(self, vllm_config: VllmConfig) -> str:
return self.compiler.compile_factors(vllm_config)

@contextmanager
def compile_context(self, runtime_shape: int | None = None):
Expand Down Expand Up @@ -590,8 +590,8 @@ def __call__(
env_factors = envs.compile_factors()
env_hash = hash_factors(env_factors)
# Compute config/compiler/code hashes once and reuse
config_hash = vllm_config.compute_hash()
compiler_hash = self.compiler_manager.compute_hash(vllm_config)
config_hash = vllm_config.compile_factors()
compiler_hash = self.compiler_manager.compile_factors(vllm_config)
Comment thread
This conversation was marked as resolved.
Outdated
forward_code_files = list(sorted(self.compilation_config.traced_files))

logger.debug(
Expand Down Expand Up @@ -621,7 +621,7 @@ def __call__(
# graph.
factors = [env_hash, config_hash, code_hash, compiler_hash]
# Use SHA-256 for cache key hashing to be consistent across
# compute_hash functions. Truncate for a short cache dir name.
# compile_factors functions. Truncate for a short cache dir name.
hash_key = hashlib.sha256(str(factors).encode()).hexdigest()[:10]
Comment thread
This conversation was marked as resolved.
Outdated
cache_dir = os.path.join(
envs.VLLM_CACHE_ROOT, "torch_compile_cache", hash_key
Expand Down
4 changes: 2 additions & 2 deletions vllm/compilation/caching.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,12 @@ def compilation_config_hash_factors(vllm_config: VllmConfig) -> list[str]:
factors = []
# 0. factors come from the env, for example, The values of
# VLLM_PP_LAYER_PARTITION will affect the computation graph.
env_hash = envs.compute_hash()
env_hash = envs.compile_factors()
factors.append(env_hash)

# 1. factors come from the vllm_config (it mainly summarizes how the
# model is created)
config_hash = vllm_config.compute_hash()
config_hash = vllm_config.compile_factors()
factors.append(config_hash)
return factors

Expand Down
8 changes: 4 additions & 4 deletions vllm/compilation/compiler_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ def initialize_cache(
"""
pass

def compute_hash(self, vllm_config: VllmConfig) -> str:
def compile_factors(self, vllm_config: VllmConfig) -> str:
"""
Gather all the relevant information from the vLLM config,
to compute a hash so that we can cache the compiled model.

See [`VllmConfig.compute_hash`][vllm.config.VllmConfig.compute_hash]
See [`VllmConfig.compile_factors`][vllm.config.VllmConfig.compile_factors]
to check what information
is already considered by default. This function should only
consider the information that is specific to the compiler.
Expand Down Expand Up @@ -195,7 +195,7 @@ class InductorStandaloneAdaptor(CompilerInterface):
def __init__(self, save_format: Literal["binary", "unpacked"]):
self.save_format = save_format

def compute_hash(self, vllm_config: VllmConfig) -> str:
def compile_factors(self, vllm_config: VllmConfig) -> str:
factors = get_inductor_factors()
hash_str = hashlib.md5(
str(factors).encode(), usedforsecurity=False
Expand Down Expand Up @@ -284,7 +284,7 @@ class InductorAdaptor(CompilerInterface):

name = "inductor"

def compute_hash(self, vllm_config: VllmConfig) -> str:
def compile_factors(self, vllm_config: VllmConfig) -> str:
factors = get_inductor_factors()
Comment thread
This conversation was marked as resolved.
Outdated
hash_str = hashlib.md5(
str(factors).encode(), usedforsecurity=False
Expand Down
2 changes: 1 addition & 1 deletion vllm/compilation/pass_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def uuid(self):
affects compilation caching. Its uuid depends on the UUIDs of all
dependent passes and the pass config. See InductorPass for more info.
"""
state = {"pass_config": self.pass_config.compute_hash(), "passes": []}
state = {"pass_config": self.pass_config.compile_factors(), "passes": []}
for pass_ in self.passes:
state["passes"].append(pass_.uuid())
state["passes"].append(self.fix_functionalization.uuid())
Comment thread
This conversation was marked as resolved.
Outdated
Expand Down
19 changes: 11 additions & 8 deletions vllm/config/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from pydantic import Field, SkipValidation, field_validator
from pydantic.dataclasses import dataclass

from vllm.config.utils import config
from vllm.config.utils import HashResult, config, get_compile_factors, hash_factors
from vllm.logger import init_logger
from vllm.utils.mem_constants import GiB_bytes
from vllm.utils.mem_utils import get_cpu_memory
Expand Down Expand Up @@ -147,17 +147,20 @@ class CacheConfig:
'native' (vLLM native CPU offloading), 'lmcache' This option must be used
together with kv_offloading_size."""

def compute_hash(self) -> str:
def compile_factors(self, *, return_factors: bool = False) -> HashResult:
"""
WARNING: Whenever a new field is added to this config,
ensure that it is included in the factors list if
it affects the computation graph.
WARNING: Whenever a new field is added to this config, review
`ignored_factors` to decide whether the field should be excluded.
All other dataclass fields participate in the hash automatically.

Provide a hash that uniquely identifies all the configs
that affect the structure of the computation
graph from input ids/embeddings to the final hidden states,
excluding anything before input ids/embeddings and after
the final hidden states.

This config uses an opt-out hash: start from every dataclass field and
then drop the `ignored_factors` below.
"""
ignored_factors = {
# Runtime/derived knobs that don't affect compiled graph shape
Expand All @@ -178,9 +181,9 @@ def compute_hash(self) -> str:
"kv_sharing_fast_prefill",
}

from vllm.config.utils import get_hash_factors, hash_factors

factors = get_hash_factors(self, ignored_factors)
factors = get_compile_factors(self, ignored_factors)
if return_factors:
return factors or None
return hash_factors(factors)
Comment thread
This conversation was marked as resolved.
Outdated

def metrics_info(self):
Expand Down
26 changes: 13 additions & 13 deletions vllm/config/compilation.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import vllm.envs as envs
from vllm.compilation.inductor_pass import CallableInductorPass, InductorPass
from vllm.config.utils import config
from vllm.config.utils import HashResult, config, get_compile_factors, hash_factors
from vllm.logger import init_logger
from vllm.platforms import current_platform
from vllm.utils.import_utils import resolve_obj_by_qualname
Expand Down Expand Up @@ -159,13 +159,16 @@ def default_fi_allreduce_fusion_max_size_mb() -> dict[int, float]:
current_platform.get_device_capability().to_int(), {}
)

def compute_hash(self) -> str:
def compile_factors(self, *, return_factors: bool = False) -> HashResult:
"""
Produces a hash unique to the pass configuration.
Any new fields that affect compilation should be added to the hash.
Any future fields that don't affect compilation should be excluded.
"""
return InductorPass.hash_dict(asdict(self))
factors = asdict(self)
if return_factors:
return factors or None
return InductorPass.hash_dict(factors)

def __post_init__(self) -> None:
if not self.enable_noop:
Expand Down Expand Up @@ -503,18 +506,17 @@ class CompilationConfig:
"vllm::sparse_attn_indexer",
]

def compute_hash(self) -> str:
def compile_factors(self, *, return_factors: bool = False) -> HashResult:
"""
Provide a hash that uniquely identifies all the configs
that affect the structure of the computation
graph from input ids/embeddings to the final hidden states,
excluding anything before input ids/embeddings and after
the final hidden states.
"""
# Opt-out: default-include declared fields; keep a tiny exclude set;
# normalize types; keep SHA-256. For nested opaque configs, include a
# stable identifier (e.g., pass_config.compute_hash()) instead of object id.

This config follows the opt-out hashing pattern: start from every
dataclass field and remove the `ignored_factors` list below.
"""
ignored_factors = {
# Paths/dirs and runtime/metrics that don’t affect compiled graph
"debug_dump_path",
Expand All @@ -524,13 +526,11 @@ def compute_hash(self) -> str:
"traced_files",
"compilation_time",
"static_forward_context",
"pass_config", # handled separately below
}

from vllm.config.utils import get_hash_factors, hash_factors

factors = get_hash_factors(self, ignored_factors)
factors["pass_config"] = self.pass_config.compute_hash()
factors = get_compile_factors(self, ignored_factors)
if return_factors:
return factors or None
return hash_factors(factors)

def __repr__(self) -> str:
Expand Down
10 changes: 5 additions & 5 deletions vllm/config/device.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project

import hashlib
from dataclasses import field
from typing import Any, Literal

import torch
from pydantic import ConfigDict, SkipValidation
from pydantic.dataclasses import dataclass

from vllm.config.utils import config
from vllm.config.utils import HashResult, config, hash_factors, normalize_value

Device = Literal["auto", "cuda", "cpu", "tpu", "xpu"]

Expand All @@ -29,7 +28,7 @@ class DeviceConfig:
"""Device type from the current platform. This is set in
`__post_init__`."""

def compute_hash(self) -> str:
def compile_factors(self, *, return_factors: bool = False) -> HashResult:
"""
WARNING: Whenever a new field is added to this config,
ensure that it is included in the factors list if
Expand All @@ -45,8 +44,9 @@ 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(), usedforsecurity=False).hexdigest()
return hash_str
if return_factors:
return factors or None
return hash_factors({"factors": normalize_value(factors)})

def __post_init__(self):
if self.device == "auto":
Expand Down
10 changes: 5 additions & 5 deletions vllm/config/ec_transfer.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
import hashlib
import uuid
from dataclasses import field
from typing import Any, Literal, get_args

from pydantic.dataclasses import dataclass

from vllm.config.utils import config
from vllm.config.utils import HashResult, config, hash_factors, normalize_value

ECProducer = Literal["ec_producer"]
ECConsumer = Literal["ec_consumer"]
Expand Down Expand Up @@ -60,7 +59,7 @@ class ECTransferConfig:
"""The Python module path to dynamically load the EC connector from.
Only supported in V1."""

def compute_hash(self) -> str:
def compile_factors(self, *, return_factors: bool = False) -> HashResult:
"""
WARNING: Whenever a new field is added to this config,
ensure that it is included in the factors list if
Expand All @@ -75,8 +74,9 @@ 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(), usedforsecurity=False).hexdigest()
return hash_str
if return_factors:
return factors or None
return hash_factors({"factors": normalize_value(factors)})

def __post_init__(self) -> None:
if self.engine_id is None:
Expand Down
10 changes: 5 additions & 5 deletions vllm/config/kv_transfer.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project

import hashlib
import uuid
from dataclasses import field
from typing import Any, Literal, get_args

from pydantic.dataclasses import dataclass

from vllm.config.utils import config
from vllm.config.utils import HashResult, config, hash_factors, normalize_value

KVProducer = Literal["kv_producer", "kv_both"]
KVConsumer = Literal["kv_consumer", "kv_both"]
Expand Down Expand Up @@ -64,7 +63,7 @@ class KVTransferConfig:
enable_permute_local_kv: bool = False
"""Experiment feature flag to enable HND to NHD KV Transfer"""

def compute_hash(self) -> str:
def compile_factors(self, *, return_factors: bool = False) -> HashResult:
"""
WARNING: Whenever a new field is added to this config,
ensure that it is included in the factors list if
Expand All @@ -79,8 +78,9 @@ 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(), usedforsecurity=False).hexdigest()
return hash_str
if return_factors:
return factors or None
return hash_factors({"factors": normalize_value(factors)})

def __post_init__(self) -> None:
if self.engine_id is None:
Expand Down
10 changes: 5 additions & 5 deletions vllm/config/load.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project

import hashlib
from typing import TYPE_CHECKING, Any

from pydantic import Field, field_validator
from pydantic.dataclasses import dataclass

from vllm.config.utils import config
from vllm.config.utils import HashResult, config, hash_factors, normalize_value
from vllm.logger import init_logger

if TYPE_CHECKING:
Expand Down Expand Up @@ -89,7 +88,7 @@ class LoadConfig:
see original doc for `map_location` in https://pytorch.org/docs/stable/generated/torch.load.html
"""

def compute_hash(self) -> str:
def compile_factors(self, *, return_factors: bool = False) -> HashResult:
"""
WARNING: Whenever a new field is added to this config,
ensure that it is included in the factors list if
Expand All @@ -104,8 +103,9 @@ 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(), usedforsecurity=False).hexdigest()
return hash_str
if return_factors:
return factors or None
return hash_factors({"factors": normalize_value(factors)})

@field_validator("load_format", mode="after")
def _lowercase_load_format(cls, load_format: str) -> str:
Expand Down
Loading