[Model][Engram] Share host tables across co-located DP replicas by default (#57651)

Signed-off-by: Juntian Liu <Juntianl777@gmail.com>
Signed-off-by: zjy0516 <riverclouds.zhu@qq.com>
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Co-authored-by: zjy0516 <riverclouds.zhu@qq.com>
This commit is contained in:
Juntian Liu
2026-09-21 08:26:56 +00:00
committed by GitHub
co-authored by Claude Fable 5.1 zjy0516
parent 0ff0477ff9
commit 76ffb0d374
7 changed files with 68 additions and 22 deletions
+13 -15
View File
@@ -10,7 +10,6 @@ import vllm.envs as envs
from vllm.config.utils import config, get_hash_factors, hash_factors
if TYPE_CHECKING:
from vllm.config.load import LoadConfig
from vllm.config.model import ModelConfig
from vllm.config.parallel import ParallelConfig
@@ -50,11 +49,13 @@ class EngramConfig:
"""Shard embeddings across TP and all DP ranks when enabled.
Otherwise, each DP rank has a separate TP-sharded embedding replica."""
dp_shared_memory: bool = False
dp_shared_memory: bool | None = None
"""Share CPU-offloaded embedding weights between co-located
DP replicas. Each node stores one copy of every TP shard, reducing host
memory without per-step Engram DP collectives. Requires sufficient
/dev/shm capacity and a shared IPC namespace."""
/dev/shm capacity and a shared IPC namespace. Defaults to enabled whenever
the other settings allow it, falling back to per-replica tables when DP
replicas are not co-located on one node or /dev/shm cannot hold them."""
@model_validator(mode="after")
def _validate_shared_memory(self) -> Self:
@@ -82,6 +83,15 @@ class EngramConfig:
"embeddings, non-empty n-gram layer ids, and CUDA."
)
def resolve_dp_shared_memory(self, parallel_config: "ParallelConfig") -> None:
"""Share host tables by default wherever the configuration permits."""
if self.dp_shared_memory is None:
self.dp_shared_memory = (
self.cpu_offload
and parallel_config.data_parallel_size > 1
and not parallel_config.enable_elastic_ep
)
def verify_parallel_config(self, parallel_config: "ParallelConfig") -> None:
"""Reject unsupported embedding parallel topologies."""
if self.dp_shared_memory:
@@ -98,18 +108,6 @@ class EngramConfig:
"Engram embedding_across_dp is not supported with elastic EP yet."
)
def verify_load_config(self, load_config: "LoadConfig") -> None:
"""Shared tables require a loader that invokes parameter weight callbacks."""
if self.dp_shared_memory and load_config.load_format not in (
"auto",
"safetensors",
"pt",
):
raise ValueError(
"dp_shared_memory requires load_format 'auto', "
f"'safetensors' or 'pt'; got {load_config.load_format!r}."
)
def get_parallel_size(self, parallel_config: "ParallelConfig") -> int:
"""Derive the embedding group size from the parallel configuration."""
size = parallel_config.tensor_parallel_size
+1 -1
View File
@@ -1266,8 +1266,8 @@ class VllmConfig:
return
self.engram_config = EngramConfig()
self.engram_config.verify_model_config(model_config)
self.engram_config.resolve_dp_shared_memory(self.parallel_config)
self.engram_config.verify_parallel_config(self.parallel_config)
self.engram_config.verify_load_config(self.load_config)
logger.info_once("Resolved Engram configuration: %s", str(self.engram_config))
def __post_init__(self):