File size: 5,810 Bytes
3ba9c19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
---
language:
- ko
- en
license: llama3
library_name: transformers
tags:
- moe
- awq
- quantized
- w4a16
- compressed-tensors
- vllm
- llm-compressor
base_model: LGAI-EXAONE/K-EXAONE-236B-A23B
---

# K-EXAONE-236B-A23B-W4A16-G128

**W4A16 AWQ quantization** of [`LGAI-EXAONE/K-EXAONE-236B-A23B`](https://huggingface.co/LGAI-EXAONE/K-EXAONE-236B-A23B), produced with [llm-compressor](https://github.com/vllm-project/llm-compressor).

This is the **first W4A16 AWQ checkpoint** for K-EXAONE-236B-A23B publicly available โ€” the original model only has FP8 and GGUF variants on HuggingFace.

---

## Model Details

| Property | Value |
|---|---|
| Base model | LGAI-EXAONE/K-EXAONE-236B-A23B |
| Architecture | ExaoneMoeForCausalLM |
| Total parameters | ~236B |
| Active parameters | ~23B per token |
| Quantization method | AWQ (Activation-aware Weight Quantization) |
| Weight precision | INT4 (packed) |
| Activation precision | BF16 |
| Group size | 128 |
| Quantization scope | All `Linear` layers except `lm_head` and gate projections |
| Compressed-tensors version | 0.15.0 |
| Context length | 262,144 tokens |
| Languages | Korean, English |

### Architecture Highlights

- **48 transformer layers** with mixed sliding-window (`LLLG` pattern) and full attention
- **MoE layers**: 47 sparse MoE layers + 1 dense MLP (layer 0)
- **128 routed experts** + 1 shared expert per MoE layer; top-8 experts activated per token
- **Sigmoid scoring** with `norm_topk_prob=True`
- **Hidden size**: 6144, **MoE intermediate size**: 2048

---

## Quantization Details

Quantization was performed using [llm-compressor](https://github.com/vllm-project/llm-compressor) with a **MoE-aware AWQ** recipe.

**Method:** AWQ applies channel-wise scaling to minimize quantization error by protecting salient weights, using a calibration dataset to determine optimal scales.

**Recipe highlights:**
- `scheme`: W4A16 (INT4 weights, BF16 activations)
- `group_size`: 128
- `n_grid`: 20 (search resolution for AWQ scale optimization)
- `duo_scaling`: True
- Smooth mappings cover all MoE expert layers (layers 1โ€“47) independently, plus attention and MLP projections
- Layer 0 (dense MLP) and `lm_head` are excluded from quantization
- Gate weight tensors are excluded from quantization

The full recipe is available in `recipe.yaml`.

**Calibration dataset:** [`neuralmagic/LLM_compression_calibration`](https://huggingface.co/datasets/neuralmagic/LLM_compression_calibration) (512 samples, sequence length 2048)

---

## Usage

### vLLM (Recommended)

Install vLLM (โ‰ฅ0.6.0 recommended for compressed-tensors support):

```bash
pip install vllm
```

```python
from vllm import LLM, SamplingParams

llm = LLM(
    model="Hyun9junn/K-EXAONE-236B-A23B-W4A16-G128",
    max_model_len=8192,
    trust_remote_code=True,   # K-EXAONE uses custom modeling code
    tensor_parallel_size=4,   # adjust to the number of GPUs available
)

sampling_params = SamplingParams(
    temperature=0.6,
    top_p=0.9,
    max_tokens=512,
)

tokenizer = llm.get_tokenizer()

prompts = [
    "What is the capital of South Korea?",
    "Explain the difference between MoE and dense transformer models.",
]

formatted_prompts = [
    tokenizer.apply_chat_template(
        [{"role": "user", "content": p}],
        tokenize=False,
        add_generation_prompt=True,
    )
    for p in prompts
]

outputs = llm.generate(formatted_prompts, sampling_params)

for prompt, output in zip(prompts, outputs):
    print(f"Prompt : {prompt}")
    print(f"Response: {output.outputs[0].text.strip()}")
```

### Transformers

```python
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch

model_id = "Hyun9junn/K-EXAONE-236B-A23B-W4A16-G128"

tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
    model_id,
    torch_dtype=torch.bfloat16,
    device_map="auto",
    trust_remote_code=True,
)

messages = [{"role": "user", "content": "ํ•œ๊ตญ์˜ ์ˆ˜๋„๋Š” ์–ด๋””์ธ๊ฐ€์š”?"}]
input_ids = tokenizer.apply_chat_template(
    messages, tokenize=True, add_generation_prompt=True, return_tensors="pt"
).to(model.device)

output = model.generate(input_ids, max_new_tokens=256, temperature=0.6, top_p=0.9)
print(tokenizer.decode(output[0][input_ids.shape[-1]:], skip_special_tokens=True))
```

---

## Hardware Requirements

| Precision | Min VRAM |
|---|---|
| This model (W4A16) | ~120 GB |
| Original BF16 | ~480 GB |

Tested on: NVIDIA B200 (180 GB HBM3e).

For multi-GPU inference, set `tensor_parallel_size` in vLLM to the number of GPUs.

---

## Files

| File | Description |
|---|---|
| `model-00001-of-00003.safetensors` | Model weights shard 1/3 |
| `model-00002-of-00003.safetensors` | Model weights shard 2/3 |
| `model-00003-of-00003.safetensors` | Model weights shard 3/3 |
| `model.safetensors.index.json` | Weight shard index |
| `config.json` | Model config with quantization metadata |
| `recipe.yaml` | llm-compressor AWQ recipe used for quantization |
| `tokenizer.json` | Tokenizer |
| `tokenizer_config.json` | Tokenizer config |
| `chat_template.jinja` | Chat template |
| `generation_config.json` | Default generation config |

---

## License

This model inherits the license of the base model [`LGAI-EXAONE/K-EXAONE-236B-A23B`](https://huggingface.co/LGAI-EXAONE/K-EXAONE-236B-A23B). Please refer to the original model page for license details.

---

## Citation

If you use this model, please cite the original K-EXAONE work:

```
@misc{k-exaone-236b,
  title  = {K-EXAONE-236B-A23B},
  author = {LG AI Research},
  year   = {2025},
  url    = {https://huggingface.co/LGAI-EXAONE/K-EXAONE-236B-A23B}
}
```

Quantization produced by [Hyun9junn](https://huggingface.co/Hyun9junn) using [llm-compressor](https://github.com/vllm-project/llm-compressor).