77from dataclasses import asdict , field
88from pathlib import Path
99from typing import TYPE_CHECKING , Any , Callable , ClassVar , Optional , Union
10+
1011from pydantic import TypeAdapter , field_validator
1112from pydantic .dataclasses import dataclass
1213
@@ -212,7 +213,8 @@ class CompilationConfig:
212213 """
213214 Whether to use inductor compilation.
214215
215- This flag is deprecated and will be removed. Please use the 'backend' option instead.
216+ This flag is deprecated and will be removed.
217+ Please use the 'backend' option instead.
216218
217219 - False: inductor compilation is not used. graph runs in eager
218220 (custom_ops enabled by default).
@@ -514,17 +516,22 @@ def __post_init__(self, **kwargs) -> None:
514516 "must be 'all', 'none', '+op' or '-op' "
515517 "(where 'op' is the registered op name)" )
516518
517- # Currently only eager and inductor backend are supported for piecewise compilation.
518- # Update when more backends are supported.
519- if self .level == CompilationLevel .PIECEWISE and self .backend not in ["" , "eager" , "inductor" ]:
520- raise ValueError (f"Invalid backend for piecewise compilation: { self .backend } " )
519+ # Currently only eager and inductor backend are supported
520+ # for piecewise compilation. Update when more backends are supported.
521+ if self .level == CompilationLevel .PIECEWISE and self .backend not in [
522+ "" , "eager" , "inductor"
523+ ]:
524+ raise ValueError (
525+ f"Invalid backend for piecewise compilation: { self .backend } " )
526+
527+ if self .backend == "" :
528+ self .backend = "inductor"
521529
522530 logger .warning_once (
523- "The 'use_inductor' flag is deprecated and will be removed in a future release. "
524- "Please use the 'backend' option instead." ,
525- )
526-
527-
531+ "The 'use_inductor' flag is deprecated and will be\
532+ removed in a future release."
533+ "Please use the 'backend' option instead." , )
534+
528535 def init_backend (self , vllm_config : "VllmConfig" ) -> Union [str , Callable ]:
529536 """
530537 Initialize the backend for the compilation config from a vllm config.
@@ -534,7 +541,10 @@ def init_backend(self, vllm_config: "VllmConfig") -> Union[str, Callable]:
534541 The backend for the compilation config.
535542 """
536543 if self .level is None :
537- raise ValueError ("No compilation level is set. This method should only be called via vllm config where the level is set if none is provided." )
544+ raise ValueError (
545+ "No compilation level is set. This method should only be \
546+ called via vllm config where the level is set if none is \
547+ provided." )
538548 if self .level == CompilationLevel .NO_COMPILATION :
539549 raise ValueError ("No compilation level is set." )
540550
@@ -554,8 +564,10 @@ def init_backend(self, vllm_config: "VllmConfig") -> Union[str, Callable]:
554564 elif self .backend in ["eager" , "inductor" ]:
555565 vllm_config .compilation_config .backend = self .backend
556566 else :
557- raise ValueError (f"Invalid backend for piecewise compilation: { self .backend } " )
558-
567+ raise ValueError (
568+ f"Invalid backend for piecewise compilation: { self .backend } "
569+ )
570+
559571 assert self .level == CompilationLevel .PIECEWISE
560572
561573 from vllm .compilation .backends import VllmBackend
0 commit comments