Skip to content

Commit 7da77b9

Browse files
committed
Update moe activation logics
Signed-off-by: Chenjie Luo <chenjiel@nvidia.com>
1 parent 8baeaaf commit 7da77b9

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

modelopt/torch/export/moe_utils.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,10 @@ def save_expert_token_count_table(model: nn.Module, output_dir: str | Path | Non
5555
avg = counts.float().mean().item()
5656
html_parts.append(f"<tr><td>{name}</td>")
5757
for c in counts.tolist():
58-
if avg > 0 and c < avg:
59-
# Scale from white (at average) to full red (at zero)
60-
ratio = c / avg
61-
r_channel = 255
62-
gb_channel = int(100 * ratio)
63-
style = f' style="background: rgb({r_channel},{gb_channel},{gb_channel});"'
58+
if avg > 0 and c < avg * 0.05:
59+
style = ' style="background: #ff6666;"'
60+
elif avg > 0 and c < avg * 0.1:
61+
style = ' style="background: #ffcccc;"'
6462
else:
6563
style = ""
6664
html_parts.append(f"<td{style}>{c}</td>")
@@ -71,6 +69,6 @@ def save_expert_token_count_table(model: nn.Module, output_dir: str | Path | Non
7169

7270
if output_dir is None:
7371
output_dir = Path(".")
74-
output_path = Path(output_dir) / "moe.html"
72+
output_path = Path(output_dir) / ".moe.html"
7573
output_path.write_text(html_content)
7674
print(f"Expert token count table saved to {output_path}")

0 commit comments

Comments
 (0)