Code clean up for fp8 quantization (#16982)
This commit is contained in:
@@ -1869,9 +1869,10 @@ def crash_on_warnings():
|
||||
return get_bool_env_var("SGLANG_IS_IN_CI")
|
||||
|
||||
|
||||
@functools.lru_cache(None)
|
||||
def print_warning_once(msg: str) -> None:
|
||||
# Set the stacklevel to 2 to print the caller's line info
|
||||
logger.warning(msg, stacklevel=2)
|
||||
logger.warning(msg)
|
||||
|
||||
|
||||
@functools.lru_cache(None)
|
||||
@@ -3774,6 +3775,20 @@ def calc_diff(x, y):
|
||||
return 1 - sim
|
||||
|
||||
|
||||
@contextmanager
|
||||
def temp_attr_context(obj, attr, value):
|
||||
if obj is None:
|
||||
yield
|
||||
return
|
||||
|
||||
original_value = getattr(obj, attr)
|
||||
setattr(obj, attr, value)
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
setattr(obj, attr, original_value)
|
||||
|
||||
|
||||
cached_device_index = -1
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user