Skip to content
Merged
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
2 changes: 1 addition & 1 deletion python/sglang/srt/eplb/expert_location_dispatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def transform_select_experts_inputs(
info: Optional[ExpertLocationDispatchInfo],
):
if (info is not None) and (info.ep_dispatch_algorithm == "fake"):
router_logits = torch.randn_like(router_logits)
router_logits.uniform_(5, 10)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using magic numbers 5 and 10 directly in the code harms readability and maintainability. It would be better to define these as named constants with descriptive names (e.g., FAKE_DISPATCH_UNIFORM_MIN, FAKE_DISPATCH_UNIFORM_MAX) at the module level. This makes the purpose of these values clear and simplifies future modifications.

if correction_bias is not None:
correction_bias = torch.zeros_like(correction_bias)
return router_logits, correction_bias
Expand Down
2 changes: 1 addition & 1 deletion python/sglang/srt/layers/moe/topk.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ def biased_grouped_topk_gpu(
and is_power_of_two(correction_bias.shape[0])
):
topk_weights, topk_ids = moe_fused_gate(
gating_output,
gating_output.to(dtype=torch.float32),
correction_bias,
num_expert_group,
topk_group,
Expand Down
2 changes: 1 addition & 1 deletion python/sglang/srt/models/deepseek_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def __init__(
)
if config.topk_method == "noaux_tc":
self.e_score_correction_bias = nn.Parameter(
torch.empty((config.n_routed_experts))
torch.empty((config.n_routed_experts), dtype=torch.float32)
)
else:
self.e_score_correction_bias = None
Expand Down
Loading