jiaxwang commited on
Commit
296979a
·
verified ·
1 Parent(s): 2a21ed3

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +46 -10
README.md CHANGED
@@ -35,18 +35,54 @@ The model was quantized from [MiniMaxAI/MiniMax-M3](https://huggingface.co/MiniM
35
 
36
  **Quantization scripts:**
37
  ```
38
- cd Quark/examples/torch/language_modeling/llm_ptq/
39
- exclude_layers="*lm_head *vision_tower* *multi_modal_projector* *patch_merge_mlp* *block_sparse_moe.gate *self_attn* *mlp.gate_proj *mlp.up_proj *mlp.down_proj"
40
- CUDA_VISIBLE_DEVICES=0 python3 quantize_quark.py \
41
- --model_dir MiniMaxAI/MiniMax-M3 \
42
- --quant_scheme mxfp4 \
43
- --exclude_layers $exclude_layers \
44
- --output_dir /mnt/amd/MiniMax-M3-MXFP4 \
45
- --file2file_quantization
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  ```
47
 
48
- For further details or issues, please refer to the AMD-Quark documentation or contact the respective developers.
49
-
50
  # Evaluation
51
  The model was evaluated on gsm8k benchmarks using the vllm framework.
52
 
 
35
 
36
  **Quantization scripts:**
37
  ```
38
+ from quark.torch import LLMTemplate, ModelQuantizer
39
+
40
+ # --- Register template ---
41
+ minimax_m3_vl_template = LLMTemplate(
42
+ model_type="minimax_m3_vl",
43
+ kv_layers_name=["*language_model.*k_proj", "*language_model.*v_proj"],
44
+ q_layer_name="*language_model.*q_proj",
45
+ exclude_layers_name=[
46
+ "*lm_head",
47
+ "*vision_tower*",
48
+ "*multi_modal_projector*",
49
+ "*patch_merge_mlp*",
50
+ "*block_sparse_moe.gate",
51
+ "*self_attn.index_*",
52
+ ],
53
+ )
54
+ LLMTemplate.register_template(minimax_m3_vl_template)
55
+ print(f"[INFO]: Registered template '{minimax_m3_vl_template.model_type}'")
56
+
57
+ # --- Configuration ---
58
+ model_dir = "MiniMaxAI/MiniMax-M3"
59
+ output_dir = "/mnt/amd/MiniMax-M3-MXFP4"
60
+ quant_scheme = "mxfp4"
61
+ exclude_layers = [
62
+ "*lm_head",
63
+ "*vision_tower*",
64
+ "*multi_modal_projector*",
65
+ "*patch_merge_mlp*",
66
+ "*block_sparse_moe.gate",
67
+ "*self_attn*",
68
+ "*mlp.gate_proj",
69
+ "*mlp.up_proj",
70
+ "*mlp.down_proj",
71
+ ]
72
+
73
+ # --- Build quant config from template ---
74
+ template = LLMTemplate.get("minimax_m3_vl")
75
+ quant_config = template.get_config(scheme=quant_scheme, exclude_layers=exclude_layers)
76
+
77
+ # --- File-to-file quantization (memory-efficient, no full model loading) ---
78
+ quantizer = ModelQuantizer(quant_config)
79
+ quantizer.direct_quantize_checkpoint(
80
+ pretrained_model_path=model_dir,
81
+ save_path=output_dir,
82
+ )
83
+ print(f"[INFO]: Quantization complete. Output saved to {output_dir}")
84
  ```
85
 
 
 
86
  # Evaluation
87
  The model was evaluated on gsm8k benchmarks using the vllm framework.
88