YCWTG commited on
Commit
e51c9a8
·
verified ·
1 Parent(s): 82bbf65

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +143 -95
README.md CHANGED
@@ -1,96 +1,144 @@
1
- base_model:
2
- - Qwen/Qwen3-Coder-Next
3
- pipeline_tag: text-generation
4
- ---
5
- <p align="center">
6
- <img src="https://cdn-uploads.huggingface.co/production/uploads/685e122d50df66f41587d406/XU7ovrDdgsNFAzahuyvI1.png" alt="Tone">
7
- </p>
8
-
9
- 语言 [中文](https://huggingface.co/YCWTG/Qwen3-Coder-Next-int2-AutoRound-best/blob/main/README_zh.md)|English
10
- ## Model Details
11
-
12
- This model is an int2 model with group_size 512 and symmetric quantization of [Qwen/Qwen3-Coder-Next](https://huggingface.co/Qwen/Qwen3-Coder-Next) generated by [intel/auto-round](https://github.com/intel/auto-round). Please follow the license of the original model.
13
-
14
- ### MMLU-Pro
15
-
16
- | Model | Accuracy | Delta |
17
- |-------|----------|-------|
18
- | BF16 | 52.90% | - |
19
- | **W2A16** | **51.27%** | **-1.63%** |
20
-
21
- ## How to Use
22
-
23
- ### HF Usage
24
-
25
- ```python
26
- from transformers import AutoModelForCausalLM, AutoTokenizer
27
-
28
- model_name = "YCWTG/Qwen3-Coder-Next-int2-AutoRound-best"
29
-
30
- # load the tokenizer and the model
31
- tokenizer = AutoTokenizer.from_pretrained(model_name)
32
- model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype="auto", device_map="auto")
33
-
34
- # prepare the model input
35
- prompt = "Write a quick sort algorithm."
36
- messages = [{"role": "user", "content": prompt}]
37
- text = tokenizer.apply_chat_template(
38
- messages,
39
- tokenize=False,
40
- add_generation_prompt=True,
41
- )
42
- model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
43
-
44
- # conduct text completion
45
- generated_ids = model.generate(**model_inputs, max_new_tokens=65536)
46
- output_ids = generated_ids[0][len(model_inputs.input_ids[0]) :].tolist()
47
-
48
- content = tokenizer.decode(output_ids, skip_special_tokens=True)
49
-
50
- print("content:", content)
51
- ```
52
-
53
- ### VLLM Usage
54
-
55
- ```bash
56
- vllm serve YCWTG/Qwen3-Coder-Next-int2-AutoRound-best \
57
- --trust-remote-code \
58
- --dtype bfloat16 \
59
- --tensor_parallel_size 1
60
- ```
61
-
62
- ## Generate the Model
63
-
64
- ```bash
65
- auto-round-best --model Qwen/Qwen3-Coder-Next --scheme "W2A16G32" --format "auto_round"
66
- ```
67
-
68
- ## Ethical Considerations and Limitations
69
-
70
- The model can produce factually incorrect output, and should not be relied on to produce factually accurate information. Because of the limitations of the pretrained model and the finetuning datasets, it is possible that this model could generate lewd, biased or otherwise offensive outputs.
71
- Therefore, before deploying any applications of the model, developers should perform safety testing.
72
-
73
- ## Caveats and Recommendations
74
-
75
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model.
76
- Here are a couple of useful links to learn more about Intel's AI software:
77
-
78
- - [Intel Neural Compressor](https://github.com/intel/neural-compressor)
79
- - [AutoRound](https://github.com/intel/auto-round)
80
-
81
- ## Disclaimer
82
-
83
- The license on this model does not constitute legal advice. We are not responsible for the actions of third parties who use this model. Please consult an attorney before using this model for commercial purposes.
84
-
85
- ## Cite
86
-
87
- ```
88
- @article{cheng2023optimize,
89
- title={Optimize weight rounding via signed gradient descent for the quantization of llms},
90
- author={Cheng, Wenhua and Zhang, Weiwei and Shen, Haihao and Cai, Yiyang and He, Xin and Lv, Kaokao and Liu, Yi},
91
- journal={arXiv preprint arXiv:2309.05516},
92
- year={2023}
93
- }
94
- ```
95
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
  [arxiv](https://arxiv.org/abs/2309.05516) [github](https://github.com/intel/auto-round)## Benchmark Results
 
1
+ ---
2
+ base_model:
3
+ - Qwen/Qwen3-Coder-Next
4
+ tags:
5
+ - qwen3
6
+ - moe
7
+ - int2
8
+ - quantized
9
+ - autoround
10
+ license: apache-2.0
11
+ pipeline_tag: text-generation
12
+ ---
13
+
14
+ <p align="center">
15
+ <img src="https://cdn-uploads.huggingface.co/production/uploads/685e122d50df66f41587d406/XU7ovrDdgsNFAzahuyvI1.png" alt="Tone">
16
+ </p>
17
+
18
+ 语言 [中文](https://huggingface.co/YCWTG/Qwen3-Coder-Next-int2-mixed-AutoRound/blob/main/README_zh.md)|English
19
+ ## Model Details
20
+
21
+ This model is an int2 model with group_size 512 and symmetric quantization of [Qwen/Qwen3-Coder-Next](https://huggingface.co/Qwen/Qwen3-Coder-Next) generated by [intel/auto-round](https://github.com/intel/auto-round). Please follow the license of the original model.
22
+
23
+ ### Quantization Strategy (Intel MoE Recipe)
24
+
25
+ | Layer Type | Bits | Notes |
26
+ |------------|------|-------|
27
+ | Expert layers (512 experts) | 2-bit | MoE expert MLPs |
28
+ | Non-expert layers (attention, gate) | 16-bit | Higher precision for quality |
29
+ | shared_expert_gate | 16-bit | Skipped (shape not divisible by 32) |
30
+ | lm_head | Original | Excluded by AutoRound |
31
+
32
+ ### MMLU-Pro
33
+
34
+ | Model | Accuracy | Delta |
35
+ |-------|----------|-------|
36
+ | BF16 | 52.90% | - |
37
+ | **W2A16** | **51.27%** | **-1.63%** |
38
+
39
+ ## How to Use
40
+
41
+ ### HF Usage
42
+
43
+ ```python
44
+ from transformers import AutoModelForCausalLM, AutoTokenizer
45
+
46
+ model_name = "YCWTG/Qwen3-Coder-Next-int2-AutoRound-best"
47
+
48
+ # load the tokenizer and the model
49
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
50
+ model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype="auto", device_map="auto")
51
+
52
+ # prepare the model input
53
+ prompt = "Write a quick sort algorithm."
54
+ messages = [{"role": "user", "content": prompt}]
55
+ text = tokenizer.apply_chat_template(
56
+ messages,
57
+ tokenize=False,
58
+ add_generation_prompt=True,
59
+ )
60
+ model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
61
+
62
+ # conduct text completion
63
+ generated_ids = model.generate(**model_inputs, max_new_tokens=65536)
64
+ output_ids = generated_ids[0][len(model_inputs.input_ids[0]) :].tolist()
65
+
66
+ content = tokenizer.decode(output_ids, skip_special_tokens=True)
67
+
68
+ print("content:", content)
69
+ ```
70
+
71
+ ```
72
+
73
+ ## Generate the Model
74
+
75
+ ```bash
76
+ from auto_round import AutoRound
77
+
78
+ model_name = "/home/ycwtg/PycharmProjects/MMLU-Pro/~/.cache/model/Qwen3-Coder-Next"
79
+
80
+ # Build layer config for mixed-bits (Intel recipe)
81
+ layer_config = {}
82
+ for i in range(48): # 48 layers
83
+ prefix = f"model.layers.{i}"
84
+
85
+ # Attention layers -> 8-bit
86
+ if i in [3, 7, 11, 15, 19, 23, 27, 31, 35, 39, 43, 47]: # self_attn layers
87
+ for proj in ["q_proj", "k_proj", "v_proj", "o_proj"]:
88
+ layer_config[f"{prefix}.self_attn.{proj}"] = {"bits": 16}
89
+ else: # linear_attn layers
90
+ for proj in ["in_proj_qkvz", "in_proj_ba", "out_proj"]:
91
+ layer_config[f"{prefix}.linear_attn.{proj}"] = {"bits": 16}
92
+
93
+ # MLP gate -> 8-bit
94
+ layer_config[f"{prefix}.mlp.gate"] = {"bits": 16}
95
+
96
+ # shared_expert_gate -> 16-bit (skipped)
97
+ layer_config[f"{prefix}.mlp.shared_expert_gate"] = {"bits": 16}
98
+
99
+ autoround = AutoRound(
100
+ model_name,
101
+ bits=2, # Default for experts
102
+ group_size=128,
103
+ sym=True,
104
+ iters=1000,
105
+ nsamples=512,
106
+ lr=2e-3,
107
+ layer_config=layer_config,
108
+ low_gpu_mem_usage=True,
109
+ enable_alg_ext=True
110
+ )
111
+ output_dir="/home/ycwtg/PycharmProjects/MMLU-Pro/~/.cache/model/Qwen3-Coder-Next-int2-mixed-AutoRound"
112
+ autoround.quantize_and_save(output_dir,format="auto_round" )
113
+
114
+ ```
115
+
116
+ ## Ethical Considerations and Limitations
117
+
118
+ The model can produce factually incorrect output, and should not be relied on to produce factually accurate information. Because of the limitations of the pretrained model and the finetuning datasets, it is possible that this model could generate lewd, biased or otherwise offensive outputs.
119
+ Therefore, before deploying any applications of the model, developers should perform safety testing.
120
+
121
+ ## Caveats and Recommendations
122
+
123
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model.
124
+ Here are a couple of useful links to learn more about Intel's AI software:
125
+
126
+ - [Intel Neural Compressor](https://github.com/intel/neural-compressor)
127
+ - [AutoRound](https://github.com/intel/auto-round)
128
+
129
+ ## Disclaimer
130
+
131
+ The license on this model does not constitute legal advice. We are not responsible for the actions of third parties who use this model. Please consult an attorney before using this model for commercial purposes.
132
+
133
+ ## Cite
134
+
135
+ ```
136
+ @article{cheng2023optimize,
137
+ title={Optimize weight rounding via signed gradient descent for the quantization of llms},
138
+ author={Cheng, Wenhua and Zhang, Weiwei and Shen, Haihao and Cai, Yiyang and He, Xin and Lv, Kaokao and Liu, Yi},
139
+ journal={arXiv preprint arXiv:2309.05516},
140
+ year={2023}
141
+ }
142
+ ```
143
+
144
  [arxiv](https://arxiv.org/abs/2309.05516) [github](https://github.com/intel/auto-round)## Benchmark Results