[NPU] fix some npu error with OffloaderV2 (#19541)
Co-authored-by: Jianzhao Xu <xujianchao@huawei.com> Co-authored-by: sglang-npu-bot <sglangnpu@163.com>
This commit is contained in:
co-authored by
Jianzhao Xu
sglang-npu-bot
parent
577dbc4ab9
commit
aa74911448
@@ -170,6 +170,10 @@ def npu_format_cast(
|
||||
)
|
||||
return tensor
|
||||
|
||||
# Skip format cast for meta tensors (used in offloader)
|
||||
if tensor.device.type == "meta":
|
||||
return tensor
|
||||
|
||||
return torch.ops.npu.npu_format_cast(tensor, acl_format.value)
|
||||
|
||||
|
||||
|
||||
@@ -317,8 +317,10 @@ class UnquantizedFusedMoEMethod(FusedMoEMethodBase, MultiPlatformOp):
|
||||
if _is_npu:
|
||||
for weight_name in ["w13_weight", "w2_weight"]:
|
||||
weight = getattr(layer, weight_name)
|
||||
weight.data = weight.data.transpose(1, 2)
|
||||
weight.data = npu_format_cast(weight.data)
|
||||
origin_weight = weight.data.transpose(1, 2)
|
||||
new_weight = origin_weight.contiguous()
|
||||
origin_weight.untyped_storage().resize_(0)
|
||||
weight.data = npu_format_cast(new_weight)
|
||||
|
||||
return
|
||||
|
||||
|
||||
@@ -452,6 +452,10 @@ def _move_param_to_meta(module, param_name):
|
||||
data=new_data,
|
||||
requires_grad=False,
|
||||
)
|
||||
if hasattr(old_param, "weihgt_loader"):
|
||||
new_param.weight_loader = old_param.weight_loader
|
||||
else:
|
||||
new_param.weight_loader = lambda *args, **kwargs: None
|
||||
else:
|
||||
raise ValueError(f"Unknown {old_param_type=} {old_param=}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user