[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, get_stream,
) )
from sglang.srt.utils import ( from sglang.srt.utils import (
LazyValue,
add_prefix, add_prefix,
is_cuda, is_cuda,
is_non_idle_and_non_empty, is_non_idle_and_non_empty,
@@ -965,12 +966,17 @@ class LLaDA2MoeModelLM(nn.Module):
) )
weight_loader(param, loaded_weight) weight_loader(param, loaded_weight)
self.routed_experts_weights_of_layer = { # Lazy: get_moe_weights() snapshots x.data, and building the map here would
layer_id: layer.mlp.get_moe_weights() # pin every expert weight's pre-process_weights_after_loading storage.
for layer_id, layer in enumerate(self.model.layers) if not hasattr(self, "routed_experts_weights_of_layer"):
if not isinstance(layer, PPMissingLayer) self.routed_experts_weights_of_layer = LazyValue(
and isinstance(layer.mlp, LLaDA2MoeSparseMoeBlock) 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 @classmethod
def get_model_config_for_expert_location(cls, config): def get_model_config_for_expert_location(cls, config):
@@ -1,4 +1,3 @@
import os
import unittest import unittest
from sglang.test.ascend.gsm8k_ascend_mixin import GSM8KAscendMixin from sglang.test.ascend.gsm8k_ascend_mixin import GSM8KAscendMixin
@@ -31,10 +30,6 @@ class TestLLaDA2Mini(GSM8KAscendMixin, CustomTestCase):
"LowConfidence", # TODO: Add dLLM configurations "LowConfidence", # TODO: Add dLLM configurations
"--no-dllm-fdfo", # FDFO (PR #27551) halves single-batch speed on NPU; use sync mode "--no-dllm-fdfo", # FDFO (PR #27551) halves single-batch speed on NPU; use sync mode
] ]
env = {
**os.environ,
"SGLANG_NPU_DISABLE_ACL_FORMAT_WEIGHT": "1", # Need to avoid OOM issue
}
accuracy = 0.88 accuracy = 0.88
output_throughput = 70 output_throughput = 70