Tiny refactor condition to requant scale ue8m0 (#13286)

This commit is contained in:
fzyzcjy
2025-11-15 16:36:00 +08:00
committed by GitHub
parent 8e6083bfcf
commit 33f08a98b0
4 changed files with 27 additions and 18 deletions

View File

@@ -12,6 +12,7 @@ from torch import nn
from transformers.dynamic_module_utils import get_class_from_dynamic_module
from sglang.srt.configs.model_config import ModelConfig, ModelImpl
from sglang.srt.layers import deep_gemm_wrapper
logger = logging.getLogger(__name__)
@@ -119,6 +120,15 @@ def post_load_weights(model: nn.Module, model_config: ModelConfig):
model.post_load_weights()
def should_deepgemm_weight_requant_ue8m0(weight_block_size):
"""Should we requant fp8 weights into UE8M0 format when loading the model"""
return (
deep_gemm_wrapper.ENABLE_JIT_DEEPGEMM
and deep_gemm_wrapper.DEEPGEMM_SCALE_UE8M0
and weight_block_size is not None
)
def should_async_load(weight: torch.Tensor) -> bool:
"""Return True if we should load the given weight asynchronously.