Text Generation
Transformers
Safetensors
English
granite
quantized
int8
w8a8
dynamic-quantization
8-bit precision
llm-compressor
zendnn
compressed-tensors
amd
cpu-inference
conversational
Instructions to use amd/granite-4.2-8b-w8a8-llmcompressor with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use amd/granite-4.2-8b-w8a8-llmcompressor with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="amd/granite-4.2-8b-w8a8-llmcompressor") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("amd/granite-4.2-8b-w8a8-llmcompressor") model = AutoModelForCausalLM.from_pretrained("amd/granite-4.2-8b-w8a8-llmcompressor", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use amd/granite-4.2-8b-w8a8-llmcompressor with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "amd/granite-4.2-8b-w8a8-llmcompressor" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "amd/granite-4.2-8b-w8a8-llmcompressor", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/amd/granite-4.2-8b-w8a8-llmcompressor
- SGLang
How to use amd/granite-4.2-8b-w8a8-llmcompressor with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "amd/granite-4.2-8b-w8a8-llmcompressor" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "amd/granite-4.2-8b-w8a8-llmcompressor", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "amd/granite-4.2-8b-w8a8-llmcompressor" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "amd/granite-4.2-8b-w8a8-llmcompressor", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use amd/granite-4.2-8b-w8a8-llmcompressor with Docker Model Runner:
docker model run hf.co/amd/granite-4.2-8b-w8a8-llmcompressor
File size: 2,066 Bytes
7d6cbc2 | 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 | {
"model_id": "ibm-granite/granite-4.2-8b",
"registry_key": null,
"verified_recipe": false,
"reference_card": null,
"category": null,
"modality": "Text",
"architecture": "GraniteForCausalLM",
"trust_remote_code": false,
"scheme": "w8a8",
"algorithm": "W8A8: INT8 per-channel symmetric weights, dynamic per-token INT8 activations, RTN (data-free)",
"recipe": {
"loader": "causal",
"load_context": false,
"pre_import": null,
"ignore": [
"lm_head",
"re:.*lm_head"
],
"group_size": 128,
"save_processor": false,
"restore_config": false,
"save_mtp": false,
"quantization_format": null,
"calibration": "text",
"sequential_targets": null,
"post_process": null,
"num_samples": 128,
"max_seq_len": 2048,
"dataset": "HuggingFaceH4/ultrachat_200k"
},
"notes": [],
"layers": {
"quantized": {
"model.layers.*.self_attn.q_proj": 40,
"model.layers.*.self_attn.k_proj": 40,
"model.layers.*.self_attn.v_proj": 40,
"model.layers.*.self_attn.o_proj": 40,
"model.layers.*.mlp.gate_proj": 40,
"model.layers.*.mlp.up_proj": 40,
"model.layers.*.mlp.down_proj": 40
},
"kept_bf16": {
"lm_head": 1
},
"num_quantized": 280,
"num_kept_bf16": 1,
"fused_expert_tensors_left": 0
},
"source_bytes": 17583228032,
"output_bytes": 9617278368,
"output_dir": "/proj/xcohdstaff7/ravchand/quant/6.2_quant_5199/granite-4.2-8b/granite-4.2-8b-w8a8-llmcompressor",
"post_process_dir": null,
"smoke_test": null,
"shape_dtype_validation": {
"ok": true,
"log": "/proj/xcohdstaff7/ravchand/quant/6.2_quant_5199/granite-4.2-8b/granite-4.2-8b-w8a8-llmcompressor/shape_dtype_validation.log",
"num_quantized_modules": 280,
"num_non_quantized_modules": 83,
"errors": []
},
"versions": {
"llmcompressor": "0.14.0",
"compressed-tensors": "0.19.0",
"transformers": "5.17.0",
"torch": "2.14.0+cpu",
"datasets": "5.0.1"
},
"quantization_seconds": 204.9,
"total_seconds": 495.8
}
|