Views
No views yet
<|im_start|>system
{system_prompt}<|im_end|>
<|im_start|>user
{prompt}<|im_end|>
<|im_start|>assistant| Name | Quant method | Bits | Size | Max RAM required | Use case |
|---|---|---|---|---|---|
| Qwen3-Coder-30B-A3B-Instruct.IQ1_S.gguf (with YaRN) | IQ1_S | 1 | 6.4 GB | 6.7 GB | smallest, significant quality loss |
| Qwen3-Coder-30B-A3B-Instruct.IQ1_M.gguf (with YaRN) | IQ1_M | 1 | 7.0 GB | 7.3 GB | very small, significant quality loss |
| Qwen3-Coder-30B-A3B-Instruct.IQ2_XXS.gguf (with YaRN) | IQ2_XXS | 2 | 8.0 GB | 8.3 GB | very small, high quality loss |
| Qwen3-Coder-30B-A3B-Instruct.IQ2_XS.gguf (with YaRN) | IQ2_XS | 2 | 8.8 GB | 9.0 GB | very small, high quality loss |
| Qwen3-Coder-30B-A3B-Instruct.IQ2_S.gguf (with YaRN) | IQ2_S | 2 | 9.0 GB | 9.3 GB | small, substantial quality loss |
| Qwen3-Coder-30B-A3B-Instruct.IQ2_M.gguf (with YaRN) | IQ2_M | 2 | 9.8 GB | 10.0 GB | small, greater quality loss |
| Qwen3-Coder-30B-A3B-Instruct.IQ3_XXS.gguf (with YaRN) | IQ3_XXS | 3 | 11.4 GB | 11.7 GB | very small, high quality loss |
| Qwen3-Coder-30B-A3B-Instruct.IQ3_XS.gguf (with YaRN) | IQ3_XS | 3 | 12.0 GB | 12.3 GB | small, substantial quality loss |
| Qwen3-Coder-30B-A3B-Instruct.IQ3_S.gguf (with YaRN) | IQ3_S | 3 | 12.7 GB | 13.0 GB | small, greater quality loss |
| Qwen3-Coder-30B-A3B-Instruct.IQ3_M.gguf (with YaRN) | IQ3_M | 3 | 12.9 GB | 13.2 GB | medium, balanced quality |
| Qwen3-Coder-30B-A3B-Instruct.IQ4_XS.gguf (with YaRN) | IQ4_XS | 4 | 15.5 GB | 15.8 GB | small, marginal quality loss - recommended |
llama.cpp commandllama.cpp from commit d3bd719 or later../llama-cli -ngl 49 -m Qwen3-Coder-30B-A3B-Instruct.IQ4_XS.gguf --color -c 262144 --temp 0.7 --top-p 0.8 --top-k 20 --repeat-penalty 1.05 --jinja-ngl 49 to the number of layers to offload to GPU. Remove it if you don't have GPU acceleration.-c 262144 to the desired sequence length.-ctk q8_0 or even -ctk q4_0 for big memory savings (depending on context size).
There is a similar option for V-cache (-ctv), only available if you enable Flash Attention (-fa) as well.1# Prebuilt wheel with basic CPU support
2pip install llama-cpp-python --extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cpu
3# Prebuilt wheel with NVidia CUDA acceleration
4pip install llama-cpp-python --extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cu121 (or cu122 etc.)
5# Prebuilt wheel with Metal GPU acceleration
6pip install llama-cpp-python --extra-index-url https://abetlen.github.io/llama-cpp-python/whl/metal
7# Build base version with no GPU acceleration
8pip install llama-cpp-python
9# With NVidia CUDA acceleration
10CMAKE_ARGS="-DGGML_CUDA=on" pip install llama-cpp-python
11# Or with OpenBLAS acceleration
12CMAKE_ARGS="-DGGML_BLAS=ON -DGGML_BLAS_VENDOR=OpenBLAS" pip install llama-cpp-python
13# Or with AMD ROCm GPU acceleration (Linux only)
14CMAKE_ARGS="-DGGML_HIPBLAS=on" pip install llama-cpp-python
15# Or with Metal GPU acceleration for macOS systems only
16CMAKE_ARGS="-DGGML_METAL=on" pip install llama-cpp-python
17# Or with Vulkan acceleration
18CMAKE_ARGS="-DGGML_VULKAN=on" pip install llama-cpp-python
19# Or with SYCL acceleration
20CMAKE_ARGS="-DGGML_SYCL=on -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx" pip install llama-cpp-python
21
22# In windows, to set the variables CMAKE_ARGS in PowerShell, follow this format; eg for NVidia CUDA:
23$env:CMAKE_ARGS = "-DGGML_CUDA=on"
24pip install llama-cpp-python1from llama_cpp import Llama
2
3# Chat Completion API
4
5llm = Llama(model_path="./Qwen3-Coder-30B-A3B-Instruct.IQ4_XS.gguf", n_gpu_layers=49, n_ctx=262144)
6print(llm.create_chat_completion(
7 repeat_penalty = 1.05,
8 messages = [
9 {
10 "role": "user",
11 "content": "Pick a LeetCode challenge and solve it in Python."
12 }
13 ]
14))1from llama_cpp import Llama
2
3# Completion API
4
5prompt = "def add("
6suffix = "\n return sum\n\n"
7
8llm = Llama(model_path="./Qwen3-Coder-30B-A3B-Instruct.IQ4_XS.gguf", n_gpu_layers=49, n_ctx=262144)
9output = llm.create_completion(
10 temperature = 0.0,
11 repeat_penalty = 1.0,
12 prompt = prompt,
13 suffix = suffix
14)
15
16# Models sometimes repeat suffix in response, attempt to filter that
17response = output["choices"][0]["text"]
18response_stripped = response.rstrip()
19unwanted_response_suffix = suffix.rstrip()
20unwanted_response_length = len(unwanted_response_suffix)
21
22filtered = False
23if unwanted_response_suffix and response_stripped[-unwanted_response_length:] == unwanted_response_suffix:
24 response = response_stripped[:-unwanted_response_length]
25 filtered = True
26
27print(f"Fill-in-Middle completion{' (filtered)' if filtered else ''}:\n\n{prompt}\033[32m{response}\033[{'33' if filtered else '0'}m{suffix}\033[0m")1from llama_cpp import Llama
2
3# Chat Completion API
4
5grammar = LlamaGrammar.from_json_schema(json.dumps({
6 "type": "array",
7 "items": {
8 "type": "object",
9 "required": [ "name", "arguments" ],
10 "properties": {
11 "name": {
12 "type": "string"
13 },
14 "arguments": {
15 "type": "object"
16 }
17 }
18 }
19}))
20
21llm = Llama(model_path="./Qwen3-Coder-30B-A3B-Instruct.IQ4_XS.gguf", n_gpu_layers=49, n_ctx=262144)
22response = llm.create_chat_completion(
23 temperature = 0.0,
24 repeat_penalty = 1.05,
25 messages = [
26 {
27 "role": "user",
28 "content": "What's the weather like in Oslo and Stockholm?"
29 }
30 ],
31 tools=[{
32 "type": "function",
33 "function": {
34 "name": "get_current_weather",
35 "description": "Get the current weather in a given location",
36 "parameters": {
37 "type": "object",
38 "properties": {
39 "location": {
40 "type": "string",
41 "description": "The city and state, e.g. San Francisco, CA"
42 },
43 "unit": {
44 "type": "string",
45 "enum": [ "celsius", "fahrenheit" ]
46 }
47 },
48 "required": [ "location" ]
49 }
50 }
51 }],
52 grammar = grammar
53)
54print(json.loads(response["choices"][0]["text"]))
55
56print(llm.create_chat_completion(
57 temperature = 0.0,
58 repeat_penalty = 1.05,
59 messages = [
60 {
61 "role": "user",
62 "content": "What's the weather like in Oslo?"
63 },
64 { # The tool_calls is from the response to the above with tool_choice active
65 "role": "assistant",
66 "content": None,
67 "tool_calls": [
68 {
69 "id": "call__0_get_current_weather_cmpl-...",
70 "type": "function",
71 "function": {
72 "name": "get_current_weather",
73 "arguments": { "location": "Oslo, Norway" , "unit": "celsius" }
74 }
75 }
76 ]
77 },
78 { # The tool_call_id is from tool_calls and content is the result from the function call you made
79 "role": "tool",
80 "content": "20",
81 "tool_call_id": "call__0_get_current_weather_cmpl-..."
82 }
83 ],
84 tools=[{
85 "type": "function",
86 "function": {
87 "name": "get_current_weather",
88 "description": "Get the current weather in a given location",
89 "parameters": {
90 "type": "object",
91 "properties": {
92 "location": {
93 "type": "string",
94 "description": "The city and state, e.g. San Francisco, CA"
95 },
96 "unit": {
97 "type": "string",
98 "enum": [ "celsius", "fahrenheit" ]
99 }
100 },
101 "required": [ "location" ]
102 }
103 }
104 }],
105 #tool_choice={
106 # "type": "function",
107 # "function": {
108 # "name": "get_current_weather"
109 # }
110 #}
111))
<think></think> blocks in its output. Meanwhile, specifying enable_thinking=False is no longer required.transformers.transformers<4.51.0, you will encounter the following error:KeyError: 'qwen3_moe'1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3model_name = "Qwen/Qwen3-Coder-30B-A3B-Instruct"
4
5# load the tokenizer and the model
6tokenizer = AutoTokenizer.from_pretrained(model_name)
7model = AutoModelForCausalLM.from_pretrained(
8 model_name,
9 torch_dtype="auto",
10 device_map="auto"
11)
12
13# prepare the model input
14prompt = "Write a quick sort algorithm."
15messages = [
16 {"role": "user", "content": prompt}
17]
18text = tokenizer.apply_chat_template(
19 messages,
20 tokenize=False,
21 add_generation_prompt=True,
22)
23model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
24
25# conduct text completion
26generated_ids = model.generate(
27 **model_inputs,
28 max_new_tokens=65536
29)
30output_ids = generated_ids[0][len(model_inputs.input_ids[0]):].tolist()
31
32content = tokenizer.decode(output_ids, skip_special_tokens=True)
33
34print("content:", content)32,768.1# Your tool implementation
2def square_the_number(num: float) -> dict:
3 return num ** 2
4
5# Define Tools
6tools=[
7 {
8 "type":"function",
9 "function":{
10 "name": "square_the_number",
11 "description": "output the square of the number.",
12 "parameters": {
13 "type": "object",
14 "required": ["input_num"],
15 "properties": {
16 'input_num': {
17 'type': 'number',
18 'description': 'input_num is a number that will be squared'
19 }
20 },
21 }
22 }
23 }
24]
25
26import OpenAI
27# Define LLM
28client = OpenAI(
29 # Use a custom endpoint compatible with OpenAI API
30 base_url='http://localhost:8000/v1', # api_base
31 api_key="EMPTY"
32)
33
34messages = [{'role': 'user', 'content': 'square the number 1024'}]
35
36completion = client.chat.completions.create(
37 messages=messages,
38 model="Qwen3-Coder-30B-A3B-Instruct",
39 max_tokens=65536,
40 tools=tools,
41)
42
43print(completion.choice[0])temperature=0.7, top_p=0.8, top_k=20, repetition_penalty=1.05.@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},
}