File size: 5,849 Bytes
55a3b37
 
9f6b7ee
 
55a3b37
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9f6b7ee
55a3b37
 
 
9f6b7ee
 
55a3b37
 
 
9f6b7ee
55a3b37
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9f6b7ee
 
55a3b37
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9f6b7ee
55a3b37
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9f6b7ee
55a3b37
 
 
 
 
 
9f6b7ee
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
---
license: other
license_name: deepseek-license
license_link: LICENSE
base_model:
- deepseek-ai/DeepSeek-Coder-V2-Lite-Instruct
base_model_relation: quantized
library_name: transformers
pipeline_tag: text-generation
tags:
- quantized
- int8
- w8a8
- dynamic-quantization
- 8-bit
- llm-compressor
- zendnn
- compressed-tensors
- amd
- cpu-inference
language:
- en
---

# DeepSeek-Coder-V2-Lite-Instruct-w8a8-llmcompressor

## Model Overview

- **Model Architecture:** DeepseekV2ForCausalLM
  - **Input:** Text
  - **Output:** Text
- **Source Model:** [DeepSeek-Coder-V2-Lite-Instruct](https://huggingface.co/deepseek-ai/DeepSeek-Coder-V2-Lite-Instruct)
- **Supported Hardware:** AMD EPYC (CPU inference)
- **Preferred Operating System:** Linux
- **Inference Engine:** [vLLM](https://docs.vllm.ai/en/latest/) v0.33.0
- **Quantization Framework:** [LLM Compressor](https://github.com/vllm-project/llm-compressor) v0.14.0
- **Quantization Method:** 8-bit Weight, 8-bit Dynamic Activation Quantization (W8A8)
- **Compatible Stack:**
  - ZenDNN v6.2.0
  - ZenTorch v2.14.0.3
  - PyTorch v2.14.0+cpu
  - Transformers v5.17.0
  - LLM Compressor v0.14.0
  - vLLM v0.33.0
- **Published with:** LLM Compressor v0.14.0

This is a quantized version of [DeepSeek-Coder-V2-Lite-Instruct](https://huggingface.co/deepseek-ai/DeepSeek-Coder-V2-Lite-Instruct) created by AMD using LLM Compressor (compressed-tensors) for ZenDNN-optimized CPU inference.

## Quantization

The model was quantized from [DeepSeek-Coder-V2-Lite-Instruct](https://huggingface.co/deepseek-ai/DeepSeek-Coder-V2-Lite-Instruct) using [LLM Compressor](https://github.com/vllm-project/llm-compressor) via the Round-to-Nearest (RTN) algorithm. This reduces the model weights from 29.3 GiB to 15.0 GiB on disk (~49% reduction).

- **Method:** 8-bit Weight, 8-bit Dynamic Activation Quantization (W8A8)
- **Config:** `compressed-tensors, num_bits=8, type=int, symmetric=true`
- **Weights:** INT8, symmetric, per-channel (static)
- **Activations:** INT8, symmetric, per-token (dynamic)
- **Quantized:** `model.layers.*.mlp.experts.*.up_proj` (1664), `model.layers.*.mlp.experts.*.gate_proj` (1664), `model.layers.*.mlp.experts.*.down_proj` (1664), `model.layers.*.self_attn.q_proj` (27), `model.layers.*.self_attn.kv_a_proj_with_mqa` (27), `model.layers.*.self_attn.kv_b_proj` (27), `model.layers.*.self_attn.o_proj` (27), `model.layers.*.mlp.shared_experts.gate_proj` (26), `model.layers.*.mlp.shared_experts.up_proj` (26), `model.layers.*.mlp.shared_experts.down_proj` (26), `model.layers.*.mlp.gate_proj` (1), `model.layers.*.mlp.up_proj` (1)
- **Kept in BF16:** `lm_head` (1), `embed_tokens`, and the layer norms

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

from llmcompressor import oneshot
from llmcompressor.modifiers.quantization import QuantizationModifier
from llmcompressor.utils import load_context

model_id = "deepseek-ai/DeepSeek-Coder-V2-Lite-Instruct"
output_dir = "./DeepSeek-Coder-V2-Lite-Instruct-w8a8-llmcompressor"

# Step 1: Load the BF16 model and tokenizer.
model_cls = transformers.AutoModelForCausalLM
with load_context(model_cls):
    model = model_cls.from_pretrained(model_id, dtype=torch.bfloat16, trust_remote_code=False)
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=False)

# Step 2: W8A8 recipe. Round-to-nearest is data-free, so no calibration set is needed.
recipe = QuantizationModifier(
    scheme="W8A8",
    targets=["Linear"],
    ignore=[
        'lm_head',
        're:.*lm_head',
    ],
)

# Step 3: One-shot quantize.
oneshot(model=model, recipe=recipe)

# Save in compressed-tensors format.
model.save_pretrained(output_dir, save_compressed=True)
tokenizer.save_pretrained(output_dir)
```

## Quick Start

### Use with vLLM

```python
from vllm import LLM, SamplingParams

model = LLM(
    model="amd/DeepSeek-Coder-V2-Lite-Instruct-w8a8-llmcompressor",
    dtype="bfloat16",
)

sampling_params = SamplingParams(temperature=0.7, max_tokens=256)
outputs = model.generate(["Hello, how are you?"], sampling_params)
print(outputs[0].outputs[0].text)
```

### Requirements

```
torch==2.14.0+cpu
zentorch==2.14.0.3
vllm==0.33.0
llmcompressor==0.14.0
```

### OpenMP Setup

For optimal performance, set `LD_PRELOAD` with `libomp.so` (LLVM OpenMP) or `libiomp5.so` (Intel OpenMP):

```bash
# Using LLVM OpenMP (llvmopenmp)
export LD_PRELOAD=$(find /path/to/env -name "libomp.so" | head -1)

# Or using Intel OpenMP (libiomp)
export LD_PRELOAD=$(find /path/to/env -name "libiomp5.so" | head -1)
```

> **Note:** Set `LD_PRELOAD` before launching vLLM or any inference script.

## Evaluation

The model was evaluated against the BF16 (unquantized) baseline on standard benchmarks using [lm-evaluation-harness](https://github.com/EleutherAI/lm-evaluation-harness) with the vLLM engine.

| Benchmark | BF16 Baseline | W8A8 (this model) | Recovery |
| --- | --- | --- | --- |
| GSM8K (5-shot) | 0.5322 | 0.5428 | 101.99% |

### Evaluation Command

```bash
lm_eval \
    --model vllm \
    --model_args pretrained=amd/DeepSeek-Coder-V2-Lite-Instruct-w8a8-llmcompressor,dtype=bfloat16 \
    --tasks gsm8k \
    --batch_size auto \
    --trust_remote_code \
    --num_fewshot 5 \
    --apply_chat_template \
    --log_samples \
    --gen_kwargs "max_gen_toks=2048" \
    --output_path .
```

## Limitations

- **Version Lock:** This model is compatible with ZenDNN v6.2.0 / ZenTorch v2.14.0.3 / PyTorch v2.14.0+cpu. It may not load correctly on other versions.
- **CPU Only:** This model is optimized for AMD EPYC CPU inference via ZenDNN. It is not intended for GPU inference.

## License

This model is distributed under the same license as the source model. See the [LICENSE](./LICENSE) file for details.

Modifications copyright (c) 2026 Advanced Micro Devices, Inc. All rights reserved.