[bug] fix WeightTransferConfig.backend to allow for all strings (#43121)
Signed-off-by: ahao-anyscale <ahao@anyscale.com>
This commit is contained in:
@@ -173,20 +173,7 @@ class TestEngineRegistry:
|
|||||||
|
|
||||||
def test_create_engine_invalid_backend(self):
|
def test_create_engine_invalid_backend(self):
|
||||||
"""Test factory raises for invalid backend."""
|
"""Test factory raises for invalid backend."""
|
||||||
# Pydantic validates Literal types at construction, so we can't create
|
config = WeightTransferConfig(backend="invalid")
|
||||||
# a config with an invalid backend. Instead, we test by directly
|
|
||||||
# accessing the registry or using model_construct to bypass validation.
|
|
||||||
from pydantic import ValidationError
|
|
||||||
|
|
||||||
# Test that Pydantic prevents invalid backend at construction
|
|
||||||
with pytest.raises(ValidationError):
|
|
||||||
WeightTransferConfig(backend="invalid")
|
|
||||||
|
|
||||||
# Test factory error by creating a config with valid backend but
|
|
||||||
# then manually modifying the backend attribute (bypassing validation)
|
|
||||||
config = WeightTransferConfig(backend="nccl")
|
|
||||||
# Use object.__setattr__ to bypass Pydantic validation
|
|
||||||
object.__setattr__(config, "backend", "invalid")
|
|
||||||
parallel_config = create_mock_parallel_config()
|
parallel_config = create_mock_parallel_config()
|
||||||
with pytest.raises(ValueError, match="Invalid weight transfer backend"):
|
with pytest.raises(ValueError, match="Invalid weight transfer backend"):
|
||||||
WeightTransferEngineFactory.create_engine(config, parallel_config)
|
WeightTransferEngineFactory.create_engine(config, parallel_config)
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||||
from typing import Literal
|
|
||||||
|
|
||||||
from vllm.config.utils import config
|
from vllm.config.utils import config
|
||||||
|
|
||||||
|
|
||||||
@@ -9,5 +7,7 @@ from vllm.config.utils import config
|
|||||||
class WeightTransferConfig:
|
class WeightTransferConfig:
|
||||||
"""Configuration for weight transfer during RL training."""
|
"""Configuration for weight transfer during RL training."""
|
||||||
|
|
||||||
backend: Literal["nccl", "ipc"] = "nccl"
|
backend: str = "nccl"
|
||||||
"""The backend to use for weight transfer."""
|
"""The backend to use for weight transfer. Validated against the
|
||||||
|
`WeightTransferEngineFactory` registry at engine creation time.
|
||||||
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user