HuggingFace镜像/Qwen3-Coder-30B-A3B-Instruct-FP8
模型介绍文件和版本分析
下载使用量0

Qwen3-Coder-30B-A3B-Instruct-FP8

Chat

核心亮点

Qwen3-Coder 提供多种规格版本。今天我们隆重推出 Qwen3-Coder-30B-A3B-Instruct-FP8。这款精简模型在保持卓越性能与效率的同时,具备以下关键升级:

  • 在智能编程代理、浏览器操作代理及其他基础编程任务中展现显著性能优势,位居开源模型前列
  • 具备长上下文处理能力,原生支持 256K tokens,通过 Yarn 技术可扩展至 1M tokens,专为代码库级理解优化
  • 支持智能编程代理功能,兼容Qwen Code、CLINE等主流平台,采用特制的函数调用格式

image/jpeg

模型概览

Qwen3-Coder-30B-A3B-Instruct-FP8 具有以下特性:

  • 模型类型:因果语言模型
  • 训练阶段:预训练与后训练
  • 参数量:总计30.5B,激活参数量3.3B
  • 层数:48
  • 注意力头数(GQA):查询头32个,键值头4个
  • 专家数量:128
  • 激活专家数:8
  • 上下文长度:原生支持 262,144 tokens

注意:本模型仅支持非思考模式,输出中不会生成<think></think>代码块。同时不再需要指定enable_thinking=False参数。

如需了解更多详细信息(包括基准测试评估、硬件要求及推理性能),请参阅我们的博客、GitHub及文档。

快速开始

建议使用最新版本的transformers库。

若使用transformers<4.51.0版本,将会遇到以下错误:

KeyError: 'qwen3_moe'

以下包含一段代码示例,演示如何使用模型根据给定输入生成内容。

from transformers import AutoModelForCausalLM, AutoTokenizer

model_name = "Qwen/Qwen3-Coder-30B-A3B-Instruct-FP8"

# load the tokenizer and the model
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(
    model_name,
    torch_dtype="auto",
    device_map="auto"
)

# prepare the model input
prompt = "Write a quick sort algorithm."
messages = [
    {"role": "user", "content": prompt}
]
text = tokenizer.apply_chat_template(
    messages,
    tokenize=False,
    add_generation_prompt=True,
)
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)

# conduct text completion
generated_ids = model.generate(
    **model_inputs,
    max_new_tokens=65536
)
output_ids = generated_ids[0][len(model_inputs.input_ids[0]):].tolist() 

content = tokenizer.decode(output_ids, skip_special_tokens=True)

print("content:", content)

注意:如果遇到内存不足(OOM)问题,可考虑将上下文长度缩短至较小值,例如32,768。

关于FP8的说明

为兼顾便捷性与性能,我们提供了Qwen3的fp8量化模型检查点,其名称以-FP8结尾。该量化方法采用块大小为128的细粒度fp8量化方案,您可在config.json中的quantization_config字段查看详细信息。

您可使用多种推理框架运行Qwen3-30B-A3B-Instruct-FP8模型(包括transformers、sglang和vllm),其使用方式与原始bfloat16模型一致。 但请注意以下已知问题:

  • transformers:
    • 当前版本对"细粒度fp8"量化方法在分布式推理场景存在兼容性问题。若使用多设备进行推理,可能需要设置环境变量CUDA_LAUNCH_BLOCKING=1。

智能编程助手能力

Qwen3-Coder在工具调用方面表现卓越。

您可参照以下示例轻松定义或使用各类工具。

# Your tool implementation
def square_the_number(num: float) -> dict:
    return num ** 2

# Define Tools
tools=[
    {
        "type":"function",
        "function":{
            "name": "square_the_number",
            "description": "output the square of the number.",
            "parameters": {
                "type": "object",
                "required": ["input_num"],
                "properties": {
                    'input_num': {
                        'type': 'number', 
                        'description': 'input_num is a number that will be squared'
                        }
                },
            }
        }
    }
]

import OpenAI
# Define LLM
client = OpenAI(
    # Use a custom endpoint compatible with OpenAI API
    base_url='http://localhost:8000/v1',  # api_base
    api_key="EMPTY"
)
 
messages = [{'role': 'user', 'content': 'square the number 1024'}]

completion = client.chat.completions.create(
    messages=messages,
    model="Qwen3-Coder-30B-A3B-Instruct-FP8",
    max_tokens=65536,
    tools=tools,
)

print(completion.choice[0])

最佳实践

为获得最佳性能,我们推荐以下设置:

  1. 采样参数:

    • 建议使用 temperature=0.7、top_p=0.8、top_k=20、repetition_penalty=1.05
  2. 适当输出长度:对于大多数查询,推荐使用 65,536 个令牌的输出长度,这对指令模型已足够

引用声明

如果您认为我们的工作对您有帮助,欢迎引用我们的成果。

@misc{qwen3technicalreport,
      title={Qwen3 Technical Report}, 
      author={Qwen Team},
      year={2025},
      eprint={2505.09388},
      archivePrefix={arXiv},
      primaryClass={cs.CL},
      url={https://arxiv.org/abs/2505.09388}, 
}