{"record":{"id":"093df82f97ab354e","repo":"vllm-project/vllm","slug":"torch-profiler-dir-must-be-set-when-profiler-is-t","errorCode":null,"errorMessage":"torch_profiler_dir must be set when profiler is 'torch'","messagePattern":"torch_profiler_dir must be set when profiler is 'torch'","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"vllm/config/profiler.py","lineNumber":182,"sourceCode":"        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\"),\n                (\"proton_data\", self.proton_data, \"tree\"),\n                (\"proton_backend\", self.proton_backend, None),\n                (\"proton_mode\", self.proton_mode, None),\n                (\"proton_hook\", self.proton_hook, None),","sourceCodeStart":164,"sourceCodeEnd":200,"githubUrl":"https://github.com/vllm-project/vllm/blob/c794754062d49a8fdb63ab3c5215b488b865030c/vllm/config/profiler.py#L164-L200","documentation":"Inverse pairing rule: when profiler == 'torch', ProfilerConfig requires torch_profiler_dir to be set, because both the frontend (AsyncLLM) and workers need a directory to write trace files. An absolute-path expansion is applied afterwards (URI schemes like gs:// pass through untouched).","triggerScenarios":"Passing profiler='torch' without torch_profiler_dir, e.g. --profiler-config profiler=torch alone.","commonSituations":"Assuming the torch profiler writes to CWD by default; enabling the profiler through the /start_profile endpoint without configuring an output dir first.","solutions":["Add torch_profiler_dir: --profiler-config profiler=torch,torch_profiler_dir=/tmp/vllm_traces.","Use an absolute local path, or a URI (gs://bucket/traces) if uploading remotely."],"exampleFix":"# before\nProfilerConfig(profiler='torch')\n\n# after\nProfilerConfig(profiler='torch', torch_profiler_dir='/tmp/vllm_traces')","handlingStrategy":"validation","validationCode":"def validate_profiler_cfg(profiler: str | None, torch_dir: str) -> None:\n    if profiler == \"torch\" and not torch_dir:\n        raise SystemExit(\"profiler='torch' requires torch_profiler_dir\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Template the profiler config as a single string: profiler=torch,torch_profiler_dir=/abs/path."],"tags":["profiling","torch-profiler","configuration"],"backgroundTag":null,"analyzedSha":"c794754062d49a8fdb63ab3c5215b488b865030c","analyzedAt":"2026-08-14T21:17:39.825Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}