Skip to content

Commit d8e8213

Browse files
committed
remove qconfig, fix typo
Signed-off-by: Kyle Sayers <kylesayrs@gmail.com>
1 parent 2b84051 commit d8e8213

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

examples/quantizing_moe/deepseek_r1_example.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from datasets import load_dataset
2-
from transformers import AutoModelForCausalLM, AutoTokenizer
2+
from transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizer
33

44
from llmcompressor.modeling import prepare_for_calibration
55
from llmcompressor.modifiers.quantization import GPTQModifier
@@ -9,7 +9,11 @@
99
# For DeepSeek-R1, we require a full precision model in order to properly calibrate
1010
# `DeepSeek-R1-0528-BF16` is a DeepSeek-V3 FP8 model which has been converted to BF16
1111
model_id = "unsloth/DeepSeek-R1-0528-BF16"
12-
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype="auto")
12+
config = AutoConfig.from_pretrained(model_id)
13+
del config.quantization_config # fp8 qconfig no longer appplies to bf16 model
14+
model = AutoModelForCausalLM.from_pretrained(
15+
model_id, torch_dtype="auto", config=config
16+
)
1317
tokenizer = AutoTokenizer.from_pretrained(model_id)
1418
model = prepare_for_calibration(model)
1519

src/llmcompressor/modeling/prepare.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313

1414
def prepare_for_calibration(model: PreTrainedModel) -> PreTrainedModel:
1515
def replace(module: torch.nn.Module) -> torch.nn.Module:
16-
if module.__class__.__name__ in replacements:
17-
return replacements[module.__class__](module)
16+
cls_name = module.__class__.__name__
17+
if cls_name in replacements:
18+
return replacements[cls_name](module)
1819
else:
1920
return module
2021

0 commit comments

Comments
 (0)