Optimize configuration access with LRU cache in custom ops (#22204)
Signed-off-by: zitian zhao <zitian.zhao@tencentmusic.com>
This commit is contained in:
+9
-1
@@ -15,7 +15,7 @@ from collections.abc import Mapping
|
||||
from contextlib import contextmanager
|
||||
from dataclasses import (MISSING, Field, asdict, field, fields, is_dataclass,
|
||||
replace)
|
||||
from functools import cached_property
|
||||
from functools import cached_property, lru_cache
|
||||
from importlib.util import find_spec
|
||||
from typing import (TYPE_CHECKING, Any, Callable, ClassVar, Literal, Optional,
|
||||
Protocol, TypeVar, Union, cast, get_args)
|
||||
@@ -5123,6 +5123,14 @@ def set_current_vllm_config(vllm_config: VllmConfig,
|
||||
finally:
|
||||
_current_vllm_config = old_vllm_config
|
||||
_current_prefix = old_prefix
|
||||
# Clear the compilation config cache when context changes
|
||||
get_cached_compilation_config.cache_clear()
|
||||
|
||||
|
||||
@lru_cache(maxsize=1)
|
||||
def get_cached_compilation_config():
|
||||
"""Cache config to avoid repeated calls to get_current_vllm_config()"""
|
||||
return get_current_vllm_config().compilation_config
|
||||
|
||||
|
||||
def get_current_vllm_config() -> VllmConfig:
|
||||
|
||||
Reference in New Issue
Block a user