Fix per file ruff ignores related to simplification (#26259)

Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
This commit is contained in:
Harry Mellor
2025-10-05 20:31:53 +00:00
committed by GitHub
parent 6b6e98775f
commit b893d661b1
32 changed files with 47 additions and 191 deletions
@@ -1746,10 +1746,7 @@ def fused_experts_impl(
else:
raise ValueError(f"Unsupported compute_type: {hidden_states.dtype}")
if inplace:
out_hidden_states = hidden_states
else:
out_hidden_states = torch.empty_like(hidden_states)
out_hidden_states = hidden_states if inplace else torch.empty_like(hidden_states)
if use_mxfp4_w4a4:
# Weight has to be dequantized for mxfp4 emulation.
@@ -886,10 +886,7 @@ def determine_expert_map(
# Distribute experts as evenly as possible to each rank.
base_experts = global_num_experts // ep_size
remainder = global_num_experts % ep_size
if ep_rank < remainder:
local_num_experts = base_experts + 1
else:
local_num_experts = base_experts
local_num_experts = base_experts + 1 if ep_rank < remainder else base_experts
# Create a tensor of size num_experts filled with -1
expert_map = torch.full((global_num_experts,), -1, dtype=torch.int32)
@@ -948,10 +948,7 @@ class FusedMoEModularKernel(torch.nn.Module):
"""
a1 = hidden_states
if inplace and self.shared_experts is None:
output = a1
else:
output = torch.zeros_like(a1)
output = a1 if inplace and self.shared_experts is None else torch.zeros_like(a1)
local_num_experts = w1.size(0)
if global_num_experts == -1:
@@ -355,10 +355,7 @@ def rocm_aiter_fused_experts(
topk_weights = topk_weights.to(torch.float32)
topk_ids = topk_ids.to(torch.int32)
if expert_map is not None:
expert_mask = (expert_map > -1).to(torch.int32)
else:
expert_mask = None
expert_mask = (expert_map > -1).to(torch.int32) if expert_map is not None else None
# w8a8 per-channel quantization
if (