For optimal performance with full FP8 benefits (2x memory savings + faster inference), use vLLM or TensorRT-LLM:
Quick Start with vLLM
pip install vllm
Python API:
python
1from vllm import LLM, SamplingParams
23# vLLM auto-detects FP8 from model config4llm = LLM(model="TevunahAi/granite-8b-code-instruct-4k-FP8", dtype="auto")56# Generate7prompt ="Write a Python function to calculate fibonacci numbers:"8sampling_params = SamplingParams(temperature=0.7, max_tokens=256)910outputs = llm.generate([prompt], sampling_params)11for output in outputs:12print(output.outputs[0].text)
OpenAI-Compatible API Server:
bash
1vllm serve TevunahAi/granite-8b-code-instruct-4k-FP8 \2 --dtype auto \3 --max-model-len 4096
Then use with OpenAI client:
python
1from openai import OpenAI
23client = OpenAI(4 base_url="http://localhost:8000/v1",5 api_key="token-abc123",# dummy key6)78response = client.chat.completions.create(9 model="TevunahAi/granite-8b-code-instruct-4k-FP8",10 messages=[11{"role":"user","content":"Write a Python function to calculate fibonacci numbers"}12],13 temperature=0.7,14 max_tokens=256,15)1617print(response.choices[0].message.content)
vLLM Benefits
✅ Weights, activations, and KV cache in FP8
✅ ~8GB VRAM (50% reduction vs BF16)
✅ Native FP8 tensor core acceleration on Ada/Hopper GPUs
✅ Faster inference with optimized CUDA kernels
✅ Runs on consumer GPUs (RTX 4070, RTX 4060 Ti 16GB, RTX 5000 Ada)
⚙️ Alternative: Transformers
This model can also be loaded with transformers. Note: Transformers will decompress FP8 → BF16 during inference. However, at 8B parameters, this is manageable (~16GB VRAM).
Transformers Example (Click to expand)
python
1from transformers import AutoModelForCausalLM, AutoTokenizer
2import torch
34# Loads FP8 weights but decompresses to BF16 during compute5model = AutoModelForCausalLM.from_pretrained(6"TevunahAi/granite-8b-code-instruct-4k-FP8",7 device_map="auto",8 torch_dtype="auto",9 low_cpu_mem_usage=True,10)11tokenizer = AutoTokenizer.from_pretrained("TevunahAi/granite-8b-code-instruct-4k-FP8")1213# Generate14prompt ="Write a Python function to calculate fibonacci numbers:"15inputs = tokenizer(prompt, return_tensors="pt").to(model.device)1617outputs = model.generate(**inputs, max_new_tokens=256)18print(tokenizer.decode(outputs[0], skip_special_tokens=True))
⚠️ Decompresses to BF16 during inference (no runtime memory benefit)
For production inference, use vLLM to realize the full FP8 benefits.
💾 Model Files
This model is sharded into multiple safetensors files (all required for inference). The compressed format enables efficient storage and faster downloads.
🔬 IBM Granite Code Models
Granite Code models are specifically trained for code generation, editing, and explanation tasks. This 8B parameter version offers strong performance on:
Code completion and generation
Bug fixing and refactoring
Code explanation and documentation
Multiple programming languages
4K context window
Granite 8B vs Larger Models:
✅ Fast iteration - quick response times
✅ Accessible - runs on consumer GPUs
✅ Good quality - suitable for most coding tasks
⚠️ Trade-off: Less capable on very complex reasoning vs 20B/34B