Lazy import torchao (#17626)
This commit is contained in:
@@ -99,4 +99,3 @@ class Lfm2Config(HFLfm2Config):
|
||||
# Cannot use .register() because lfm2 is already registered by transformers
|
||||
# Directly modify the internal _extra_content dict instead
|
||||
CONFIG_MAPPING._extra_content["lfm2"] = Lfm2Config
|
||||
logger.info("Registered SGLang Lfm2Config to override HuggingFace's version")
|
||||
|
||||
@@ -42,6 +42,9 @@ def apply_torchao_config_to_model(
|
||||
quantize the model, e.g. int4wo-128 means int4 weight only quantization with group_size
|
||||
128
|
||||
"""
|
||||
if torchao_config == "" or torchao_config is None:
|
||||
return model
|
||||
|
||||
# Lazy import to suppress some warnings
|
||||
from torchao.quantization import (
|
||||
float8_dynamic_activation_float8_weight,
|
||||
@@ -53,9 +56,7 @@ def apply_torchao_config_to_model(
|
||||
)
|
||||
from torchao.quantization.observer import PerRow, PerTensor
|
||||
|
||||
if torchao_config == "" or torchao_config is None:
|
||||
return model
|
||||
elif "int8wo" in torchao_config:
|
||||
if "int8wo" in torchao_config:
|
||||
quantize_(model, int8_weight_only(), filter_fn=proj_filter_conv3d)
|
||||
elif "int8dq" in torchao_config:
|
||||
quantize_(model, int8_dynamic_activation_int8_weight(), filter_fn=filter_fn)
|
||||
|
||||
Reference in New Issue
Block a user