Code clean up for fp8 quantization (#16982)

This commit is contained in:
Lianmin Zheng
2026-01-13 12:38:39 -08:00
committed by GitHub
parent a0b4ba9032
commit 075c5a5789
9 changed files with 309 additions and 237 deletions

View File

@@ -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