Views
No views yet
uv pip install -U git+https://github.com/vllm-project/vllm.git \
--extra-index-url https://wheels.vllm.ai/nightly \
--no-deps \
--no-cache
uv pip install compressed-tensors==0.12.3a20251114 --no-cache
uv pip install --upgrade torchvision --break-system-packages --no-cache
uv pip install cloudpickle msgspec zmq blake3 cachetools prometheus_client fastapi openai openai_harmony pybase64 llguidance diskcache xgrammar lm-format-enforcer partial-json-parser cbor2 einops gguf numba --no-cachevllm serve RedHatAI/granite-4.0-h-small-FP8-dynamic --tensor_parallel_size 11from openai import OpenAI
2
3# Modify OpenAI's API key and API base to use vLLM's API server.
4openai_api_key = "EMPTY"
5openai_api_base = "http://<your-server-host>:8000/v1"
6
7client = OpenAI(
8 api_key=openai_api_key,
9 base_url=openai_api_base,
10)
11
12model = "RedHatAI/granite-4.0-h-small-FP8-dynamic"
13
14messages = [
15 {"role": "user", "content": "Explain quantum mechanics clearly and concisely."},
16]
17
18
19outputs = client.chat.completions.create(
20 model=model,
21 messages=messages,
22)
23
24generated_text = outputs.choices[0].message.content
25print(generated_text)uv pip install git+https://github.com/vllm-project/llm-compressor.git@refs/pull/2001/head --no-cache
uv pip install --upgrade torchvision --break-system-packages --no-cache1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3from llmcompressor import oneshot
4from llmcompressor.modifiers.quantization import QuantizationModifier
5from llmcompressor.utils import dispatch_for_generation
6from llmcompressor.modeling import replace_modules_for_calibration
7from llmcompressor.modeling.granite4 import pack_3d_experts
8
9
10MODEL_ID = "ibm-granite/granite-4.0-h-small"
11
12model = AutoModelForCausalLM.from_pretrained(MODEL_ID, torch_dtype="auto")
13tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
14
15model = replace_modules_for_calibration(model)
16
17ignore_lay = ["lm_head", "re:.*block_sparse_moe.router"]
18
19recipe = QuantizationModifier(
20 targets=["Linear"],
21 scheme="FP8_DYNAMIC",
22 ignore=ignore_lay,
23)
24
25oneshot(model=model, recipe=recipe)
26
27print("========== SAMPLE GENERATION ==============")
28dispatch_for_generation(model)
29input_ids = tokenizer(
30 "Describe Large Language Model", return_tensors="pt"
31).input_ids.to(model.device)
32output = model.generate(input_ids, max_new_tokens=35)
33print(tokenizer.decode(output[0]))
34print("==========================================")
35
36SAVE_DIR = MODEL_ID.rstrip("/").split("/")[-1] + "-FP8-dynamic"
37print(f"Saving to {SAVE_DIR}")
38
39model.save_pretrained(SAVE_DIR)
40tokenizer.save_pretrained(SAVE_DIR)
41pack_3d_experts(SAVE_DIR)uv pip install -U git+https://github.com/vllm-project/vllm.git \
--extra-index-url https://wheels.vllm.ai/nightly \
--no-deps \
--no-cache
uv pip install compressed-tensors==0.12.3a20251114 --no-cache
uv pip install --upgrade torchvision --break-system-packages --no-cache
uv pip install cloudpickle msgspec zmq blake3 cachetools prometheus_client fastapi openai openai_harmony pybase64 llguidance diskcache xgrammar lm-format-enforcer partial-json-parser cbor2 einops gguf numba --no-cachelm_eval \
--model vllm \
--model_args pretrained="RedHatAI/granite-4.0-h-small-FP8-dynamic",dtype=auto,add_bos_token=True,max_model_len=16384,tensor_parallel_size=1,gpu_memory_utilization=0.9,enable_chunked_prefill=True,trust_remote_code=True \
--tasks openllm \
--write_out \
--batch_size auto \
--show_configlm_eval \
--model vllm \
--model_args pretrained="RedHatAI/granite-4.0-h-small-FP8-dynamic",dtype=auto,add_bos_token=False,max_model_len=16384,tensor_parallel_size=1,gpu_memory_utilization=0.7,disable_log_stats=True,enable_chunked_prefill=True,trust_remote_code=True \
--tasks leaderboard \
--apply_chat_template \
--fewshot_as_multiturn \
--write_out \
--batch_size auto \
--show_configevalplus.evaluate --model "RedHatAI/granite-4.0-h-small-FP8-dynamic" \
--dataset "humaneval" \
--backend vllm \
--tp 1 \
--greedy
evalplus.evaluate --model "RedHatAI/granite-4.0-h-small-FP8-dynamic" \
--dataset "mbpp" \
--backend vllm \
--tp 1 \
--greedy
| Category | Metric | ibm-granite/granite-4.0-h-small | ibm-granite/granite-4.0-h-small-FP8 | RedHatAI/granite-4.0-h-small-FP8-block | RedHatAI/granite-4.0-h-small-FP8-dynamic |
|---|---|---|---|---|---|
| OpenLLM V1 | ARC-Challenge (Acc-Norm, 25-shot) | 72.27 | 72.10 (99.76%) | 72.27 (100.00%) | 72.10 (99.76%) |
| GSM8K (Strict-Match, 5-shot) | 85.22 | 85.29 (100.09%) | 85.52 (100.36%) | 84.84 (99.56%) | |
| HellaSwag (Acc-Norm, 10-shot) | 86.08 | 85.88 (99.77%) | 85.96 (99.86%) | 85.88 (99.77%) | |
| MMLU (Acc, 5-shot) | 77.15 | 77.18 (100.03%) | 77.23 (100.09%) | 77.18 (100.03%) | |
| TruthfulQA (MC2, 0-shot) | 57.64 | 57.63 (99.99%) | 57.94 (100.52%) | 57.63 (100.00%) | |
| Winogrande (Acc, 5-shot) | 81.37 | 81.45 (100.10%) | 80.82 (99.32%) | 81.45 (100.10%) | |
| Average Score | 76.62 | 76.59 (99.96%) | 76.62 (100.00%) | 76.51 (99.86%) | |
| OpenLLM V2 | IFEval (Inst Level Strict Acc, 0-shot) | 87.53 | 87.17 (99.59%) | 86.69 (99.04%) | 87.41 (99.86%) |
| BBH (Acc-Norm, 3-shot) | 61.52 | 61.31 (99.66%) | 61.40 (99.80%) | 61.19 (99.46%) | |
| Math-Hard (Exact-Match, 4-shot) | 46.22 | 43.73 (94.61%) | 43.88 (94.93%) | 41.77 (90.36%) | |
| GPQA (Acc-Norm, 0-shot) | 35.23 | 34.98 (99.29%) | 34.23 (97.14%) | 34.23 (97.14%) | |
| MUSR (Acc-Norm, 0-shot) | 46.69 | 46.56 (99.72%) | 45.77 (98.02%) | 45.77 (98.02%) | |
| MMLU-Pro (Acc, 5-shot) | 47.99 | 47.63 (99.26%) | 47.93 (99.88%) | 47.58 (99.15%) | |
| Average Score | 54.20 | 53.56 (98.82%) | 53.32 (98.38%) | 52.99 (97.77%) |