[feature]Ascend quantization support (#7791)

Co-authored-by: ichernob <ichernobnn@gmail.com>
Co-authored-by: liupeng <liupeng374@huawei.com>
This commit is contained in:
ronnie_zheng
2025-07-10 09:17:37 -07:00
committed by GitHub
co-authored by ichernob liupeng
parent 4a0d19198b
commit 766392c6bd
13 changed files with 889 additions and 34 deletions
+10
View File
@@ -34,6 +34,7 @@ from sglang.srt.layers.quantization.base_config import (
from sglang.srt.utils import (
cpu_has_amx_support,
is_cpu,
is_npu,
set_weight_attrs,
use_intel_amx_backend,
)
@@ -60,6 +61,7 @@ WEIGHT_LOADER_V2_SUPPORTED = [
_is_cpu_amx_available = cpu_has_amx_support()
_is_cpu = is_cpu()
_is_npu = is_npu()
def adjust_marlin_shard(param, shard_size, shard_offset):
@@ -297,6 +299,14 @@ class ReplicatedLinear(LinearBase):
if len(loaded_weight.shape) == 0:
loaded_weight = loaded_weight.reshape(1)
# The per-tensor quant-scale must be 1 dimension
if _is_npu:
if param.size() != loaded_weight.size() and param.size(0) == 1:
if torch.allclose(loaded_weight, loaded_weight[0]):
loaded_weight = loaded_weight[:1]
else:
raise ValueError(f"{loaded_weight} are not all equal")
assert param.size() == loaded_weight.size()
param.data.copy_(loaded_weight)