Skip to content

Commit 5352aa1

Browse files
committed
Add comment explaining in-place add requirement for symmetric memory
1 parent 58dd5f3 commit 5352aa1

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

python/sglang/srt/models/qwen2_moe.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,10 @@ def forward(
324324
final_hidden_states = self._forward_router_experts(hidden_states)
325325

326326
if shared_output is not None:
327+
# In-place add is required to keep final_hidden_states in the
328+
# symmetric memory pool (when --enable-symm-mem is used).
329+
# An out-of-place add would allocate a new tensor outside symm
330+
# memory, breaking subsequent symmetric collective operations.
327331
final_hidden_states += shared_output
328332
if self.tp_size > 1 and not use_reduce_scatter:
329333
final_hidden_states = tensor_model_parallel_all_reduce(final_hidden_states)

0 commit comments

Comments
 (0)