Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
e05ad27
feat: imbalance statistics
Jul 22, 2026
5a02246
feat: remove auto_update_redundancy_expert function
Aug 5, 2026
efeede6
feat: add EPLB
Jul 22, 2026
e6a0719
feat: support eplb for mtp
Sep 2, 2026
14af0f7
perf: use CUDA memcpy for EPLB expert transfers
Sep 4, 2026
5a7440a
refine
Sep 8, 2026
782d526
refactor: drop unused memory profiling reservations
hiworldwzj Sep 17, 2026
33d8db0
refactor: drop unused memory profiling hooks
hiworldwzj Sep 17, 2026
fd9dabe
refactor: derive EPLB enablement from redundant expert count
hiworldwzj Sep 17, 2026
7fa1606
test: require EP mode for EPLB redundancy
hiworldwzj Sep 17, 2026
43db9af
refactor: unify DeepEP expert count management
hiworldwzj Sep 17, 2026
4ffd812
style: restore compact DeepEP size hint call
hiworldwzj Sep 17, 2026
e9c3ba6
refactor: unify EPLB routing across inference modes
hiworldwzj Sep 17, 2026
b5ff3fd
refactor: remove inference phase from expert selection
hiworldwzj Sep 17, 2026
967daad
refactor: separate MoE routing from execution layout
hiworldwzj Sep 17, 2026
47bf4bb
refactor: simplify DeepGEMM MoE routing
hiworldwzj Sep 17, 2026
487e446
refactor: simplify EPLB expert placement metadata
hiworldwzj Sep 17, 2026
11c81b4
style: minimize DeepGEMM formatting diff
hiworldwzj Sep 17, 2026
1265836
refactor(eplb): simplify expert balance metrics
hiworldwzj Sep 17, 2026
7100fdf
refactor(eplb): migrate expert weights through pinned memory
hiworldwzj Sep 17, 2026
495e9b7
refactor(eplb): move lifecycle control into mode backend
hiworldwzj Sep 18, 2026
0c8288f
refactor(eplb): extract extensible placement planner
hiworldwzj Sep 18, 2026
5c86700
fix
hiworldwzj Sep 18, 2026
dc48e82
refactor(eplb): remove planner sample threshold
hiworldwzj Sep 18, 2026
9235c18
fix(moe): restore random routing during autotune warmup
hiworldwzj Sep 18, 2026
99f0550
refactor(eplb): simplify manager state
hiworldwzj Sep 18, 2026
4c5046d
refactor(eplb): simplify expert p2p transfer
hiworldwzj Sep 18, 2026
a0a970b
refactor(eplb): simplify expert transfer planning
hiworldwzj Sep 18, 2026
b133da6
refactor(eplb): unify manager lifecycle step
hiworldwzj Sep 18, 2026
dd9ccb3
refactor(eplb): drive manager with explicit state machine
hiworldwzj Sep 18, 2026
2a6689d
refactor(eplb): scope runtime state to lifecycle phases
hiworldwzj Sep 18, 2026
a3e055f
refactor(eplb): keep state transitions in step handlers
hiworldwzj Sep 18, 2026
b32ac32
refactor(eplb): simplify manager state transitions
hiworldwzj Sep 18, 2026
1990124
refactor(eplb): separate evaluation and planning phases
hiworldwzj Sep 18, 2026
bc73bcd
refactor(eplb): isolate asynchronous planning task
hiworldwzj Sep 18, 2026
81bb2fc
refactor EPLB planning and transfer lifecycle
hiworldwzj Sep 18, 2026
facf59c
refine EPLB batched transfer scheduling
hiworldwzj Sep 18, 2026
5b52214
simplify EPLB transfer batch flow
hiworldwzj Sep 18, 2026
7b1091b
standardize EPLB full expert placements
hiworldwzj Sep 18, 2026
901e531
simplify EPLB greedy placement planning
hiworldwzj Sep 18, 2026
7a8fee4
reset EPLB route counters across placements
hiworldwzj Sep 18, 2026
d89024d
refine EPLB placement and transfer planning
hiworldwzj Sep 20, 2026
1f6f475
simplify EPLB runtime and transfer polling
hiworldwzj Sep 20, 2026
f958ade
add EPLB rebalance count control
hiworldwzj Sep 21, 2026
a0dd26e
keep reporting EPLB load after rebalancing
hiworldwzj Sep 21, 2026
60df608
clarify EPLB manager control flow
hiworldwzj Sep 21, 2026
a452432
plan EPLB transfers asynchronously
hiworldwzj Sep 21, 2026
b85aa74
group EPLB runtime modules into package
hiworldwzj Sep 21, 2026
20f924a
move EPLB placement and planner into runtime package
hiworldwzj Sep 21, 2026
691d445
clarify EPLB runtime module names
hiworldwzj Sep 21, 2026
b81ccbb
commit EPLB updates on overlap stream
hiworldwzj Sep 21, 2026
89b4474
remove unused EPLB layer map helper
hiworldwzj Sep 21, 2026
d7a510c
refactor(eplb): organize placement modules
hiworldwzj Sep 21, 2026
ae80f60
fix(eplb): reject redundant experts with RL
hiworldwzj Sep 21, 2026
8ddb29b
refactor(eplb): move weight utilities into runtime package
hiworldwzj Sep 21, 2026
e3316cc
fix(eplb): validate SM100 support in runtime manager
hiworldwzj Sep 21, 2026
6da8cca
feat: persist EPLB placement configuration
hiworldwzj Sep 21, 2026
1b1bdc5
refactor(eplb): carry source slot in transfer info
hiworldwzj Sep 21, 2026
942e0b5
feat(eplb): add topology-aware expert dispatch modes
hiworldwzj Sep 21, 2026
afbe8df
fix(eplb): improve replica hash distribution
hiworldwzj Sep 21, 2026
d20f3f0
refactor(eplb): simplify MoE weight discovery
hiworldwzj Sep 21, 2026
4e774e7
feat(eplb): support configurable placement planners
hiworldwzj Sep 21, 2026
2680dec
docs(eplb): add Chinese implementation guide
hiworldwzj Sep 21, 2026
3ac7954
fix
hiworldwzj Sep 22, 2026
eb61641
fix
hiworldwzj Sep 22, 2026
cb10850
fix
hiworldwzj Sep 24, 2026
8493571
refactor(eplb): record per-prefill route samples
hiworldwzj Sep 26, 2026
b3beb21
feat(eplb): report placement imbalance metrics
hiworldwzj Sep 26, 2026
b94fd18
refactor(eplb): simplify async task statuses
hiworldwzj Sep 26, 2026
5924509
refactor(eplb): unify async task lifecycle
hiworldwzj Sep 26, 2026
3fa9b50
feat(eplb): gather raw load samples asynchronously
hiworldwzj Sep 27, 2026
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
546 changes: 546 additions & 0 deletions docs/CN/source/framework/eplb.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/CN/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ Lightllm 整合了众多的开源方案的优点,包括但不限于 FasterTran
架构介绍 <framework/framework>
token attention介绍 <framework/token_attention>
峰值显存调度器介绍 <framework/router>
EPLB 专家负载均衡实现 <framework/eplb>

