kd13 commited on
Commit
30b238c
·
verified ·
1 Parent(s): dd5711f

Upload folder using huggingface_hub

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: kd13/Coder-o1-mini-reasoning
3
+ library_name: transformers
4
+ pipeline_tag: text-generation
5
+ license: mit
6
+ language:
7
+ - en
8
+ tags:
9
+ - awq
10
+ - w4a16
11
+ - compressed-tensors
12
+ - quantized
13
+ - vllm
14
+ - code
15
+ - text-generation
16
+ ---
17
+
18
+ # Coder-o1-mini-reasoning - AWQ
19
+
20
+ 4-bit AWQ quantization of [kd13/Coder-o1-mini-reasoning](https://huggingface.co/kd13/Coder-o1-mini-reasoning), a compact
21
+ Python-focused reasoning model for coding assistance, debugging, code explanation, and
22
+ math/logic reasoning.
23
+
24
+ Quantized with [llm-compressor](https://github.com/vllm-project/llm-compressor) using
25
+ `AWQModifier` + `W4A16_ASYM`. Calibrated on 256 code-instruction samples at
26
+ 2048 tokens, with the model's own chat template applied.
27
+
28
+ `lm_head` is left at full precision. Weights are 4-bit; activations stay 16-bit.
29
+
30
+ ## Format
31
+
32
+ This is **compressed-tensors** format, which is what current AWQ tooling produces.
33
+ vLLM and transformers both detect it automatically from `config.json` — you do not need
34
+ to pass `--quantization awq`. The older AutoAWQ format is not interchangeable with this
35
+ one; if a loader expects `quant_config.json`, it wants the legacy format and will not
36
+ read this repo.
37
+
38
+ ## Usage
39
+
40
+ ### vLLM
41
+
42
+ ```bash
43
+ vllm serve kd13/Coder-o1-mini-reasoning-AWQ --max-model-len 8192
44
+ ```
45
+
46
+ ### Transformers
47
+
48
+ ```python
49
+ from transformers import AutoModelForCausalLM, AutoTokenizer
50
+
51
+ model = AutoModelForCausalLM.from_pretrained("kd13/Coder-o1-mini-reasoning-AWQ", device_map="auto")
52
+ tok = AutoTokenizer.from_pretrained("kd13/Coder-o1-mini-reasoning-AWQ")
53
+
54
+ msgs = [
55
+ {"role": "system", "content": "You are a helpful Python coding assistant."},
56
+ {"role": "user", "content": "Explain list comprehensions with an example."},
57
+ ]
58
+ prompt = tok.apply_chat_template(msgs, tokenize=False, add_generation_prompt=True)
59
+ ids = tok(prompt, return_tensors="pt").to(model.device)
60
+ print(tok.decode(model.generate(**ids, max_new_tokens=300)[0]))
61
+ ```
62
+
63
+ Requires `pip install compressed-tensors`.
64
+
65
+ ## Hardware
66
+
67
+ A CUDA GPU is required — AWQ has no CPU path. For local or CPU inference use the GGUF
68
+ build instead.
69
+
70
+ On Ampere or newer (compute capability 8.0+) vLLM uses the Marlin kernel, which is where
71
+ the throughput gains come from. Turing cards such as the T4 fall back to a slower kernel
72
+ and see much less benefit.
73
+
74
+ ## Chat template
75
+
76
+ ChatML, with Qwen-style tool calling:
77
+
78
+ ```
79
+ <|im_start|>system
80
+ {system}<|im_end|>
81
+ <|im_start|>user
82
+ {message}<|im_end|>
83
+ <|im_start|>assistant
84
+ ```
85
+
86
+ Tool definitions are injected into the system message inside `<tools>` tags, and the
87
+ model replies with a JSON object inside `<tool_call>` tags. Tool results are returned
88
+ wrapped in `<tool_response>`. vLLM exposes this through its OpenAI-compatible `tools`
89
+ parameter.
90
+
91
+ A default system prompt is applied when you do not supply one. Pass an explicit system
92
+ prompt to control the assistant's stated identity.
93
+
94
+ ## Limitations
95
+
96
+ Everything in the [base model card](https://huggingface.co/kd13/Coder-o1-mini-reasoning) applies. This is
97
+ a small experimental reasoning model: good for Python learning, debugging help, code
98
+ explanation, and basic-to-intermediate problems. Not suited to hard competitive
99
+ programming, complex algorithmic work, non-Python languages, security-sensitive code, or
100
+ production use without review.
101
+
102
+ 4-bit quantization does not improve any of that. Expect 1-3% degradation on most tasks,
103
+ concentrated in exactly the long multi-step reasoning this model is already weakest at.
104
+ If quality matters more than memory, use the unquantized model or an 8-bit build.
105
+ Always test generated code.
chat_template.jinja ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- if tools %}
2
+ {{- '<|im_start|>system\n' }}
3
+ {%- if messages[0]['role'] == 'system' %}
4
+ {{- messages[0]['content'] }}
5
+ {%- else %}
6
+ {{- 'You are MUA o1 Pro, created by OumuamuaAI. You are a helpful assistant.' }}
7
+ {%- endif %}
8
+ {{- "\n\n# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within <tools></tools> XML tags:\n<tools>" }}
9
+ {%- for tool in tools %}
10
+ {{- "\n" }}
11
+ {{- tool | tojson }}
12
+ {%- endfor %}
13
+ {{- "\n</tools>\n\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\n<tool_call>\n{\"name\": <function-name>, \"arguments\": <args-json-object>}\n</tool_call><|im_end|>\n" }}
14
+ {%- else %}
15
+ {%- if messages[0]['role'] == 'system' %}
16
+ {{- '<|im_start|>system\n' + messages[0]['content'] + '<|im_end|>\n' }}
17
+ {%- else %}
18
+ {{- '<|im_start|>system\nYou are MUA o1 Pro, created by OumuamuaAI. You are a helpful assistant.<|im_end|>\n' }}
19
+ {%- endif %}
20
+ {%- endif %}
21
+ {%- for message in messages %}
22
+ {%- if (message.role == "user") or (message.role == "system" and not loop.first) or (message.role == "assistant" and not message.tool_calls) %}
23
+ {{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>' + '\n' }}
24
+ {%- elif message.role == "assistant" %}
25
+ {{- '<|im_start|>' + message.role }}
26
+ {%- if message.content %}
27
+ {{- '\n' + message.content }}
28
+ {%- endif %}
29
+ {%- for tool_call in message.tool_calls %}
30
+ {%- if tool_call.function is defined %}
31
+ {%- set tool_call = tool_call.function %}
32
+ {%- endif %}
33
+ {{- '\n<tool_call>\n{"name": "' }}
34
+ {{- tool_call.name }}
35
+ {{- '", "arguments": ' }}
36
+ {{- tool_call.arguments | tojson }}
37
+ {{- '}\n</tool_call>' }}
38
+ {%- endfor %}
39
+ {{- '<|im_end|>\n' }}
40
+ {%- elif message.role == "tool" %}
41
+ {%- if (loop.index0 == 0) or (messages[loop.index0 - 1].role != "tool") %}
42
+ {{- '<|im_start|>user' }}
43
+ {%- endif %}
44
+ {{- '\n<tool_response>\n' }}
45
+ {{- message.content }}
46
+ {{- '\n</tool_response>' }}
47
+ {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
48
+ {{- '<|im_end|>\n' }}
49
+ {%- endif %}
50
+ {%- endif %}
51
+ {%- endfor %}
52
+ {%- if add_generation_prompt %}
53
+ {{- '<|im_start|>assistant\n' }}
54
+ {%- endif %}
config.json ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "Qwen2ForCausalLM"
4
+ ],
5
+ "attention_dropout": 0.0,
6
+ "bos_token_id": 151643,
7
+ "dtype": "bfloat16",
8
+ "eos_token_id": 151643,
9
+ "hidden_act": "silu",
10
+ "hidden_size": 1536,
11
+ "initializer_range": 0.02,
12
+ "intermediate_size": 8960,
13
+ "layer_types": [
14
+ "full_attention",
15
+ "full_attention",
16
+ "full_attention",
17
+ "full_attention",
18
+ "full_attention",
19
+ "full_attention",
20
+ "full_attention",
21
+ "full_attention",
22
+ "full_attention",
23
+ "full_attention",
24
+ "full_attention",
25
+ "full_attention",
26
+ "full_attention",
27
+ "full_attention",
28
+ "full_attention",
29
+ "full_attention",
30
+ "full_attention",
31
+ "full_attention",
32
+ "full_attention",
33
+ "full_attention",
34
+ "full_attention",
35
+ "full_attention",
36
+ "full_attention",
37
+ "full_attention",
38
+ "full_attention",
39
+ "full_attention",
40
+ "full_attention",
41
+ "full_attention"
42
+ ],
43
+ "max_position_embeddings": 32768,
44
+ "max_window_layers": 28,
45
+ "model_type": "qwen2",
46
+ "num_attention_heads": 12,
47
+ "num_hidden_layers": 28,
48
+ "num_key_value_heads": 2,
49
+ "pad_token_id": 151643,
50
+ "quantization_config": {
51
+ "config_groups": {
52
+ "group_0": {
53
+ "format": "pack-quantized",
54
+ "input_activations": null,
55
+ "output_activations": null,
56
+ "targets": [
57
+ "Linear"
58
+ ],
59
+ "weights": {
60
+ "actorder": null,
61
+ "block_structure": null,
62
+ "dynamic": false,
63
+ "group_size": 128,
64
+ "num_bits": 4,
65
+ "observer": "memoryless_minmax",
66
+ "observer_kwargs": {},
67
+ "scale_dtype": null,
68
+ "strategy": "group",
69
+ "symmetric": false,
70
+ "type": "int",
71
+ "zp_dtype": "torch.int8"
72
+ }
73
+ }
74
+ },
75
+ "format": "pack-quantized",
76
+ "global_compression_ratio": null,
77
+ "ignore": [
78
+ "lm_head"
79
+ ],
80
+ "kv_cache_scheme": null,
81
+ "quant_method": "compressed-tensors",
82
+ "quantization_status": "compressed",
83
+ "sparsity_config": {},
84
+ "transform_config": {},
85
+ "version": "0.17.1"
86
+ },
87
+ "rms_norm_eps": 1e-06,
88
+ "rope_parameters": {
89
+ "rope_theta": 1000000.0,
90
+ "rope_type": "default"
91
+ },
92
+ "sliding_window": null,
93
+ "tie_word_embeddings": true,
94
+ "transformers_version": "5.10.1",
95
+ "use_cache": false,
96
+ "use_sliding_window": false,
97
+ "vocab_size": 151665
98
+ }
generation_config.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token_id": 151643,
3
+ "eos_token_id": 151643,
4
+ "max_new_tokens": 2048,
5
+ "transformers_version": "5.10.1"
6
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ddc30d06f1691109894ae79f37cc0a7146972f08c1908a9af6fd5001803347d5
3
+ size 1147001472
recipe.yaml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ default_stage:
2
+ default_modifiers:
3
+ AWQModifier:
4
+ mappings:
5
+ - smooth_layer: re:.*input_layernorm$
6
+ balance_layers: ['re:.*q_proj$', 're:.*k_proj$', 're:.*v_proj$']
7
+ activation_hook_target: null
8
+ - smooth_layer: re:.*v_proj$
9
+ balance_layers: ['re:.*o_proj$']
10
+ activation_hook_target: null
11
+ - smooth_layer: re:.*post_attention_layernorm$
12
+ balance_layers: ['re:.*gate_proj$', 're:.*up_proj$']
13
+ activation_hook_target: null
14
+ - smooth_layer: re:.*up_proj$
15
+ balance_layers: ['re:.*down_proj$']
16
+ activation_hook_target: null
17
+ duo_scaling: both
18
+ n_grid: 20
19
+ QuantizationModifier:
20
+ targets: [Linear]
21
+ ignore: [lm_head]
22
+ scheme: W4A16_ASYM
23
+ bypass_divisibility_checks: false
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3fd169731d2cbde95e10bf356d66d5997fd885dd8dbb6fb4684da3f23b2585d8
3
+ size 11421892
tokenizer_config.json ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "backend": "tokenizers",
4
+ "bos_token": null,
5
+ "clean_up_tokenization_spaces": false,
6
+ "eos_token": "<|endoftext|>",
7
+ "errors": "replace",
8
+ "is_local": true,
9
+ "local_files_only": false,
10
+ "model_max_length": 32768,
11
+ "pad_token": "<|endoftext|>",
12
+ "split_special_tokens": false,
13
+ "tokenizer_class": "Qwen2Tokenizer",
14
+ "unk_token": null
15
+ }