[quant] fix fp32 downcasting (#19844)
Co-authored-by: qiuxuan.lzw <qiuxuan.lzw@alibaba-inc.com>
This commit is contained in:
@@ -326,6 +326,7 @@ class Envs:
|
||||
SGLANG_NVFP4_CKPT_FP8_GEMM_IN_ATTN = EnvBool(False)
|
||||
SGLANG_PER_TOKEN_GROUP_QUANT_8BIT_V2 = EnvBool(False)
|
||||
SGLANG_NVFP4_CKPT_FP8_NEXTN_MOE = EnvBool(False)
|
||||
SGLANG_QUANT_ALLOW_DOWNCASTING = EnvBool(False)
|
||||
|
||||
# Flashinfer
|
||||
SGLANG_IS_FLASHINFER_AVAILABLE = EnvBool(True)
|
||||
|
||||
@@ -7,6 +7,7 @@ from typing import Callable, Optional, Union
|
||||
import torch
|
||||
from torch.nn import Parameter
|
||||
|
||||
from sglang.srt.environ import envs
|
||||
from sglang.srt.layers.utils import pad_or_narrow_weight
|
||||
from sglang.srt.utils import is_cpu
|
||||
|
||||
@@ -65,7 +66,7 @@ def copy_with_check(target: torch.Tensor, loaded_weight: torch.Tensor):
|
||||
raise ValueError(
|
||||
f"Unsupported copy between dtypes: {target.dtype=}, {loaded_weight.dtype=}"
|
||||
)
|
||||
if target_rank < loaded_rank:
|
||||
if target_rank < loaded_rank and not envs.SGLANG_QUANT_ALLOW_DOWNCASTING.get():
|
||||
raise ValueError(
|
||||
f"Downcasting not allowed: {target.dtype=}, {loaded_weight.dtype=}"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user