.. Indices and tables
.. ==================
Expand Down
71 changes: 60 additions & 11 deletions docs/CN/source/tutorial/api_server_args.rst
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,66 @@ PD 分离模式参数

使用 tgi 输入和输出格式

专家并行与 EPLB 参数
--------------------

.. option:: --enable_ep_moe

为支持的 MoE 模型启用专家并行。使用 EPLB 时必须开启此参数。

.. option:: --eplb_num_redundant_experts_per_rank

每个 MoE 层在每个 EP rank 上分配的冗余物理专家数量,默认值为 ``0``,表示关闭 EPLB。
设置为正数时启用 EPLB,并且必须同时设置 ``--enable_ep_moe``;负数会在启动阶段被拒绝。

每个 rank 会额外分配指定数量的专家权重行。EPLB 将逻辑专家映射到主副本或冗余物理副本,
统计路由负载,并可在线迁移冗余副本以改善专家负载均衡。增大此值可以提供更多布局选择,
但也会占用更多 GPU 显存并增加专家迁移流量。

EPLB 当前不能与 ``--enable_prefill_cudagraph`` 同时使用,也不支持 SM100 GPU。
同一部署中的所有 rank 和节点必须使用相同的配置值。

.. option:: --eplb_plan_mode

EPLB 动态重排使用的专家布局规划算法,默认值为 ``greedy``。当前支持:

