Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions python/sglang/srt/models/bailing_moe.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,7 @@ def __init__(
self.expert_bias = None

def forward(self, hidden_states):
logits = F.linear(hidden_states.to(self.weight.dtype), self.weight, None).to(
hidden_states.dtype
)
return logits
return F.linear(hidden_states.to(self.weight.dtype), self.weight, None)


class BailingMoESparseMoeBlock(nn.Module):
Expand Down
5 changes: 1 addition & 4 deletions python/sglang/srt/models/bailing_moe_linear.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,7 @@ def __init__(
self.expert_bias = None

def forward(self, hidden_states):
logits = F.linear(hidden_states.to(self.weight.dtype), self.weight, None).to(
hidden_states.dtype
)
return logits
return F.linear(hidden_states.to(self.weight.dtype), self.weight, None)


class BailingMoE(nn.Module):
Expand Down
2 changes: 1 addition & 1 deletion python/sglang/srt/models/ernie4.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def __init__(
torch.empty((config.moe_num_experts, config.hidden_size))
)
self.e_score_correction_bias = nn.Parameter(
torch.empty((1, config.moe_num_experts))
torch.empty((1, config.moe_num_experts), dtype=torch.float32)
)

def forward(self, hidden_states):
Expand Down
4 changes: 3 additions & 1 deletion python/sglang/srt/models/kimi_linear.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ def __init__(
prefix=f"{prefix}.gate",
)

self.gate.e_score_correction_bias = nn.Parameter(torch.empty(num_experts))
self.gate.e_score_correction_bias = nn.Parameter(
torch.empty(num_experts, dtype=torch.float32)
)

self.experts = get_moe_impl_class(quant_config)(
num_experts=config.n_routed_experts,
Expand Down
14 changes: 2 additions & 12 deletions python/sglang/srt/models/mimo_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,7 @@
resolve_linear_parallel_group,
)
from sglang.srt.layers.logits_processor import LogitsProcessor
from sglang.srt.layers.moe import (
get_moe_a2a_backend,
get_moe_runner_backend,
)
from sglang.srt.layers.moe import get_moe_a2a_backend
from sglang.srt.layers.moe.ep_moe.layer import DeepEPMoE, get_moe_impl_class
from sglang.srt.layers.moe.topk import TopK, TopKOutputFormat
from sglang.srt.layers.moe.utils import is_deepep_class_backend
Expand Down Expand Up @@ -360,15 +357,8 @@ def __init__(
torch.empty((config.n_routed_experts, config.hidden_size), dtype=self.dtype)
)
if config.topk_method == "noaux_tc":
correction_bias_dtype = (
torch.bfloat16
if quant_config is not None
and quant_config.get_name() == "modelopt_fp4"
and get_moe_runner_backend().is_flashinfer_trtllm()
else torch.float32
)
self.e_score_correction_bias = nn.Parameter(
torch.empty((config.n_routed_experts), dtype=correction_bias_dtype)
torch.empty((config.n_routed_experts), dtype=torch.float32)
)
else:
self.e_score_correction_bias = None
Expand Down
Loading