vllm-project/vllm · error · ValueError

max_model_len must be a positive integer, got {type(self.max

Error message

max_model_len must be a positive integer, got {type(self.max_model_len).__name__}: {self.max_model_len!r}. Example: max_model_len=2048

What it means

Error "max_model_len must be a positive integer, got {type(self.max_model_len).__name__}: {self.max_model_len!r}. Example: max_model_len=2048" thrown in vllm-project/vllm.

Source

Thrown at vllm/config/model.py:924

    @field_validator("quantization", mode="before")
    @classmethod
    def validate_quantization_before(cls, value: Any) -> Any:
        if isinstance(value, str):
            return value.lower()
        return value

    @model_validator(mode="after")
    def validate_model_config_after(self: "ModelConfig") -> "ModelConfig":
        """Called after __post_init__"""
        if not isinstance(self.tokenizer, str):
            raise ValueError(
                f"tokenizer must be a string, got "
                f"{type(self.tokenizer).__name__}: {self.tokenizer!r}. "
                "Please provide a valid tokenizer path or HuggingFace model ID."
            )
        if not isinstance(self.max_model_len, int) or self.max_model_len < 1:
            raise ValueError(
                f"max_model_len must be a positive integer, "
                f"got {type(self.max_model_len).__name__}: {self.max_model_len!r}. "
                "Example: max_model_len=2048"
            )
        return self

    def _resolve_mm_device_do_normalize(
        self, mm_device_do_normalize: bool | None
    ) -> bool:
        if mm_device_do_normalize is None:
            if envs.VLLM_USE_RUST_FRONTEND:
                logger.debug(
                    "VLLM_USE_RUST_FRONTEND is set. "
                    "Rust frontend does not currently support mm_device_do_normalize, "
                    "forcing mm_device_do_normalize = False."
                )
                mm_device_do_normalize = False
            else:

View on GitHub (pinned to c794754062)

Solutions

  1. Set max_model_len to a positive integer, e.g. max_model_len=2048.

When it happens

Trigger: Raised at vllm/config/model.py:924 when validation fails: max_model_len must be a positive integer. Typically triggered by an incompatible or incomplete vLLM configuration, an unsupported platform/backend combination, or a runtime resource/dependency that is missing.

Common situations: Commonly encountered at vllm/config/model.py:924 during vLLM startup/config validation or runtime setup when: (1) conflicting CLI flags or config fields are combined, (2) the current platform (CUDA/ROCm/CPU/XPU) or installed optional packages do not support the requested feature, or (3) a required value is absent or out of range. Resolve by correcting the configuration as described in the message, or by selecting a supported alternative.


AI-assisted analysis of vllm-project/vllm@c794754062 (2026-08-14). Data as JSON: /api/errors/267c943c8492ddf9. Report an issue: GitHub.