* ``greedy``:根据各层逻辑专家的全局路由负载生成近似均衡的完整布局,
并尽量复用当前 rank 和物理槽位以减少专家迁移。

此参数只选择布局规划算法,不改变 token 到已有专家副本的运行时分发策略。
同一个 EP 通信组内的所有 rank 必须使用相同的值。PD 分离部署中的 prefill
和 decode 进程拥有各自独立的 EPLB manager,因此可以分别设置适合各自流量
特征的规划算法;非 PD 部署则使用一个算法处理该进程采集到的全部路由负载。

.. option:: --eplb_rebalance_count

动态 EPLB 最多成功执行的重排次数,默认值为 ``1``。只有新布局实际发生
专家权重迁移并完成提交后才计数;样本不足或规划布局不变不会消耗次数。

* ``-1``:不限制次数,持续进行动态重排;
* ``0``:不进行动态重排,仅使用初始化时的冗余布局;
* 正整数:完成指定次数的重排后停止规划。

.. option:: --eplb_config_path

EPLB 布局 JSON 文件路径,默认值为 ``None``。指定后,LightLLM 会在初始化专家权重之前校验并
读取各层保存的布局,使服务启动后立即使用上一次优化得到的专家分配。同一个文件也作为输出:
每次成功完成动态重排后,rank 0 会写回当前最新布局。

如果文件不存在、JSON 无法解析、缺少模型层,或保存的专家拓扑与当前部署不匹配,LightLLM 会
记录 warning,并对受影响的层使用默认初始化布局。只有后续动态重排成功完成时,rank 0 才会把
新布局写入该路径。

以下示例为每个 EP rank 配置两个冗余专家::

python -m lightllm.server.api_server \
--model_dir /path/to/model \
--enable_ep_moe \
--eplb_num_redundant_experts_per_rank 2 \
--eplb_plan_mode greedy \
--eplb_rebalance_count 1 \
--eplb_config_path /path/to/eplb-placement.json

MTP 多预测参数
--------------

Expand Down Expand Up @@ -732,17 +792,6 @@ MTP 多预测参数
增加此值允许更多预测,但确保模型与指定的步数兼容。
目前 deepseekv3/r1 模型仅支持 1 步

DeepSeek 冗余专家参数
---------------------

.. option:: --ep_redundancy_expert_config_path

冗余专家配置的路径。可用于 deepseekv3 模型。

.. option:: --auto_update_redundancy_expert

是否通过在线专家使用计数器为 deepseekv3 模型更新冗余专家。

监控和日志参数
--------------

Expand Down
76 changes: 65 additions & 11 deletions docs/EN/source/tutorial/api_server_args.rst
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,71 @@ Sampling and Generation Parameters

Use tgi input and output format

Expert Parallelism and EPLB Parameters
--------------------------------------

.. option:: --enable_ep_moe

Enable expert parallelism for supported MoE models. EPLB requires this option.

.. option:: --eplb_num_redundant_experts_per_rank

