Support weight update for blackwell DeepGEMM (#13324)
This commit is contained in:
@@ -105,6 +105,7 @@ from sglang.srt.layers.quantization.fp8_utils import (
|
|||||||
block_quant_dequant,
|
block_quant_dequant,
|
||||||
block_quant_to_tensor_quant,
|
block_quant_to_tensor_quant,
|
||||||
channel_quant_to_tensor_quant,
|
channel_quant_to_tensor_quant,
|
||||||
|
inverse_transform_scale_ue8m0,
|
||||||
normalize_e4m3fn_to_e4m3fnuz,
|
normalize_e4m3fn_to_e4m3fnuz,
|
||||||
quant_weight_ue8m0,
|
quant_weight_ue8m0,
|
||||||
requant_weight_ue8m0_inplace,
|
requant_weight_ue8m0_inplace,
|
||||||
@@ -3270,6 +3271,8 @@ class DeepseekV2ForCausalLM(nn.Module):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
self.capture_aux_hidden_states = False
|
self.capture_aux_hidden_states = False
|
||||||
|
self._executed_weight_requant_ue8m0 = False
|
||||||
|
|
||||||
self.nsa_enable_prefill_cp = is_nsa_enable_prefill_cp()
|
self.nsa_enable_prefill_cp = is_nsa_enable_prefill_cp()
|
||||||
if self.nsa_enable_prefill_cp:
|
if self.nsa_enable_prefill_cp:
|
||||||
self.cp_rank = get_attention_tp_rank()
|
self.cp_rank = get_attention_tp_rank()
|
||||||
@@ -3443,6 +3446,18 @@ class DeepseekV2ForCausalLM(nn.Module):
|
|||||||
weight = w
|
weight = w
|
||||||
weight_scale = self_attn.kv_b_proj.weight_scale_inv
|
weight_scale = self_attn.kv_b_proj.weight_scale_inv
|
||||||
|
|
||||||
|
if (
|
||||||
|
should_deepgemm_weight_requant_ue8m0(
|
||||||
|
weight_block_size=getattr(
|
||||||
|
self.quant_config, "weight_block_size", None
|
||||||
|
)
|
||||||
|
)
|
||||||
|
and self._executed_weight_requant_ue8m0
|
||||||
|
):
|
||||||
|
weight_scale = inverse_transform_scale_ue8m0(
|
||||||
|
weight_scale, mn=weight.shape[-2]
|
||||||
|
)
|
||||||
|
|
||||||
if (
|
if (
|
||||||
_is_cuda
|
_is_cuda
|
||||||
and weight_block_size[0] == 128
|
and weight_block_size[0] == 128
|
||||||
@@ -3553,9 +3568,14 @@ class DeepseekV2ForCausalLM(nn.Module):
|
|||||||
self_attn.w_vc = bind_or_assign(self_attn.w_vc, w_vc.contiguous())
|
self_attn.w_vc = bind_or_assign(self_attn.w_vc, w_vc.contiguous())
|
||||||
self_attn.use_deep_gemm_bmm = True
|
self_attn.use_deep_gemm_bmm = True
|
||||||
|
|
||||||
if not ENABLE_FLASHINFER_FP8_GEMM and should_deepgemm_weight_requant_ue8m0(
|
if (
|
||||||
weight_block_size=getattr(self.quant_config, "weight_block_size", None)
|
not ENABLE_FLASHINFER_FP8_GEMM
|
||||||
|
and should_deepgemm_weight_requant_ue8m0(
|
||||||
|
weight_block_size=getattr(self.quant_config, "weight_block_size", None)
|
||||||
|
)
|
||||||
|
and not self._executed_weight_requant_ue8m0
|
||||||
):
|
):
|
||||||
|
self._executed_weight_requant_ue8m0 = True
|
||||||
self._weight_requant_ue8m0(is_nextn)
|
self._weight_requant_ue8m0(is_nextn)
|
||||||
|
|
||||||
# TODO can move weight_requant_ue8m0 and transform_scale_ue8m0 into Fp8LinearMethod.process_weights_after_loading
|
# TODO can move weight_requant_ue8m0 and transform_scale_ue8m0 into Fp8LinearMethod.process_weights_after_loading
|
||||||
|
|||||||
Reference in New Issue
Block a user