Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,92 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: apache-2.0
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
base_model: ibm-granite/granite-34b-code-instruct-8k
|
| 4 |
+
tags:
|
| 5 |
+
- fp8
|
| 6 |
+
- quantized
|
| 7 |
+
- code
|
| 8 |
+
- granite
|
| 9 |
+
- ibm
|
| 10 |
+
- llmcompressor
|
| 11 |
+
- vllm
|
| 12 |
+
library_name: transformers
|
| 13 |
+
pipeline_tag: text-generation
|
| 14 |
+
---
|
| 15 |
+
|
| 16 |
+
# granite-34b-code-instruct-8k-FP8
|
| 17 |
+
|
| 18 |
+
This is an FP8 quantized version of [granite-34b-code-instruct-8k](https://huggingface.co/ibm-granite/granite-34b-code-instruct-8k) for efficient inference.
|
| 19 |
+
|
| 20 |
+
## Model Description
|
| 21 |
+
|
| 22 |
+
- **Base Model:** [granite-34b-code-instruct-8k](https://huggingface.co/ibm-granite/granite-34b-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:** 31.0 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-34b-code-instruct-8k-FP8",
|
| 37 |
+
torch_dtype=torch.float8_e4m3fn, # FP8 dtype
|
| 38 |
+
device_map="auto",
|
| 39 |
+
low_cpu_mem_usage=True,
|
| 40 |
+
)
|
| 41 |
+
|
| 42 |
+
tokenizer = AutoTokenizer.from_pretrained("TevunahAi/granite-34b-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 |
+
llm = LLM(model="TevunahAi/granite-34b-code-instruct-8k-FP8")
|
| 56 |
+
sampling_params = SamplingParams(temperature=0.7, max_tokens=256)
|
| 57 |
+
|
| 58 |
+
prompts = ["Write a Python function to calculate fibonacci numbers:"]
|
| 59 |
+
outputs = llm.generate(prompts, sampling_params)
|
| 60 |
+
```
|
| 61 |
+
|
| 62 |
+
## Quantization Details
|
| 63 |
+
|
| 64 |
+
- **Target Layers:** All Linear layers except lm_head
|
| 65 |
+
- **Precision:** FP8 (E4M3 format)
|
| 66 |
+
- **Hardware Requirements:** NVIDIA Ada Lovelace or Hopper (native FP8) or Ampere with emulation
|
| 67 |
+
|
| 68 |
+
### Quantization Infrastructure
|
| 69 |
+
|
| 70 |
+
Quantized on professional hardware to ensure quality and reliability:
|
| 71 |
+
- **CPUs:** Dual Intel Xeon Max 9480 (224 threads, 128GB HBM2e)
|
| 72 |
+
- **GPU:** NVIDIA RTX 5000 Ada Generation (32GB VRAM) with native FP8 support
|
| 73 |
+
- **Memory:** 256GB DDR5 + 128GB HBM2e = 384GB total
|
| 74 |
+
- **Software:** Ubuntu 25.10 | Python 3.12 | PyTorch 2.8 | CUDA 13 | llm-compressor
|
| 75 |
+
|
| 76 |
+
### Performance Notes
|
| 77 |
+
|
| 78 |
+
This 34B model demonstrates optimal HBM2e utilization:
|
| 79 |
+
- Full CPU/HBM2e processing path for maximum efficiency
|
| 80 |
+
- Superior per-parameter performance (0.91 min/B)
|
| 81 |
+
- Counterintuitively faster than smaller 20B model due to pure HBM2e workflow
|
| 82 |
+
- Ideal size for our hardware architecture
|
| 83 |
+
|
| 84 |
+
## License
|
| 85 |
+
|
| 86 |
+
Apache 2.0 (same as original model)
|
| 87 |
+
|
| 88 |
+
## Credits
|
| 89 |
+
|
| 90 |
+
- Original model by [IBM Granite](https://huggingface.co/ibm-granite)
|
| 91 |
+
- Quantized by [TevunahAi](https://huggingface.co/TevunahAi)
|
| 92 |
+
- Quantization powered by [llm-compressor](https://github.com/vllm-project/llm-compressor)
|