[ROCm] [Bugfix] Fix DeepSeek V4 Functionality and Accuracy (#42810)
Signed-off-by: tjtanaa <tunjian.tan@embeddedllm.com>
This commit is contained in:
@@ -61,31 +61,35 @@ class MHCPreOp(CustomOp):
|
||||
sinkhorn_repeat: int,
|
||||
n_splits: int = 1,
|
||||
) -> tuple[torch.Tensor, torch.Tensor, torch.Tensor]:
|
||||
hidden_size = residual.shape[-1]
|
||||
if hidden_size % 256 == 0:
|
||||
return torch.ops.vllm.mhc_pre_aiter(
|
||||
residual,
|
||||
fn,
|
||||
hc_scale,
|
||||
hc_base,
|
||||
rms_eps,
|
||||
hc_pre_eps,
|
||||
hc_sinkhorn_eps,
|
||||
hc_post_mult_value,
|
||||
sinkhorn_repeat,
|
||||
)
|
||||
else:
|
||||
return mhc_kernels.mhc_pre_torch(
|
||||
residual,
|
||||
fn,
|
||||
hc_scale,
|
||||
hc_base,
|
||||
rms_eps,
|
||||
hc_pre_eps,
|
||||
hc_sinkhorn_eps,
|
||||
hc_post_mult_value,
|
||||
sinkhorn_repeat,
|
||||
)
|
||||
# TODO: Reenable aiter after we are at the aiter
|
||||
# version that has this bugfix
|
||||
# https://github.com/ROCm/aiter/commit/b639cb63bcac4672dce33a731fad042a65cb3649
|
||||
# It has accuracy problem at large number of tokens.
|
||||
# hidden_size = residual.shape[-1]
|
||||
# if hidden_size % 256 == 0:
|
||||
# return torch.ops.vllm.mhc_pre_aiter(
|
||||
# residual,
|
||||
# fn,
|
||||
# hc_scale,
|
||||
# hc_base,
|
||||
# rms_eps,
|
||||
# hc_pre_eps,
|
||||
# hc_sinkhorn_eps,
|
||||
# hc_post_mult_value,
|
||||
# sinkhorn_repeat,
|
||||
# )
|
||||
# else:
|
||||
return mhc_kernels.mhc_pre_torch(
|
||||
residual,
|
||||
fn,
|
||||
hc_scale,
|
||||
hc_base,
|
||||
rms_eps,
|
||||
hc_pre_eps,
|
||||
hc_sinkhorn_eps,
|
||||
hc_post_mult_value,
|
||||
sinkhorn_repeat,
|
||||
)
|
||||
|
||||
def forward_native(self, *args, **kwargs):
|
||||
raise NotImplementedError("Native implementation of mhc_pre is not available")
|
||||
@@ -124,21 +128,25 @@ class MHCPostOp(CustomOp):
|
||||
post_layer_mix: torch.Tensor,
|
||||
comb_res_mix: torch.Tensor,
|
||||
) -> torch.Tensor:
|
||||
hidden_size = residual.shape[-1]
|
||||
if hidden_size % 256 == 0:
|
||||
return torch.ops.vllm.mhc_post_aiter(
|
||||
x,
|
||||
residual,
|
||||
post_layer_mix,
|
||||
comb_res_mix,
|
||||
)
|
||||
else:
|
||||
return mhc_kernels.mhc_post_torch(
|
||||
x,
|
||||
residual,
|
||||
post_layer_mix,
|
||||
comb_res_mix,
|
||||
)
|
||||
# TODO: Reenable aiter after we are at the aiter
|
||||
# version that has this bugfix
|
||||
# https://github.com/ROCm/aiter/commit/b639cb63bcac4672dce33a731fad042a65cb3649
|
||||
# It has accuracy problem at large number of tokens.
|
||||
# hidden_size = residual.shape[-1]
|
||||
# if hidden_size % 256 == 0:
|
||||
# return torch.ops.vllm.mhc_post_aiter(
|
||||
# x,
|
||||
# residual,
|
||||
# post_layer_mix,
|
||||
# comb_res_mix,
|
||||
# )
|
||||
# else:
|
||||
return mhc_kernels.mhc_post_torch(
|
||||
x,
|
||||
residual,
|
||||
post_layer_mix,
|
||||
comb_res_mix,
|
||||
)
|
||||
|
||||
def forward_native(self, *args, **kwargs):
|
||||
raise NotImplementedError("Native implementation of mhc_post is not available")
|
||||
|
||||
Reference in New Issue
Block a user