{"record":{"id":"dc5b4ef455856005","repo":"vllm-project/vllm","slug":"torch-profiler-dir-is-only-applicable-when-profile","errorCode":null,"errorMessage":"torch_profiler_dir is only applicable when profiler is set to 'torch'","messagePattern":"torch_profiler_dir is only applicable when profiler is set to 'torch'","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"vllm/config/profiler.py","lineNumber":178,"sourceCode":"        \"\"\"\n        # no factors to consider.\n        # this config will not affect the computation graph.\n        factors: list[Any] = []\n        hash_str = safe_hash(str(factors).encode(), usedforsecurity=False).hexdigest()\n        return hash_str\n\n    @model_validator(mode=\"after\")\n    def _validate_profiler_config(self) -> Self:\n        has_delay_or_limit = self.delay_iterations > 0 or self.max_iterations > 0\n        if self.profiler == \"torch\" and has_delay_or_limit and not self.ignore_frontend:\n            logger.warning_once(\n                \"Using 'torch' profiler with delay_iterations or max_iterations \"\n                \"while ignore_frontend is False may result in high overhead.\"\n            )\n\n        torch_profiler_dir = self.torch_profiler_dir\n        if torch_profiler_dir and self.profiler != \"torch\":\n            raise ValueError(\n                \"torch_profiler_dir is only applicable when profiler is set to 'torch'\"\n            )\n        if self.profiler == \"torch\" and not torch_profiler_dir:\n            raise ValueError(\"torch_profiler_dir must be set when profiler is 'torch'\")\n\n        # Support any URI scheme (gs://, s3://, hdfs://, etc.)\n        # These paths should not be converted to absolute paths\n        if torch_profiler_dir and not _is_uri_path(torch_profiler_dir):\n            self.torch_profiler_dir = os.path.abspath(\n                os.path.expanduser(torch_profiler_dir)\n            )\n\n        proton_profiler_dir = self.proton_profiler_dir\n        non_default_proton_options = [\n            name\n            for name, value, default in (\n                (\"proton_profiler_dir\", proton_profiler_dir, \"\"),\n                (\"proton_context\", self.proton_context, \"shadow\"),","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/vllm-project/vllm/blob/c794754062d49a8fdb63ab3c5215b488b865030c/vllm/config/profiler.py#L160-L196","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Set profiler='torch' if you want torch traces: --profiler-config profiler=torch,torch_profiler_dir=/tmp/tr.","Or remove torch_profiler_dir when using proton/cuda.","Move the path to proton_profiler_dir if proton profiling was intended."],"exampleFix":"# before\nProfilerConfig(torch_profiler_dir='/tmp/traces')  # profiler defaults to None\n\n# after\nProfilerConfig(profiler='torch', torch_profiler_dir='/tmp/traces')","handlingStrategy":"validation","validationCode":"def validate_profiler_cfg(profiler: str | None, torch_dir: str) -> None:\n    if torch_dir and profiler != \"torch\":\n        raise SystemExit(\"torch_profiler_dir set but profiler != 'torch'; set profiler='torch' or drop the dir\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass profiler and its matching *_profiler_dir as one atomic unit in CLI strings / dicts."],"tags":["profiling","torch-profiler","configuration"],"backgroundTag":null,"analyzedSha":"c794754062d49a8fdb63ab3c5215b488b865030c","analyzedAt":"2026-08-14T21:17:39.825Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}