Text Generation
Transformers
Safetensors
English
granite
w8a8
int8
vllm
8-bit precision
compressed-tensors
Instructions to use RedHatAI/granite-3.1-2b-base-quantized.w8a8 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use RedHatAI/granite-3.1-2b-base-quantized.w8a8 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="RedHatAI/granite-3.1-2b-base-quantized.w8a8")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("RedHatAI/granite-3.1-2b-base-quantized.w8a8") model = AutoModelForCausalLM.from_pretrained("RedHatAI/granite-3.1-2b-base-quantized.w8a8", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use RedHatAI/granite-3.1-2b-base-quantized.w8a8 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "RedHatAI/granite-3.1-2b-base-quantized.w8a8" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "RedHatAI/granite-3.1-2b-base-quantized.w8a8", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/RedHatAI/granite-3.1-2b-base-quantized.w8a8
- SGLang
How to use RedHatAI/granite-3.1-2b-base-quantized.w8a8 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 "RedHatAI/granite-3.1-2b-base-quantized.w8a8" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "RedHatAI/granite-3.1-2b-base-quantized.w8a8", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "RedHatAI/granite-3.1-2b-base-quantized.w8a8" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "RedHatAI/granite-3.1-2b-base-quantized.w8a8", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use RedHatAI/granite-3.1-2b-base-quantized.w8a8 with Docker Model Runner:
docker model run hf.co/RedHatAI/granite-3.1-2b-base-quantized.w8a8
Download config.json from RedHatAI/granite-3.1-2b-base-quantized.w8a8: direct link, hf CLI and curl.
- Browser
- Download file 1.91 kB
-
https://huggingface.co/RedHatAI/granite-3.1-2b-base-quantized.w8a8/resolve/main/config.json
- Command line
-
hf download hf://RedHatAI/granite-3.1-2b-base-quantized.w8a8/config.json
-
curl -L -o config.json https://huggingface.co/RedHatAI/granite-3.1-2b-base-quantized.w8a8/resolve/main/config.json
1.91 kB
| { | |
| "_name_or_path": "ibm-granite/granite-3.1-2b-base", | |
| "architectures": [ | |
| "GraniteForCausalLM" | |
| ], | |
| "attention_bias": false, | |
| "attention_dropout": 0.1, | |
| "attention_multiplier": 0.015625, | |
| "bos_token_id": 0, | |
| "embedding_multiplier": 12.0, | |
| "eos_token_id": 0, | |
| "hidden_act": "silu", | |
| "hidden_size": 2048, | |
| "initializer_range": 0.02, | |
| "intermediate_size": 8192, | |
| "logits_scaling": 8.0, | |
| "max_position_embeddings": 131072, | |
| "mlp_bias": false, | |
| "model_type": "granite", | |
| "num_attention_heads": 32, | |
| "num_hidden_layers": 40, | |
| "num_key_value_heads": 8, | |
| "pad_token_id": 0, | |
| "quantization_config": { | |
| "config_groups": { | |
| "group_0": { | |
| "input_activations": { | |
| "actorder": null, | |
| "block_structure": null, | |
| "dynamic": true, | |
| "group_size": null, | |
| "num_bits": 8, | |
| "observer": null, | |
| "observer_kwargs": {}, | |
| "strategy": "token", | |
| "symmetric": true, | |
| "type": "int" | |
| }, | |
| "output_activations": null, | |
| "targets": [ | |
| "Linear" | |
| ], | |
| "weights": { | |
| "actorder": null, | |
| "block_structure": null, | |
| "dynamic": false, | |
| "group_size": null, | |
| "num_bits": 8, | |
| "observer": "mse", | |
| "observer_kwargs": {}, | |
| "strategy": "channel", | |
| "symmetric": true, | |
| "type": "int" | |
| } | |
| } | |
| }, | |
| "format": "int-quantized", | |
| "global_compression_ratio": 1.5301580068100984, | |
| "ignore": [ | |
| "lm_head" | |
| ], | |
| "kv_cache_scheme": null, | |
| "quant_method": "compressed-tensors", | |
| "quantization_status": "compressed" | |
| }, | |
| "residual_multiplier": 0.22, | |
| "rms_norm_eps": 1e-05, | |
| "rope_scaling": null, | |
| "rope_theta": 5000000.0, | |
| "tie_word_embeddings": true, | |
| "torch_dtype": "bfloat16", | |
| "transformers_version": "4.47.1", | |
| "use_cache": true, | |
| "vocab_size": 49152 | |
| } | |