littlebird13 commited on
Commit
fd8eeb8
·
verified ·
1 Parent(s): d8df4ca

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +174 -3
README.md CHANGED
@@ -1,3 +1,174 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: transformers
3
+ license: apache-2.0
4
+ license_link: https://huggingface.co/Qwen/Qwen3-Coder-30B-A3B-Instruct-FP8/blob/main/LICENSE
5
+ pipeline_tag: text-generation
6
+ ---
7
+
8
+ # Qwen3-Coder-3B-A3B-Instruct-FP8
9
+ <a href="https://chat.qwen.ai/" target="_blank" style="margin: 2px;">
10
+ <img alt="Chat" src="https://img.shields.io/badge/%F0%9F%92%9C%EF%B8%8F%20Qwen%20Chat%20-536af5" style="display: inline-block; vertical-align: middle;"/>
11
+ </a>
12
+
13
+ ## Highlights
14
+
15
+ **Qwen3-Coder** is available in multiple sizes, but we're excited to introduce **Qwen3-Coder-30B-A3B-Instruct**. featuring the following key enhancements:
16
+
17
+ - **Significant Performance** among open models on **Agentic Coding**, **Agentic Browser-Use**, and other foundational coding tasks.
18
+ - **Long-context Capabilities** with native support for **256K** tokens, extendable up to **1M** tokens using Yarn, optimized for repository-scale understanding.
19
+ - **Agentic Coding** supporting for most platform such as **Qwen Code**, **CLINE**, featuring a specially designed function call format.
20
+
21
+ ![image/jpeg](placeholder of Qwen3-Coder-30B-A3B-Instruct performance image )
22
+
23
+ ## Model Overview
24
+
25
+ **Qwen3-Coder-30B-A3B-Instruct-FP8** has the following features:
26
+ - Type: Causal Language Models
27
+ - Training Stage: Pretraining & Post-training
28
+ - Number of Parameters: 30.5B in total and 3.3B activated
29
+ - Number of Layers: 48
30
+ - Number of Attention Heads (GQA): 32 for Q and 4 for KV
31
+ - Number of Experts: 128
32
+ - Number of Activated Experts: 8
33
+ - Context Length: **262,144 natively**.
34
+
35
+ **NOTE: This model supports only non-thinking mode and does not generate ``<think></think>`` blocks in its output. Meanwhile, specifying `enable_thinking=False` is no longer required.**
36
+
37
+ For more details, including benchmark evaluation, hardware requirements, and inference performance, please refer to our [blog](https://qwenlm.github.io/blog/qwen3-coder/), [GitHub](https://github.com/QwenLM/Qwen3-Coder), and [Documentation](https://qwen.readthedocs.io/en/latest/).
38
+
39
+
40
+ ## Quickstart
41
+
42
+ We advise you to use the latest version of `transformers`.
43
+
44
+ With `transformers<4.51.0`, you will encounter the following error:
45
+ ```
46
+ KeyError: 'qwen3_moe'
47
+ ```
48
+
49
+ The following contains a code snippet illustrating how to use the model generate content based on given inputs.
50
+ ```python
51
+ from transformers import AutoModelForCausalLM, AutoTokenizer
52
+
53
+ model_name = "Qwen/Qwen3-Coder-30B-A3B-Instruct-FP8"
54
+
55
+ # load the tokenizer and the model
56
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
57
+ model = AutoModelForCausalLM.from_pretrained(
58
+ model_name,
59
+ torch_dtype="auto",
60
+ device_map="auto"
61
+ )
62
+
63
+ # prepare the model input
64
+ prompt = "Write a quick sort algorithm."
65
+ messages = [
66
+ {"role": "user", "content": prompt}
67
+ ]
68
+ text = tokenizer.apply_chat_template(
69
+ messages,
70
+ tokenize=False,
71
+ add_generation_prompt=True,
72
+ )
73
+ model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
74
+
75
+ # conduct text completion
76
+ generated_ids = model.generate(
77
+ **model_inputs,
78
+ max_new_tokens=65536
79
+ )
80
+ output_ids = generated_ids[0][len(model_inputs.input_ids[0]):].tolist()
81
+
82
+ content = tokenizer.decode(output_ids, skip_special_tokens=True)
83
+
84
+ print("content:", content)
85
+ ```
86
+
87
+ **Note: If you encounter out-of-memory (OOM) issues, consider reducing the context length to a shorter value, such as `32,768`.**
88
+
89
+ ## Note on FP8
90
+
91
+ For convenience and performance, we have provided `fp8`-quantized model checkpoint for Qwen3, whose name ends with `-FP8`. The quantization method is fine-grained `fp8` quantization with block size of 128. You can find more details in the `quantization_config` field in `config.json`.
92
+
93
+ You can use the Qwen3-30B-A3B-Instruct-FP8 model with serveral inference frameworks, including `transformers`, `sglang`, and `vllm`, as the original bfloat16 model.
94
+ However, please pay attention to the following known issues:
95
+ - `transformers`:
96
+ - there are currently issues with the "fine-grained fp8" method in `transformers` for distributed inference. You may need to set the environment variable `CUDA_LAUNCH_BLOCKING=1` if multiple devices are used in inference.
97
+
98
+
99
+ ## Agentic Coding
100
+
101
+ Qwen3-Coder excels in tool calling capabilities.
102
+
103
+ You can simply define or use any tools as following example.
104
+ ```python
105
+ # Your tool implementation
106
+ def square_the_number(num: float) -> dict:
107
+ return num ** 2
108
+
109
+ # Define Tools
110
+ tools=[
111
+ {
112
+ "type":"function",
113
+ "function":{
114
+ "name": "square_the_number",
115
+ "description": "output the square of the number.",
116
+ "parameters": {
117
+ "type": "object",
118
+ "required": ["input_num"],
119
+ "properties": {
120
+ 'input_num': {
121
+ 'type': 'number',
122
+ 'description': 'input_num is a number that will be squared'
123
+ }
124
+ },
125
+ }
126
+ }
127
+ }
128
+ ]
129
+
130
+ import OpenAI
131
+ # Define LLM
132
+ client = OpenAI(
133
+ # Use a custom endpoint compatible with OpenAI API
134
+ base_url='http://localhost:8000/v1', # api_base
135
+ api_key="EMPTY"
136
+ )
137
+
138
+ messages = [{'role': 'user', 'content': 'square the number 1024'}]
139
+
140
+ completion = client.chat.completions.create(
141
+ messages=messages,
142
+ model="Qwen3-Coder-30B-A3B-Instruct-FP8",
143
+ max_tokens=65536,
144
+ tools=tools,
145
+ )
146
+
147
+ print(completion.choice[0])
148
+ ```
149
+
150
+ ## Best Practices
151
+
152
+ To achieve optimal performance, we recommend the following settings:
153
+
154
+ 1. **Sampling Parameters**:
155
+ - We suggest using `temperature=0.7`, `top_p=0.8`, `top_k=20`, `repetition_penalty=1.05`.
156
+
157
+ 2. **Adequate Output Length**: We recommend using an output length of 65,536 tokens for most queries, which is adequate for instruct models.
158
+
159
+
160
+ ### Citation
161
+
162
+ If you find our work helpful, feel free to give us a cite.
163
+
164
+ ```
165
+ @misc{qwen3technicalreport,
166
+ title={Qwen3 Technical Report},
167
+ author={Qwen Team},
168
+ year={2025},
169
+ eprint={2505.09388},
170
+ archivePrefix={arXiv},
171
+ primaryClass={cs.CL},
172
+ url={https://arxiv.org/abs/2505.09388},
173
+ }
174
+ ```