[lora] Fix WAR race: never write MoE runner output into hidden_states in place (#31870)

This commit is contained in:
Sam Shleifer
2026-07-24 00:58:55 -07:00
committed by GitHub
parent d059b0f56e
commit b8bb1b4e5a
2 changed files with 121 additions and 0 deletions
+5
View File
@@ -924,6 +924,11 @@ class FusedMoEWithLoRA(BaseLayerWithLoRA):
self.lora_use_virtual_experts: bool = False
self.quant_method = base_layer.quant_method
self.moe_runner_config = base_layer.moe_runner_config
# Don't let the MoE runner overwrite hidden_states with its output:
# dual-stream forwards (e.g. DeepseekV2MoE.forward_normal_dual_stream)
# read hidden_states for the shared experts on the alt stream, and
# losing that race corrupts long generations.
self.moe_runner_config.inplace = False
self.dispatcher = base_layer.dispatcher
self.num_local_experts = base_layer.num_local_experts
self.should_fuse_routed_scaling_factor_in_topk = (