vllm-project/vllm · error · ValueError

torch_profiler_dir is only applicable when profiler is set t

Error message

torch_profiler_dir is only applicable when profiler is set to 'torch'

What it means

ProfilerConfig's model_validator rejects a non-empty torch_profiler_dir when profiler is not 'torch'. Trace-directory options are paired with their profiler kind; specifying a torch trace dir while selecting 'cuda' or 'proton' (or no profiler) indicates a misconfigured profiler setup.

Source

Thrown at vllm/config/profiler.py:178

        """
        # no factors to consider.
        # this config will not affect the computation graph.
        factors: list[Any] = []
        hash_str = safe_hash(str(factors).encode(), usedforsecurity=False).hexdigest()
        return hash_str

    @model_validator(mode="after")
    def _validate_profiler_config(self) -> Self:
        has_delay_or_limit = self.delay_iterations > 0 or self.max_iterations > 0
        if self.profiler == "torch" and has_delay_or_limit and not self.ignore_frontend:
            logger.warning_once(
                "Using 'torch' profiler with delay_iterations or max_iterations "
                "while ignore_frontend is False may result in high overhead."
            )

        torch_profiler_dir = self.torch_profiler_dir
        if torch_profiler_dir and self.profiler != "torch":
            raise ValueError(
                "torch_profiler_dir is only applicable when profiler is set to 'torch'"
            )
        if self.profiler == "torch" and not torch_profiler_dir:
            raise ValueError("torch_profiler_dir must be set when profiler is 'torch'")

        # Support any URI scheme (gs://, s3://, hdfs://, etc.)
        # These paths should not be converted to absolute paths
        if torch_profiler_dir and not _is_uri_path(torch_profiler_dir):
            self.torch_profiler_dir = os.path.abspath(
                os.path.expanduser(torch_profiler_dir)
            )

        proton_profiler_dir = self.proton_profiler_dir
        non_default_proton_options = [
            name
            for name, value, default in (
                ("proton_profiler_dir", proton_profiler_dir, ""),
                ("proton_context", self.proton_context, "shadow"),

View on GitHub (pinned to c794754062)

Solutions

  1. Set profiler='torch' if you want torch traces: --profiler-config profiler=torch,torch_profiler_dir=/tmp/tr.
  2. Or remove torch_profiler_dir when using proton/cuda.
  3. Move the path to proton_profiler_dir if proton profiling was intended.

Example fix

# before
ProfilerConfig(torch_profiler_dir='/tmp/traces')  # profiler defaults to None

# after
ProfilerConfig(profiler='torch', torch_profiler_dir='/tmp/traces')
Defensive patterns

Strategy: validation

Validate before calling

def validate_profiler_cfg(profiler: str | None, torch_dir: str) -> None:
    if torch_dir and profiler != "torch":
        raise SystemExit("torch_profiler_dir set but profiler != 'torch'; set profiler='torch' or drop the dir")

Prevention

When it happens

Trigger: Passing --profiler-config torch_profiler_dir=/tmp/traces with profiler unset, or with profiler='proton'/'cuda'; leftover torch_profiler_dir in a shared profiler-config string when switching profiler kinds.

Common situations: Copy-pasted profiling flags between profiles; enabling a profiler via /start_profile API while the static config still names a torch dir for a different kind.

Related errors


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