Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions hf_torchao_vllm/quantize_hf_model_with_llm_compressor.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from llmcompressor.modifiers.quantization import QuantizationModifier
from llmcompressor.utils import dispatch_for_generation

import torch
from transformers import AutoModelForCausalLM, AutoTokenizer


Expand All @@ -17,9 +16,7 @@ def run(
assert quant_type in ("fp8", "nvfp4"), "unsupported"

# Load model.
model = AutoModelForCausalLM.from_pretrained(
model_name, torch_dtype=torch.bfloat16
)
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype="auto")
print(model)
tokenizer = AutoTokenizer.from_pretrained(model_name)

Expand All @@ -34,6 +31,16 @@ def run(
"re:.*shared_expert.*",
]
)
elif model_name == "meta-llama/Llama-4-Scout-17B-16E-Instruct":
ignore_list.extend(
[
"re:.*self_attn",
"re:.*router",
"re:.*vision_model.*",
"re:.*multi_modal_projector.*",
"Llama4TextAttention",
]
)

if quant_type == "fp8":
# Configure the quantization algorithm and scheme.
Expand Down