Skip to content

Commit ea93089

Browse files
committed
PR comments
1 parent a7af9ca commit ea93089

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

src/llmcompressor/modeling/prepare.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def replace_modules_for_calibration(model: PreTrainedModel) -> PreTrainedModel:
2929

3030

3131
def update_qwen3_moe(model, stack):
32-
for _, module in model.named_modules():
32+
for module in model.modules():
3333
cls_name = module.__class__.__name__
3434
if cls_name == "Qwen3MoeDecoderLayer":
3535
stack.enter_context(
@@ -38,7 +38,7 @@ def update_qwen3_moe(model, stack):
3838

3939

4040
def update_deepseek3_moe(model, stack):
41-
for _, module in model.named_modules():
41+
for module in model.modules():
4242
cls_name = module.__class__.__name__
4343
if (
4444
cls_name == "DeepseekV3DecoderLayer"
@@ -55,6 +55,8 @@ def update_deepseek3_moe(model, stack):
5555
}
5656

5757
def moe_calibration_context(model: PreTrainedModel, stack):
58+
# Temporarily updates the MoE modules within the context
59+
# Once the context exists, parameter updates persist
5860
cls_name = model.__class__.__name__
5961
if cls_name in moe_context:
6062
moe_context.get(cls_name)(model, stack)

src/llmcompressor/modeling/qwen3_moe.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
# coding=utf-8
2+
# Copyright 2025 The Qwen team, Alibaba Group and the HuggingFace Inc. team.
3+
# All rights reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
117
import torch
218

319

0 commit comments

Comments
 (0)