[Misc] Move dynamic seed initialization to EngineArgs (#29165)
Signed-off-by: DarkLight1337 <tlleungac@connect.ust.hk>
This commit is contained in:
+7
-27
@@ -146,9 +146,12 @@ class ModelConfig:
|
||||
- "bfloat16" for a balance between precision and range.\n
|
||||
- "float" is shorthand for FP32 precision.\n
|
||||
- "float32" for FP32 precision."""
|
||||
seed: int | None = None
|
||||
"""Random seed for reproducibility. Initialized to None in V0, but
|
||||
initialized to 0 in V1."""
|
||||
seed: int = 0
|
||||
"""Random seed for reproducibility.
|
||||
|
||||
We must set the global seed because otherwise,
|
||||
different tensor parallel workers would sample different tokens,
|
||||
leading to inconsistent results."""
|
||||
hf_config: PretrainedConfig = field(init=False)
|
||||
"""The Hugging Face config of the model."""
|
||||
hf_text_config: PretrainedConfig = field(init=False)
|
||||
@@ -415,7 +418,7 @@ class ModelConfig:
|
||||
def __post_init__(
|
||||
self,
|
||||
# Multimodal config init vars
|
||||
limit_mm_per_prompt: dict[str, int] | None,
|
||||
limit_mm_per_prompt: dict[str, int | dict[str, int]] | None,
|
||||
enable_mm_embeds: bool | None,
|
||||
media_io_kwargs: dict[str, dict[str, Any]] | None,
|
||||
mm_processor_kwargs: dict[str, Any] | None,
|
||||
@@ -428,23 +431,6 @@ class ModelConfig:
|
||||
skip_mm_profiling: bool | None,
|
||||
video_pruning_rate: float | None,
|
||||
) -> None:
|
||||
# Set the default seed to 0 in V1.
|
||||
# NOTE(woosuk): In V1, we use separate processes for workers (unless
|
||||
# VLLM_ENABLE_V1_MULTIPROCESSING=0), so setting a seed here
|
||||
# doesn't affect the user process. However, without a consistent seed,
|
||||
# different tensor parallel workers would sample different tokens,
|
||||
# leading to inconsistent results.
|
||||
if self.seed is None:
|
||||
self.seed = 0
|
||||
if not envs.VLLM_ENABLE_V1_MULTIPROCESSING:
|
||||
logger.warning(
|
||||
"The global random seed is set to %d. Since "
|
||||
"VLLM_ENABLE_V1_MULTIPROCESSING is set to False, this may "
|
||||
"affect the random state of the Python process that "
|
||||
"launched vLLM.",
|
||||
self.seed,
|
||||
)
|
||||
|
||||
# Keep set served_model_name before maybe_model_redirect(self.model)
|
||||
self.served_model_name = get_served_model_name(
|
||||
self.model, self.served_model_name
|
||||
@@ -1151,12 +1137,6 @@ class ModelConfig:
|
||||
self,
|
||||
parallel_config: ParallelConfig,
|
||||
) -> None:
|
||||
if parallel_config.distributed_executor_backend == "external_launcher":
|
||||
assert self.seed is not None, (
|
||||
"Seed must be set when using external launcher backend to "
|
||||
"make sure sampling results are the same across workers."
|
||||
)
|
||||
|
||||
total_num_attention_heads = getattr(
|
||||
self.hf_text_config, "num_attention_heads", 0
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user