{"record":{"id":"b0874463aef19f72","repo":"vllm-project/vllm","slug":"compilation-mode-cannot-be-no-compilation","errorCode":null,"errorMessage":"Compilation mode cannot be NO_COMPILATION","messagePattern":"Compilation mode cannot be NO_COMPILATION","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"vllm/compilation/wrapper.py","lineNumber":88,"sourceCode":"        return callable_fn(*args, **kwargs)\n\n    def __init__(\n        self,\n        compile_prefix: str = \"\",\n        is_encoder: bool = False,\n    ) -> None:\n        self.compiled = False\n        self._compile_prefix = compile_prefix\n        self._is_encoder = is_encoder\n\n        vllm_config = get_current_vllm_config()\n        self.vllm_config = vllm_config\n        mode = vllm_config.compilation_config.mode\n        self.layerwise_nvtx_tracing_enabled = (\n            vllm_config.observability_config.enable_layerwise_nvtx_tracing\n        )\n        if mode is None:\n            raise RuntimeError(\"Compilation mode cannot be NO_COMPILATION\")\n\n        backend = vllm_config.compilation_config.init_backend(\n            vllm_config, prefix=compile_prefix, is_encoder=is_encoder\n        )\n        options = {}\n\n        if isinstance(backend, str) and backend == \"inductor\":\n            options = vllm_config.compilation_config.inductor_compile_config\n\n        self.first_compile = True\n        self.evaluate_guards = (\n            vllm_config.compilation_config.dynamic_shapes_config.evaluate_guards\n        )\n\n        ds_type = vllm_config.compilation_config.dynamic_shapes_config.type\n\n        if mode != CompilationMode.STOCK_TORCH_COMPILE:\n            # Drop all the guards.","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/vllm-project/vllm/blob/c794754062d49a8fdb63ab3c5215b488b865030c/vllm/compilation/wrapper.py#L70-L106","documentation":"TorchCompileWrapper.__init__ builds a torch.compile wrapper around the module and needs a concrete compilation backend; the backend is chosen from vllm_config.compilation_config.mode. If mode is None (CompilationMode.NO_COMPILATION / eager), constructing the wrapper is contradictory and vLLM raises RuntimeError immediately.","triggerScenarios":"Manually instantiating TorchCompileWrapper (or a subclass like VllmCompiledNode / CompilationWrapper) while the current vllm_config has compilation mode None — e.g. LLM(model=..., compilation_config=CompilationConfig(mode=None)) or enforce_eager=True paths, then calling the wrapper.","commonSituations":"Custom integration code that always wraps models in TorchCompileWrapper regardless of config; disabling compilation globally but a code path still constructs the wrapper; tests constructing wrappers with a default VllmConfig.","solutions":["Only construct the wrapper when compilation_config.mode is not None; guard the call site.","Set an explicit mode if you want compilation: CompilationConfig(mode='VLLM_COMPILE') (or run with -O3).","If you intended eager, skip the wrapper entirely instead of instantiating it."],"exampleFix":"# before\nwrapper = TorchCompileWrapper(my_module, compilation_prefix='model')\n# with compilation_config.mode is None\n# after\nfrom vllm.config.compilation import CompilationMode\nif vllm_config.compilation_config.mode is not None:\n    wrapper = TorchCompileWrapper(my_module, compilation_prefix='model')\nelse:\n    wrapper = my_module","handlingStrategy":"type-guard","validationCode":"from vllm.config.compilation import CompilationMode\n\ndef can_wrap(vllm_config) -> bool:\n    return vllm_config.compilation_config.mode is not CompilationMode.NONE and vllm_config.compilation_config.mode is not None","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Guard wrapper construction on mode is not None","Set an explicit mode when compilation is desired","Cover both eager and compiled paths in integration tests"],"tags":["torch-compile","configuration","vllm"],"backgroundTag":null,"analyzedSha":"c794754062d49a8fdb63ab3c5215b488b865030c","analyzedAt":"2026-08-14T21:17:39.825Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}