[NPU] Fix LLaDA2 MoE OOM after the FRACTAL_NZ cast, re-enabling the NZ speedup (#31772)

This commit is contained in:
wenxuewuhd
2026-07-21 16:09:34 +08:00
committed by GitHub
parent 429f6b6d15
commit c0ed009f5b
2 changed files with 12 additions and 11 deletions
+12 -6
View File
@@ -83,6 +83,7 @@ from sglang.srt.runtime_context import (
get_stream,
)
from sglang.srt.utils import (
LazyValue,
add_prefix,
is_cuda,
is_non_idle_and_non_empty,
@@ -965,12 +966,17 @@ class LLaDA2MoeModelLM(nn.Module):
)
weight_loader(param, loaded_weight)
self.routed_experts_weights_of_layer = {
layer_id: layer.mlp.get_moe_weights()
for layer_id, layer in enumerate(self.model.layers)
if not isinstance(layer, PPMissingLayer)
and isinstance(layer.mlp, LLaDA2MoeSparseMoeBlock)
}
# Lazy: get_moe_weights() snapshots x.data, and building the map here would
# pin every expert weight's pre-process_weights_after_loading storage.
if not hasattr(self, "routed_experts_weights_of_layer"):
self.routed_experts_weights_of_layer = LazyValue(
lambda: {
layer_id: layer.mlp.get_moe_weights()
for layer_id, layer in enumerate(self.model.layers)
if not isinstance(layer, PPMissingLayer)
and isinstance(layer.mlp, LLaDA2MoeSparseMoeBlock)
}
)
@classmethod
def get_model_config_for_expert_location(cls, config):