11"""Provide factory functions to conduct creation of various components."""
22
3+ # ruff: noqa: PLC0415
4+
35from typing import TYPE_CHECKING
46
57from naive_speculate .config .registry import InferencerType , KVCacheType , LanguageModelType
@@ -16,7 +18,7 @@ def make_lm(model_name: str) -> LanguageModel:
1618 family_name = model_name .split ("/" )[0 ].lower ()
1719 match LanguageModelType [family_name ]:
1820 case LanguageModelType .QWEN3 :
19- import naive_speculate .infer .lm .qwen3 as impl_module # noqa: PLC0415
21+ import naive_speculate .infer .lm .qwen3 as impl_module
2022
2123 lm_class = impl_module .LanguageModelImpl
2224 return lm_class (model_name = model_name )
@@ -25,9 +27,9 @@ def make_lm(model_name: str) -> LanguageModel:
2527def make_inferencer (language_model : LanguageModel , inferencer_type : InferencerType ) -> Inferencer :
2628 match inferencer_type :
2729 case InferencerType .BASIC :
28- import naive_speculate .infer .inferencer .basic as impl_module # noqa: PLC0415
30+ import naive_speculate .infer .inferencer .basic as impl_module
2931 case InferencerType .CHUNKWISE :
30- import naive_speculate .infer .inferencer .chunkwise as impl_module # noqa: PLC0415
32+ import naive_speculate .infer .inferencer .chunkwise as impl_module
3133
3234 inferencer_class = impl_module .InferencerImpl
3335 return inferencer_class (language_model = language_model )
@@ -44,9 +46,9 @@ def make_scorer(language_model: LanguageModel) -> Scorer:
4446def make_kvcache (kvcache_type : KVCacheType ) -> KVCache :
4547 match kvcache_type :
4648 case KVCacheType .DYNAMIC :
47- import naive_speculate .infer .kvcache .dynamic as impl_module # noqa: PLC0415
49+ import naive_speculate .infer .kvcache .dynamic as impl_module
4850 case KVCacheType .DYNAMIC_NO_UPDATE :
49- import naive_speculate .infer .kvcache .dynamic_no_update as impl_module # noqa: PLC0415
51+ import naive_speculate .infer .kvcache .dynamic_no_update as impl_module
5052
5153 kvcache_class = impl_module .KVCacheImpl
5254 return kvcache_class ()
0 commit comments