rockylynnstein commited on
Commit
1c95c50
Β·
verified Β·
1 Parent(s): aec9cca

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +203 -44
README.md CHANGED
@@ -15,80 +15,239 @@ pipeline_tag: text-generation
15
 
16
  # granite-20b-code-instruct-8k-FP8
17
 
18
- This is an FP8 quantized version of [granite-20b-code-instruct-8k](https://huggingface.co/ibm-granite/granite-20b-code-instruct-8k) for efficient inference.
19
 
20
- ## Model Description
21
 
22
- - **Base Model:** [granite-20b-code-instruct-8k](https://huggingface.co/ibm-granite/granite-20b-code-instruct-8k)
23
- - **Quantization:** FP8 (E4M3 format)
24
- - **Quantization Method:** llmcompressor oneshot with FP8 scheme
25
- - **Calibration Dataset:** open_platypus (512 samples)
26
- - **Quantization Time:** 46.5 minutes
27
 
28
- ## Usage
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
 
30
- ### With Transformers
31
  ```python
32
  from transformers import AutoModelForCausalLM, AutoTokenizer
33
  import torch
34
 
 
35
  model = AutoModelForCausalLM.from_pretrained(
36
  "TevunahAi/granite-20b-code-instruct-8k-FP8",
37
- torch_dtype=torch.bfloat16,
38
  device_map="auto",
 
39
  low_cpu_mem_usage=True,
40
  )
41
-
42
  tokenizer = AutoTokenizer.from_pretrained("TevunahAi/granite-20b-code-instruct-8k-FP8")
43
 
44
  # Generate
45
  prompt = "Write a Python function to calculate fibonacci numbers:"
46
  inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
 
47
  outputs = model.generate(**inputs, max_new_tokens=256)
48
  print(tokenizer.decode(outputs[0], skip_special_tokens=True))
49
  ```
50
 
51
- ### With vLLM (Recommended for production)
52
- ```python
53
- from vllm import LLM, SamplingParams
54
-
55
- if __name__ == '__main__':
56
- llm = LLM(model="TevunahAi/granite-20b-code-instruct-8k-FP8")
57
- sampling_params = SamplingParams(temperature=0.7, max_tokens=256)
58
-
59
- outputs = llm.generate(["Write a Python fibonacci function:"], sampling_params)
60
-
61
- for output in outputs:
62
- print(output.outputs[0].text)
63
- print("---DONE---")
64
  ```
65
- ## Quantization Details
66
 
67
- - **Target Layers:** All Linear layers except lm_head
68
- - **Precision:** FP8 (E4M3 format)
69
- - **Hardware Requirements:** NVIDIA Ada Lovelace or Hopper (native FP8) or Ampere with emulation
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
 
71
  ### Quantization Infrastructure
72
 
73
- Quantized on professional hardware to ensure quality and reliability:
74
- - **CPUs:** Dual Intel Xeon Max 9480 (224 threads, 128GB HBM2e)
75
- - **GPU:** NVIDIA RTX 5000 Ada Generation (32GB VRAM) with native FP8 support
76
- - **Memory:** 256GB DDR5 + 128GB HBM2e = 384GB total
77
- - **Software:** Ubuntu 25.10 | Python 3.12 | PyTorch 2.8 | CUDA 13 | llm-compressor
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
 
79
- ### Performance Notes
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
 
81
- This 20B model exhibits unique quantization characteristics due to hardware architecture:
82
- - Models in the 16-25B range utilize mixed GPU/CPU processing
83
- - Full HBM2e optimization is achieved with larger models (30B+)
84
- - See our other Granite FP8 quantizations for performance comparisons
85
 
86
- ## License
87
 
88
- Apache 2.0 (same as original model)
89
 
90
- ## Credits
91
 
92
- - Original model by [IBM Granite](https://huggingface.co/ibm-granite)
93
- - Quantized by [TevunahAi](https://huggingface.co/TevunahAi)
94
- - Quantization powered by [llm-compressor](https://github.com/vllm-project/llm-compressor)
 
15
 
16
  # granite-20b-code-instruct-8k-FP8
17
 
18
+ **FP8 quantized version of IBM's Granite 20B Code model for efficient inference**
19
 
20
+ This is an FP8 (E4M3) quantized version of [ibm-granite/granite-20b-code-instruct-8k](https://huggingface.co/ibm-granite/granite-20b-code-instruct-8k) using compressed_tensors format. Quantized by [TevunahAi](https://huggingface.co/TevunahAi) on enterprise-grade hardware.
21
 
22
+ ## 🎯 Recommended Usage: vLLM
 
 
 
 
23
 
24
+ For optimal performance with **full FP8 benefits** (2x memory savings + faster inference), use **vLLM** or **TensorRT-LLM**:
25
+
26
+ ### Quick Start with vLLM
27
+
28
+ ```bash
29
+ pip install vllm
30
+ ```
31
+
32
+ **Python API:**
33
+
34
+ ```python
35
+ from vllm import LLM, SamplingParams
36
+
37
+ # vLLM auto-detects FP8 from model config
38
+ llm = LLM(model="TevunahAi/granite-20b-code-instruct-8k-FP8", dtype="auto")
39
+
40
+ # Generate
41
+ prompt = "Write a Python function to calculate fibonacci numbers:"
42
+ sampling_params = SamplingParams(temperature=0.7, max_tokens=256)
43
+
44
+ outputs = llm.generate([prompt], sampling_params)
45
+ for output in outputs:
46
+ print(output.outputs[0].text)
47
+ ```
48
+
49
+ **OpenAI-Compatible API Server:**
50
+
51
+ ```bash
52
+ vllm serve TevunahAi/granite-20b-code-instruct-8k-FP8 \
53
+ --dtype auto \
54
+ --max-model-len 8192
55
+ ```
56
+
57
+ Then use with OpenAI client:
58
+
59
+ ```python
60
+ from openai import OpenAI
61
+
62
+ client = OpenAI(
63
+ base_url="http://localhost:8000/v1",
64
+ api_key="token-abc123", # dummy key
65
+ )
66
+
67
+ response = client.chat.completions.create(
68
+ model="TevunahAi/granite-20b-code-instruct-8k-FP8",
69
+ messages=[
70
+ {"role": "user", "content": "Write a Python function to calculate fibonacci numbers"}
71
+ ],
72
+ temperature=0.7,
73
+ max_tokens=256,
74
+ )
75
+
76
+ print(response.choices[0].message.content)
77
+ ```
78
+
79
+ ### vLLM Benefits
80
+
81
+ - βœ… **Weights, activations, and KV cache in FP8**
82
+ - βœ… **~20GB VRAM** (50% reduction vs BF16)
83
+ - βœ… **Native FP8 tensor core acceleration** on Ada/Hopper GPUs
84
+ - βœ… **Faster inference** with optimized CUDA kernels
85
+ - βœ… **Production-grade performance**
86
+
87
+ ## βš™οΈ Alternative: Transformers (Not Recommended)
88
+
89
+ This model can be loaded with `transformers`, but **will decompress FP8 β†’ BF16 during inference**, requiring ~40GB+ VRAM. For 20B models, **vLLM is strongly recommended**.
90
+
91
+ <details>
92
+ <summary>Transformers Example (Click to expand)</summary>
93
 
 
94
  ```python
95
  from transformers import AutoModelForCausalLM, AutoTokenizer
96
  import torch
97
 
98
+ # Loads FP8 weights but decompresses to BF16 during compute
99
  model = AutoModelForCausalLM.from_pretrained(
100
  "TevunahAi/granite-20b-code-instruct-8k-FP8",
 
101
  device_map="auto",
102
+ torch_dtype="auto",
103
  low_cpu_mem_usage=True,
104
  )
 
105
  tokenizer = AutoTokenizer.from_pretrained("TevunahAi/granite-20b-code-instruct-8k-FP8")
106
 
107
  # Generate
108
  prompt = "Write a Python function to calculate fibonacci numbers:"
109
  inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
110
+
111
  outputs = model.generate(**inputs, max_new_tokens=256)
112
  print(tokenizer.decode(outputs[0], skip_special_tokens=True))
113
  ```
114
 
115
+ **Requirements:**
116
+ ```bash
117
+ pip install torch>=2.1.0 transformers>=4.40.0 accelerate compressed-tensors
 
 
 
 
 
 
 
 
 
 
118
  ```
 
119
 
120
+ **System Requirements:**
121
+ - **~40GB+ VRAM** (decompressed to BF16)
122
+ - Multi-GPU setup or A100/H100
123
+ - CUDA 11.8 or newer
124
+
125
+ **⚠️ Warning:** vLLM is the recommended deployment method for 20B models.
126
+
127
+ </details>
128
+
129
+ ## πŸ“Š Quantization Details
130
+
131
+ | Property | Value |
132
+ |----------|-------|
133
+ | **Base Model** | [ibm-granite/granite-20b-code-instruct-8k](https://huggingface.co/ibm-granite/granite-20b-code-instruct-8k) |
134
+ | **Quantization Method** | FP8 E4M3 weight-only |
135
+ | **Framework** | llm-compressor + compressed_tensors |
136
+ | **Calibration Dataset** | open_platypus (512 samples) |
137
+ | **Storage Size** | ~20GB (sharded safetensors) |
138
+ | **VRAM (vLLM)** | ~20GB |
139
+ | **VRAM (Transformers)** | ~40GB+ (decompressed to BF16) |
140
+ | **Target Hardware** | NVIDIA Ada (RTX 4000/5000) or Hopper (H100/GH200) |
141
+ | **Quantization Time** | 46.5 minutes |
142
 
143
  ### Quantization Infrastructure
144
 
145
+ Professional hardware ensures consistent, high-quality quantization:
146
+
147
+ - **CPUs:** Dual Intel Xeon Max 9480 (112 cores / 224 threads, 128GB HBM2e)
148
+ - **GPU:** NVIDIA RTX 5000 Ada Generation (32GB VRAM, native FP8 support)
149
+ - **Memory:** 256GB DDR5 + 128GB HBM2e = 384GB total system memory
150
+ - **Software Stack:** Ubuntu 25.10 | Python 3.12 | PyTorch 2.8 | CUDA 13.0 | llm-compressor
151
+
152
+ ## πŸ”§ Why FP8 for 20B Models?
153
+
154
+ ### With vLLM/TensorRT-LLM:
155
+ - βœ… **50% memory reduction** vs BF16 (weights + activations + KV cache)
156
+ - βœ… **Single GPU deployment** on RTX 4090 (24GB) or RTX 5000 Ada (32GB)
157
+ - βœ… **Faster inference** via native FP8 tensor cores
158
+ - βœ… **Better throughput** with optimized kernels
159
+ - βœ… **Minimal quality loss** for code generation tasks
160
+
161
+ ### With Transformers:
162
+ - βœ… **Smaller download size** (~20GB vs ~40GB BF16)
163
+ - βœ… **Compatible** with standard transformers workflow
164
+ - ⚠️ **Decompresses to BF16** during inference (no runtime memory benefit)
165
+ - ❌ **Requires 40GB+ VRAM** - impractical for most setups
166
+
167
+ **For 20B models, vLLM is essential for practical deployment.**
168
+
169
+ ## πŸ’Ύ Model Files
170
+
171
+ This model is sharded into multiple safetensors files (all required for inference). The compressed format enables efficient storage and faster downloads.
172
+
173
+ ## πŸ”¬ IBM Granite Code Models
174
+
175
+ Granite Code models are specifically trained for code generation, editing, and explanation tasks. This 20B parameter version offers strong performance on:
176
+
177
+ - Code completion and generation
178
+ - Bug fixing and refactoring
179
+ - Code explanation and documentation
180
+ - Multiple programming languages
181
+ - 8K context window
182
+
183
+ ## πŸ“š Original Model
184
+
185
+ This quantization is based on [ibm-granite/granite-20b-code-instruct-8k](https://huggingface.co/ibm-granite/granite-20b-code-instruct-8k) by IBM.
186
 
187
+ For comprehensive information about:
188
+ - Model architecture and training methodology
189
+ - Supported programming languages
190
+ - Evaluation benchmarks and results
191
+ - Ethical considerations and responsible AI guidelines
192
+
193
+ Please refer to the [original model card](https://huggingface.co/ibm-granite/granite-20b-code-instruct-8k).
194
+
195
+ ## πŸ”§ Hardware Requirements
196
+
197
+ ### Minimum (vLLM):
198
+ - **GPU:** NVIDIA RTX 4090 (24GB) or RTX 5000 Ada (32GB)
199
+ - **VRAM:** 20GB minimum, 24GB+ recommended
200
+ - **CUDA:** 11.8 or newer
201
+
202
+ ### Recommended (vLLM):
203
+ - **GPU:** NVIDIA RTX 5000 Ada (32GB) / H100 (80GB)
204
+ - **VRAM:** 24GB+
205
+ - **CUDA:** 12.0+
206
+
207
+ ### Transformers:
208
+ - **GPU:** Multi-GPU setup or A100 (40GB+)
209
+ - **VRAM:** 40GB+ (single GPU) or distributed across multiple GPUs
210
+ - **Not recommended** for practical deployment
211
+
212
+ ## πŸ“– Additional Resources
213
+
214
+ - **vLLM Documentation:** [docs.vllm.ai](https://docs.vllm.ai/)
215
+ - **TensorRT-LLM:** [github.com/NVIDIA/TensorRT-LLM](https://github.com/NVIDIA/TensorRT-LLM)
216
+ - **TevunahAi Models:** [huggingface.co/TevunahAi](https://huggingface.co/TevunahAi)
217
+ - **llm-compressor:** [github.com/vllm-project/llm-compressor](https://github.com/vllm-project/llm-compressor)
218
+ - **IBM Granite:** [github.com/ibm-granite](https://github.com/ibm-granite)
219
+
220
+ ## πŸ“„ License
221
+
222
+ This model inherits the **Apache 2.0 License** from the original Granite model.
223
+
224
+ ## πŸ™ Acknowledgments
225
+
226
+ - **Original Model:** IBM Granite team
227
+ - **Quantization Framework:** Neural Magic's llm-compressor
228
+ - **Quantized by:** [TevunahAi](https://huggingface.co/TevunahAi)
229
+
230
+ ## πŸ“ Citation
231
+
232
+ If you use this model, please cite the original Granite work:
233
+
234
+ ```bibtex
235
+ @misc{granite2024,
236
+ title={Granite Code Models},
237
+ author={IBM Research},
238
+ year={2024},
239
+ url={https://huggingface.co/ibm-granite/granite-20b-code-instruct-8k}
240
+ }
241
+ ```
242
+
243
+ ---
244
 
245
+ <div align="center">
 
 
 
246
 
247
+ **Professional AI Model Quantization by TevunahAi**
248
 
249
+ *Enterprise-grade quantization on specialized hardware*
250
 
251
+ [View all models](https://huggingface.co/TevunahAi) | [Contact for custom quantization](https://huggingface.co/TevunahAi)
252
 
253
+ </div>