Number of redundant physical experts allocated on each EP rank for every MoE layer. The default is ``0``,
which disables EPLB. A positive value enables EPLB and must be used together with ``--enable_ep_moe``;
negative values are rejected during startup.

Each rank allocates the configured number of additional expert weight rows. EPLB maps logical experts to
primary or redundant physical copies, records routing load, and can migrate redundant copies online to
improve expert load balance. Larger values provide more placement flexibility but consume more GPU memory
and increase expert migration traffic.

EPLB currently cannot be combined with ``--enable_prefill_cudagraph`` and is not supported on SM100 GPUs.
Use the same value on every rank and node in one deployment.

.. option:: --eplb_plan_mode

Expert placement planning algorithm used for dynamic EPLB rebalances. The default is ``greedy``. The
currently supported value is:

* ``greedy``: builds an approximately balanced full placement from the global logical-expert load of each
layer and attempts to reuse the current ranks and physical slots to reduce expert migration.

This option selects the placement planner; it does not change how tokens are dispatched among replicas in
an existing placement. Every rank in one EP communication group must use the same value. Prefill and decode
processes in a PD-disaggregated deployment have independent EPLB managers and may select planners suited to
their respective traffic. A non-PD process uses one planner for all routing load collected by that process.

.. option:: --eplb_rebalance_count

Maximum number of successfully completed dynamic EPLB rebalances. The default is ``1``. A count is consumed
only after a new placement has transferred and committed its expert weights; insufficient samples and unchanged
placements do not consume the limit.

* ``-1`` keeps dynamic rebalancing enabled indefinitely.
* ``0`` disables dynamic rebalancing, leaving only the initial redundant placement active.
* A positive value stops planning after that many completed rebalances.

.. option:: --eplb_config_path

Path to an EPLB placement JSON file. The default is ``None``. When specified, LightLLM validates and loads
the saved per-layer placement before expert weights are initialized, so the service starts directly with the
previous optimized layout. The same file is updated with the latest layout after every successfully completed
rebalance.

If the file does not exist, cannot be decoded, is missing a model layer, or does not match the current expert
topology, LightLLM logs a warning and uses the default initial placement for the affected layer. Rank 0 writes
a new layout to this path only after a dynamic rebalance completes successfully.

Example: enable EPLB with two redundant experts per EP rank::

python -m lightllm.server.api_server \
--model_dir /path/to/model \
--enable_ep_moe \
--eplb_num_redundant_experts_per_rank 2 \
--eplb_plan_mode greedy \
--eplb_rebalance_count 1 \
--eplb_config_path /path/to/eplb-placement.json

MTP Multi-Prediction Parameters
-------------------------------

Expand Down Expand Up @@ -748,17 +813,6 @@ MTP Multi-Prediction Parameters
Increasing this value allows more predictions, but ensure the model is compatible with the specified number of steps.
Currently deepseekv3/r1 models only support 1 step

DeepSeek Redundant Expert Parameters
------------------------------------

.. option:: --ep_redundancy_expert_config_path

Path to redundant expert configuration. Can be used for deepseekv3 models.

.. option:: --auto_update_redundancy_expert

Whether to update redundant experts for deepseekv3 models through online expert usage counters.

Monitoring and Logging Parameters
---------------------------------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ def custom_del(self: torch.Tensor):
if hasattr(self, "storage_weak_ptr"):
storage_weak_ptr = self.storage_weak_ptr
else:
storage_weak_ptr = self.untyped_storage()._weak_ref()
try:
storage_weak_ptr = self.untyped_storage()._weak_ref()
except RuntimeError:
# Some tensor implementations, including UndefinedTensorImpl,
# have no backing storage. Their destructor must stay silent.
return
UntypedStorage._free_weak_ref(storage_weak_ptr)
if storage_weak_ptr in g_cache_manager.ptr_to_bufnode:
g_cache_manager.changed_ptr.add(storage_weak_ptr)
Expand Down

This file was deleted.

Loading
Loading