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
2 changes: 1 addition & 1 deletion tensorrt_llm/_torch/moe/fused_moe/MOE_DEVELOPER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -1463,7 +1463,7 @@ set wrong has a test that catches it:
the previous expert's values after a migration, with no error; extend
`tests/unittest/_torch/moe/test_w4a16_nvfp4_eplb.py` for a new one.
- `FUSED_COMM` backends use `ignore_allreduce=False` for EPLB statistic update because the fused kernel AllReduces routing stats internally.
- Warmup expert placement (`MoeLoadBalancerConfig.warmup_placement`, standard mode only; `moe_warmup_placement.py`) learns the placement of the static balancer layers from the live rows of real requests: each round swaps at most `max_moved_fraction` of a layer's slots between heavy and light ranks and moves their per-slot tensors GPU to GPU in place (captured CUDA graphs stay valid); the placement freezes after `max_migrations` rounds. With extra slots (`num_slots > num_experts`) a layer keeps copies of experts, which hold the same bytes, so outputs are unchanged; each round also moves the copies towards hot experts (cold experts take the extra slots a layer does not need). A backend that `counts_routes` adds the picks in its routing launch; otherwise the schedulers issue a separate count launch. Only a backend that implements `on_expert_placement_changed` is re-placed: `TrtllmCutedslMegaMoeNvfp4Impl` applies a static placement itself (`maps_expert_slots`), so `FusedCommMoEScheduler` hands it expert ids and its route + quantize launch writes slots into the launch bucket. Layers on other backends keep their configured placement, and a model whose MoE layers all run other backends is rejected at load.
- Warmup expert placement (`MoeLoadBalancerConfig.warmup_placement`, standard mode only; `moe_warmup_placement.py`) learns the placement of the static balancer layers from the live rows of real requests: each round swaps at most `max_moved_fraction` of a layer's slots between heavy and light ranks and moves their per-slot tensors GPU to GPU in place (captured CUDA graphs stay valid); opt-in `step_ema` and `drift_alpha` on `MoeWarmupPlacementConfig` (both `0.0` by default, forwarded via `OnlineDriftConfig`) enable rank-0 per-round increment EMA and round-to-round routing-distribution drift extrapolation before freezing after `max_migrations` rounds. With extra slots (`num_slots > num_experts`) a layer keeps copies of experts, which hold the same bytes, so outputs are unchanged; each round also moves the copies towards hot experts (cold experts take the extra slots a layer does not need). A backend that `counts_routes` adds the picks in its routing launch; otherwise the schedulers issue a separate count launch. Only a backend that implements `on_expert_placement_changed` is re-placed: `TrtllmCutedslMegaMoeNvfp4Impl` applies a static placement itself (`maps_expert_slots`), so `FusedCommMoEScheduler` hands it expert ids and its route + quantize launch writes slots into the launch bucket. Layers on other backends keep their configured placement, and a model whose MoE layers all run other backends is rejected at load.
- Per-layer dynamic EPLB uses `MoeConfig.load_balancer.mode=per_layer_dynamic` with
`num_slots` greater than the model expert count. Backend resolution selects
`MEGAMOE_CUTEDSL` when no concrete backend is requested and rejects an
Expand Down
8 changes: 6 additions & 2 deletions tensorrt_llm/_torch/moe/fused_moe/moe_load_balancer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1268,7 +1268,8 @@ def _create_warmup_placement(
model_config: "ModelConfig", ep_rank: int,
ep_size: int) -> Optional["WarmupPlacementController"]:
"""The controller of ``moe_load_balancer.warmup_placement``, or None when unset."""
from .moe_warmup_placement import (WarmupPlacementController,
from .moe_warmup_placement import (OnlineDriftConfig,
WarmupPlacementController,
register_controller)
settings = model_config.moe_load_balancer.warmup_placement
if settings is None:
Expand All @@ -1278,10 +1279,13 @@ def _create_warmup_placement(
if text_config is None:
text_config = model_config.pretrained_config
num_layers = getattr(text_config, "num_hidden_layers", None)
drift_config = OnlineDriftConfig(step_ema=settings.step_ema,
drift_alpha=settings.drift_alpha)
controller = WarmupPlacementController(settings,
ep_rank=ep_rank,
ep_size=ep_size,
num_target_layers=num_layers)
num_target_layers=num_layers,
drift_config=drift_config)
register_controller(controller)
return controller

Expand Down
Loading
Loading