moe_utils

Utilities for Mixture-of-Experts (MoE) model export.

Functions

save_expert_token_count_table

Collect expert_token_count from all quantized MoE layers and save as an HTML table.

save_expert_token_count_table(model, output_dir=None)

Collect expert_token_count from all quantized MoE layers and save as an HTML table.

The table has rows for each MoE layer and columns for each expert, with cell values showing the number of tokens routed to that expert during calibration.

Parameters:
  • model (Module) – The model containing quantized MoE layers with expert_token_count attributes.

  • output_dir (str | Path | None) – Directory to save the HTML file. Defaults to current directory.