[Chore] Use Transformers v5 names and drop redundant processor use_fast (#58550)
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
484c211fe8
commit
d881812500
+12
-12
@@ -55,7 +55,7 @@ from vllm.utils.import_utils import LazyLoader
|
||||
from vllm.v1.attention.backends.registry import AttentionBackendEnum
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from transformers import PretrainedConfig
|
||||
from transformers import PreTrainedConfig
|
||||
|
||||
import vllm.model_executor.layers.quantization as me_quant
|
||||
import vllm.model_executor.models as me_models
|
||||
@@ -64,7 +64,7 @@ if TYPE_CHECKING:
|
||||
from vllm.model_executor.layers.quantization import QuantizationMethods
|
||||
from vllm.v1.sample.logits_processor import LogitsProcessor
|
||||
else:
|
||||
PretrainedConfig = Any
|
||||
PreTrainedConfig = Any
|
||||
|
||||
me_quant = LazyLoader(
|
||||
"model_executor", globals(), "vllm.model_executor.layers.quantization"
|
||||
@@ -105,7 +105,7 @@ PROCESSED_LOGPROBS_MODES: tuple[LogprobsMode, ...] = (
|
||||
"processed_logits",
|
||||
"processed_logprobs",
|
||||
)
|
||||
HfOverrides = dict[str, Any] | Callable[[PretrainedConfig], PretrainedConfig]
|
||||
HfOverrides = dict[str, Any] | Callable[[PreTrainedConfig], PreTrainedConfig]
|
||||
ModelImpl = Literal["auto", "vllm", "transformers", "terratorch"]
|
||||
LayerBlockType = Literal["attention", "linear_attention", "mamba"]
|
||||
|
||||
@@ -183,9 +183,9 @@ class ModelConfig:
|
||||
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)
|
||||
hf_config: PreTrainedConfig = field(init=False)
|
||||
"""The Hugging Face config of the model."""
|
||||
hf_text_config: PretrainedConfig = field(init=False)
|
||||
hf_text_config: PreTrainedConfig = field(init=False)
|
||||
"""The Hugging Face config of the text model (same as hf_config for text models)."""
|
||||
is_submodel_config: bool = field(default=False, init=False)
|
||||
"""Whether this is a submodule view derived by `VllmConfig.with_hf_config`
|
||||
@@ -483,7 +483,7 @@ class ModelConfig:
|
||||
|
||||
def _update_nested(
|
||||
self,
|
||||
target: PretrainedConfig | dict[str, Any],
|
||||
target: PreTrainedConfig | dict[str, Any],
|
||||
updates: dict[str, Any],
|
||||
) -> None:
|
||||
"""Recursively updates a config or dict with nested updates."""
|
||||
@@ -511,15 +511,15 @@ class ModelConfig:
|
||||
|
||||
def _apply_dict_overrides(
|
||||
self,
|
||||
config: PretrainedConfig,
|
||||
config: PreTrainedConfig,
|
||||
overrides: dict[str, Any],
|
||||
) -> None:
|
||||
"""Apply dict overrides, handling both nested configs and dict values."""
|
||||
from transformers import PretrainedConfig
|
||||
from transformers import PreTrainedConfig
|
||||
|
||||
for key, value in overrides.items():
|
||||
attr = getattr(config, key, None)
|
||||
if attr is not None and isinstance(attr, PretrainedConfig):
|
||||
if attr is not None and isinstance(attr, PreTrainedConfig):
|
||||
# It's a nested config - recursively update it
|
||||
self._update_nested(attr, value)
|
||||
else:
|
||||
@@ -2393,7 +2393,7 @@ def _resolve_auto_dtype(
|
||||
|
||||
def _get_and_verify_dtype(
|
||||
model_id: str,
|
||||
config: PretrainedConfig,
|
||||
config: PreTrainedConfig,
|
||||
dtype: str | torch.dtype,
|
||||
*,
|
||||
is_pooling_model: bool,
|
||||
@@ -2440,7 +2440,7 @@ def _get_and_verify_dtype(
|
||||
|
||||
|
||||
def _get_head_dtype(
|
||||
config: PretrainedConfig, dtype: torch.dtype, runner_type: str
|
||||
config: PreTrainedConfig, dtype: torch.dtype, runner_type: str
|
||||
) -> torch.dtype:
|
||||
head_dtype: str | torch.dtype | None = getattr(config, "head_dtype", None)
|
||||
|
||||
@@ -2464,7 +2464,7 @@ def _get_head_dtype(
|
||||
|
||||
|
||||
def _get_and_verify_max_len(
|
||||
hf_config: PretrainedConfig,
|
||||
hf_config: PreTrainedConfig,
|
||||
model_arch_config: ModelArchitectureConfig,
|
||||
tokenizer_config: dict | None,
|
||||
max_model_len: int | None,
|
||||
|
||||
@@ -22,12 +22,12 @@ from vllm.utils.import_utils import LazyLoader, has_arctic_inference
|
||||
from vllm.v1.attention.backends.registry import AttentionBackendEnum
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from transformers import PretrainedConfig
|
||||
from transformers import PreTrainedConfig
|
||||
|
||||
import vllm.model_executor.layers.quantization as me_quant
|
||||
from vllm.config.vllm import VllmConfig
|
||||
else:
|
||||
PretrainedConfig = Any
|
||||
PreTrainedConfig = Any
|
||||
VllmConfig = Any
|
||||
|
||||
me_quant = LazyLoader(
|
||||
@@ -657,7 +657,7 @@ class SpeculativeConfig:
|
||||
return hash_str
|
||||
|
||||
@staticmethod
|
||||
def hf_config_override(hf_config: PretrainedConfig) -> PretrainedConfig:
|
||||
def hf_config_override(hf_config: PreTrainedConfig) -> PreTrainedConfig:
|
||||
initial_architecture = hf_config.architectures[0]
|
||||
use_v32_mtp = hf_config.model_type in ("deepseek_v32", "glm_moe_dsa")
|
||||
if hf_config.model_type == "dots3_note":
|
||||
@@ -1066,16 +1066,16 @@ class SpeculativeConfig:
|
||||
|
||||
@staticmethod
|
||||
def _apply_composed_hf_override(
|
||||
target_hf_overrides: Callable[[PretrainedConfig], PretrainedConfig],
|
||||
hf_config: PretrainedConfig,
|
||||
) -> PretrainedConfig:
|
||||
target_hf_overrides: Callable[[PreTrainedConfig], PreTrainedConfig],
|
||||
hf_config: PreTrainedConfig,
|
||||
) -> PreTrainedConfig:
|
||||
hf_config = SpeculativeConfig.hf_config_override(hf_config)
|
||||
return target_hf_overrides(hf_config)
|
||||
|
||||
@staticmethod
|
||||
def compose_draft_hf_overrides(
|
||||
target_hf_overrides: HfOverrides | None,
|
||||
) -> Callable[[PretrainedConfig], PretrainedConfig]:
|
||||
) -> Callable[[PreTrainedConfig], PreTrainedConfig]:
|
||||
"""Build the ``hf_overrides`` for the draft ``ModelConfig``.
|
||||
|
||||
Callable overrides on the target are config-to-config transforms
|
||||
@@ -1667,7 +1667,7 @@ class SpeculativeConfig:
|
||||
|
||||
@staticmethod
|
||||
def _maybe_override_draft_max_position_embeddings(
|
||||
draft_hf_config: PretrainedConfig,
|
||||
draft_hf_config: PreTrainedConfig,
|
||||
target_max_model_len: int,
|
||||
) -> None:
|
||||
"""Raise an EAGLE draft's max_position_embeddings up to the target's.
|
||||
@@ -1704,7 +1704,7 @@ class SpeculativeConfig:
|
||||
def _verify_and_get_draft_tp(
|
||||
target_parallel_config: ParallelConfig,
|
||||
speculative_draft_tensor_parallel_size: int | None,
|
||||
draft_hf_config: PretrainedConfig,
|
||||
draft_hf_config: PreTrainedConfig,
|
||||
) -> int:
|
||||
"""Verifies and adjusts the tensor parallel size for a draft model
|
||||
specified using speculative_draft_tensor_parallel_size.
|
||||
|
||||
@@ -138,7 +138,7 @@ def getattr_iter(
|
||||
) -> Any:
|
||||
"""A helper function that retrieves an attribute from an object which may
|
||||
have multiple possible names. This is useful when fetching attributes from
|
||||
arbitrary `transformers.PretrainedConfig` instances.
|
||||
arbitrary `transformers.PreTrainedConfig` instances.
|
||||
|
||||
In the case where the first name in `names` is the preferred name, and
|
||||
any other names are deprecated aliases, setting `warn=True` will log a
|
||||
@@ -314,7 +314,7 @@ def normalize_value(x):
|
||||
except Exception:
|
||||
return str(x)
|
||||
|
||||
# PretrainedConfig (must be before dataclass branch as these are now dataclasses)
|
||||
# PreTrainedConfig (must be before dataclass branch as these are now dataclasses)
|
||||
if hasattr(x, "to_json_string") and callable(x.to_json_string):
|
||||
try:
|
||||
return x.to_json_string()
|
||||
|
||||
+3
-3
@@ -56,12 +56,12 @@ from .watermarking import WatermarkConfig
|
||||
from .weight_transfer import WeightTransferConfig
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from transformers import PretrainedConfig
|
||||
from transformers import PreTrainedConfig
|
||||
|
||||
from vllm.model_executor.layers.quantization.base_config import QuantizationConfig
|
||||
from vllm.v1.kv_cache_interface import KVCacheConfig
|
||||
else:
|
||||
PretrainedConfig = Any
|
||||
PreTrainedConfig = Any
|
||||
|
||||
QuantizationConfig = Any
|
||||
|
||||
@@ -939,7 +939,7 @@ class VllmConfig:
|
||||
|
||||
def with_hf_config(
|
||||
self,
|
||||
hf_config: PretrainedConfig,
|
||||
hf_config: PreTrainedConfig,
|
||||
architectures: list[str] | None = None,
|
||||
) -> "VllmConfig":
|
||||
if architectures is not None:
|
||||
|
||||
Reference in New Issue
Block a user