Views
No views yet
import os
from quark.torch import LLMTemplate, ModelQuantizer
# Configuration
ckpt_path = "Qwen/Qwen3.5-397B-A17B-FP8"
output_dir = "amd/Qwen3.5-397B-A17B-MoE-MXFP4"
quant_scheme = "mxfp4"
# NOTE: shared expert is NOT excluded here, so it is quantized to MXFP4 as well.
exclude_layers = ["lm_head", "model.visual.*", "mtp.*", "*mlp.gate", "*shared_expert_gate*", "*.linear_attn.*", "*.self_attn.*"]
# Get quant config from template
template = LLMTemplate.get("qwen3_5_moe")
quant_config = template.get_config(scheme=quant_scheme, exclude_layers=exclude_layers)
# Quantize with file-to-file mode
quantizer = ModelQuantizer(quant_config)
quantizer.direct_quantize_checkpoint(
pretrained_model_path=ckpt_path,
save_path=output_dir,
)local-chat-completions with the chat template applied, 5-shot, greedy). The baseline is the
original Qwen/Qwen3.5-397B-A17B-FP8 checkpoint,
evaluated with the identical recipe on SGLang.| Benchmark | Qwen/Qwen3.5-397B-A17B-FP8 | amd/Qwen3.5-397B-A17B-MoE-MXFP4 (this model) | Recovery |
|---|---|---|---|
| gsm8k (flexible-extract, 5-shot) | 97.95 | 97.27 | 99.31% |
lm-eval recipe.python3 -m sglang.launch_server \
--model-path amd/Qwen3.5-397B-A17B-MoE-MXFP4 \
--tensor-parallel-size 4 \
--trust-remote-code \
--attention-backend aiter \
--mem-fraction-static 0.8 \
--host 0.0.0.0 --port 30000gsm8k.yaml, whose only change vs. the stock
lm-eval task is a doc_to_text that asks the model to end its response with #### <number> so the
reasoning model's final answer is parsed correctly:lm_eval --model local-chat-completions --apply_chat_template \
--tasks gsm8k.yaml \
--num_fewshot 5 \
--model_args "model=amd/Qwen3.5-397B-A17B-MoE-MXFP4,base_url=http://127.0.0.1:30000/v1/chat/completions,num_concurrent=64,tokenized_requests=False,max_length=16384" \
--gen_kwargs "max_tokens=12288,temperature=0,top_p=1"