Instructions to use INCModel4/granite-4.1-8b-W4A16-AutoRound with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use INCModel4/granite-4.1-8b-W4A16-AutoRound with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="INCModel4/granite-4.1-8b-W4A16-AutoRound") 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("INCModel4/granite-4.1-8b-W4A16-AutoRound") model = AutoModelForCausalLM.from_pretrained("INCModel4/granite-4.1-8b-W4A16-AutoRound", 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 INCModel4/granite-4.1-8b-W4A16-AutoRound with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "INCModel4/granite-4.1-8b-W4A16-AutoRound" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "INCModel4/granite-4.1-8b-W4A16-AutoRound", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/INCModel4/granite-4.1-8b-W4A16-AutoRound
- SGLang
How to use INCModel4/granite-4.1-8b-W4A16-AutoRound 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 "INCModel4/granite-4.1-8b-W4A16-AutoRound" \ --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": "INCModel4/granite-4.1-8b-W4A16-AutoRound", "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 "INCModel4/granite-4.1-8b-W4A16-AutoRound" \ --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": "INCModel4/granite-4.1-8b-W4A16-AutoRound", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use INCModel4/granite-4.1-8b-W4A16-AutoRound with Docker Model Runner:
docker model run hf.co/INCModel4/granite-4.1-8b-W4A16-AutoRound
Model Details
This model is an int4 (W4A16, group_size 128, symmetric) model of ibm-granite/granite-4.1-8b generated by intel/auto-round with 200 tuning iterations. Please follow the license of the original model.
- Quantized (W4A16): attention and MLP projections
- Kept in BF16: token embeddings, lm_head, normalization layers
How to Use
Environment
uv pip install vllm==0.33.0
uv pip install transformers==5.20.2
vLLM Usage
vllm serve INCModel4/granite-4.1-8b-W4A16-AutoRound \
--kv-cache-dtype auto \
--dtype bfloat16
Evaluation
| Benchmark | BF16 | W4A16 | Recovery |
|---|---|---|---|
| PIQA | 79.05 | 78.78 | 99.66% |
| HellaSwag | 62.84 | 61.94 | 98.57% |
| MMLU | 71.68 | 71.21 | 99.35% |
| GSM8K | 92.49 | 91.28 | 98.69% |
| Average | 76.52 | 75.80 | 99.07% |
lm_eval
lm_eval --model local-completions \
--model_args model=INCModel4/granite-4.1-8b-W4A16-AutoRound,tokenizer=ibm-granite/granite-4.1-8b,tokenizer_backend=huggingface,base_url=http://127.0.0.1:8000/v1/completions,tokenized_requests=True,num_concurrent=32,max_retries=50,timeout=1800,max_length=131073,max_gen_toks=2048,add_bos_token=False \
--tasks gsm8k --batch_size 32 --output_path results/gsm8k --log_samples --seed 42 \
--num_fewshot 5 --apply_chat_template --fewshot_as_multiturn --gen_kwargs max_gen_toks=2048
lm_eval --model local-completions \
--model_args model=INCModel4/granite-4.1-8b-W4A16-AutoRound,tokenizer=ibm-granite/granite-4.1-8b,tokenizer_backend=huggingface,base_url=http://127.0.0.1:8000/v1/completions,tokenized_requests=True,num_concurrent=32,max_retries=50,timeout=1800,max_length=131073,max_gen_toks=2048,add_bos_token=False \
--tasks piqa,mmlu,hellaswag --batch_size 32 --output_path results/piqa_mmlu_hellaswag --log_samples --seed 42
Generate the Model
auto-round \
--model_name ibm-granite/granite-4.1-8b \
--scheme W4A16 \
--iters 200 \
--nsamples 128 \
--ignore_layers lm_head \
--format auto_round \
--output_dir granite-4.1-8b-W4A16-AutoRound \
--seqlen 2048 \
--group_size 128 \
--disable_trust_remote_code
Ethical Considerations and Limitations
The model can produce factually incorrect output, and should not be relied on to produce factually accurate information. Because of the limitations of the pretrained model and the finetuning datasets, it is possible that this model could generate lewd, biased or otherwise offensive outputs. Therefore, before deploying any applications of the model, developers should perform safety testing.
Caveats and Recommendations
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. Here are a couple of useful links to learn more about Intel's AI software:
Disclaimer
The license on this model does not constitute legal advice. We are not responsible for the actions of third parties who use this model. Please consult an attorney before using this model for commercial purposes.
Cite
@article{cheng2023optimize,
title={Optimize weight rounding via signed gradient descent for the quantization of llms},
author={Cheng, Wenhua and Zhang, Weiwei and Shen, Haihao and Cai, Yiyang and He, Xin and Lv, Kaokao and Liu, Yi},
journal={arXiv preprint arXiv:2309.05516},
year={2023}
}
Signed-off-by: Sun, Xuehao xuehao.sun@intel.com
- Downloads last month
- 300
Model tree for INCModel4/granite-4.1-8b-W4A16-AutoRound
Base model
ibm-granite/granite-4.1-8b