Views
No views yet


1from vllm import LLM, SamplingParams
2from transformers import AutoTokenizer
3
4model_id = "RedHatAI/Qwen3-8B-FP8-dynamic"
5number_gpus = 1
6sampling_params = SamplingParams(temperature=0.6, top_p=0.95, top_k=20, min_p=0, max_tokens=256)
7
8messages = [
9 {"role": "user", "content": prompt}
10]
11
12tokenizer = AutoTokenizer.from_pretrained(model_id)
13
14messages = [{"role": "user", "content": "Give me a short introduction to large language model."}]
15
16prompts = tokenizer.apply_chat_template(messages, add_generation_prompt=True, tokenize=False)
17
18llm = LLM(model=model_id, tensor_parallel_size=number_gpus)
19
20outputs = llm.generate(prompts, sampling_params)
21
22generated_text = outputs[0].outputs[0].text
23print(generated_text)1podman run --rm -it --device nvidia.com/gpu=all -p 8000:8000 \
2 --ipc=host \
3--env "HUGGING_FACE_HUB_TOKEN=$HF_TOKEN" \
4--env "HF_HUB_OFFLINE=0" -v ~/.cache/vllm:/home/vllm/.cache \
5--name=vllm \
6registry.access.redhat.com/rhaiis/rh-vllm-cuda \
7vllm serve \
8--tensor-parallel-size 8 \
9--max-model-len 32768 \
10--enforce-eager --model RedHatAI/Qwen3-8B-FP8-dynamic1# Setting up vllm server with ServingRuntime
2# Save as: vllm-servingruntime.yaml
3apiVersion: serving.kserve.io/v1alpha1
4kind: ServingRuntime
5metadata:
6 name: vllm-cuda-runtime # OPTIONAL CHANGE: set a unique name
7 annotations:
8 openshift.io/display-name: vLLM NVIDIA GPU ServingRuntime for KServe
9 opendatahub.io/recommended-accelerators: '["nvidia.com/gpu"]'
10 labels:
11 opendatahub.io/dashboard: 'true'
12spec:
13 annotations:
14 prometheus.io/port: '8080'
15 prometheus.io/path: '/metrics'
16 multiModel: false
17 supportedModelFormats:
18 - autoSelect: true
19 name: vLLM
20 containers:
21 - name: kserve-container
22 image: quay.io/modh/vllm:rhoai-2.24-cuda # CHANGE if needed. If AMD: quay.io/modh/vllm:rhoai-2.24-rocm
23 command:
24 - python
25 - -m
26 - vllm.entrypoints.openai.api_server
27 args:
28 - "--port=8080"
29 - "--model=/mnt/models"
30 - "--served-model-name={{.Name}}"
31 env:
32 - name: HF_HOME
33 value: /tmp/hf_home
34 ports:
35 - containerPort: 8080
36 protocol: TCP1# Attach model to vllm server. This is an NVIDIA template
2# Save as: inferenceservice.yaml
3apiVersion: serving.kserve.io/v1beta1
4kind: InferenceService
5metadata:
6 annotations:
7 openshift.io/display-name: Qwen3-8B-FP8-dynamic # OPTIONAL CHANGE
8 serving.kserve.io/deploymentMode: RawDeployment
9 name: Qwen3-8B-FP8-dynamic # specify model name. This value will be used to invoke the model in the payload
10 labels:
11 opendatahub.io/dashboard: 'true'
12spec:
13 predictor:
14 maxReplicas: 1
15 minReplicas: 1
16 model:
17 modelFormat:
18 name: vLLM
19 name: ''
20 resources:
21 limits:
22 cpu: '2' # this is model specific
23 memory: 8Gi # this is model specific
24 nvidia.com/gpu: '1' # this is accelerator specific
25 requests: # same comment for this block
26 cpu: '1'
27 memory: 4Gi
28 nvidia.com/gpu: '1'
29 runtime: vllm-cuda-runtime # must match the ServingRuntime name above
30 storageUri: oci://registry.redhat.io/rhelai1/modelcar-qwen3-8b-fp8-dynamic:1.5
31 tolerations:
32 - effect: NoSchedule
33 key: nvidia.com/gpu
34 operator: Exists1# make sure first to be in the project where you want to deploy the model
2# oc project <project-name>
3
4# apply both resources to run model
5
6# Apply the ServingRuntime
7oc apply -f vllm-servingruntime.yaml
8
9# Apply the InferenceService
10oc apply -f qwen-inferenceservice.yaml1# Replace <inference-service-name> and <cluster-ingress-domain> below:
2# - Run `oc get inferenceservice` to find your URL if unsure.
3
4# Call the server using curl:
5curl https://<inference-service-name>-predictor-default.<domain>/v1/chat/completions
6 -H "Content-Type: application/json" \
7 -d '{
8 "model": "Qwen3-8B-FP8-dynamic",
9 "stream": true,
10 "stream_options": {
11 "include_usage": true
12 },
13 "max_tokens": 1,
14 "messages": [
15 {
16 "role": "user",
17 "content": "How can a bee fly when its wings are so small?"
18 }
19 ]
20}'
211from llmcompressor.modifiers.quantization import QuantizationModifier
2from llmcompressor.transformers import oneshot
3from transformers import AutoModelForCausalLM, AutoTokenizer
4
5# Load model
6model_stub = "Qwen/Qwen3-8B"
7model_name = model_stub.split("/")[-1]
8
9model = AutoModelForCausalLM.from_pretrained(model_stub)
10
11tokenizer = AutoTokenizer.from_pretrained(model_stub)
12
13# Configure the quantization algorithm and scheme
14recipe = QuantizationModifier(
15 ignore=["lm_head"],
16 targets="Linear",
17 scheme="FP8_dynamic",
18)
19
20# Apply quantization
21oneshot(
22 model=model,
23 recipe=recipe,
24)
25
26# Save to disk in compressed-tensors format
27save_path = model_name + "-FP8-dynamic"
28model.save_pretrained(save_path)
29tokenizer.save_pretrained(save_path)
30print(f"Model and tokenizer saved to: {save_path}")lm_eval \
--model vllm \
--model_args pretrained="RedHatAI/Qwen3-8B-FP8-dynamic",dtype=auto,gpu_memory_utilization=0.5,max_model_len=8192,enable_chunk_prefill=True,tensor_parallel_size=1 \
--tasks openllm \
--apply_chat_template\
--fewshot_as_multiturn \
--batch_size autolm_eval \
--model vllm \
--model_args pretrained="RedHatAI/Qwen3-8B-FP8-dynamic",dtype=auto,gpu_memory_utilization=0.5,max_model_len=8192,enable_chunk_prefill=True,tensor_parallel_size=1 \
--tasks mgsm \
--apply_chat_template\
--batch_size autolm_eval \
--model vllm \
--model_args pretrained="RedHatAI/Qwen3-8B-FP8-dynamic",dtype=auto,gpu_memory_utilization=0.5,max_model_len=16384,enable_chunk_prefill=True,tensor_parallel_size=1 \
--tasks leaderboard \
--apply_chat_template\
--fewshot_as_multiturn \
--batch_size auto1model_parameters:
2 model_name: RedHatAI/Qwen3-8B-FP8-dynamic
3 dtype: auto
4 gpu_memory_utilization: 0.9
5 max_model_length: 40960
6 generation_parameters:
7 temperature: 0.6
8 top_k: 20
9 min_p: 0.0
10 top_p: 0.95
11 max_new_tokens: 32768lighteval vllm \
--model_args lighteval_model_arguments.yaml \
--tasks lighteval|aime24|0|0 \
--use_chat_template = truelighteval vllm \
--model_args lighteval_model_arguments.yaml \
--tasks lighteval|aime25|0|0 \
--use_chat_template = truelighteval vllm \
--model_args lighteval_model_arguments.yaml \
--tasks lighteval|math_500|0|0 \
--use_chat_template = truelighteval vllm \
--model_args lighteval_model_arguments.yaml \
--tasks lighteval|gpqa:diamond|0|0 \
--use_chat_template = truelighteval vllm \
--model_args lighteval_model_arguments.yaml \
--tasks extended|lcb:codegeneration \
--use_chat_template = true| Category | Benchmark | Qwen3-8B | Qwen3-8B-FP8-dynamic (this model) | Recovery |
|---|---|---|---|---|
| OpenLLM v1 | MMLU (5-shot) | 71.95 | 72.30 | 100.5% |
| ARC Challenge (25-shot) | 61.69 | 61.60 | 99.9% | |
| GSM-8K (5-shot, strict-match) | 75.97 | 80.52 | 106.0% | |
| Hellaswag (10-shot) | 56.52 | 55.95 | 99.0% | |
| Winogrande (5-shot) | 65.98 | 66.22 | 100.4% | |
| TruthfulQA (0-shot, mc2) | 53.17 | 52.39 | 98.5% | |
| Average | 64.21 | 64.83 | 101.0% | |
| OpenLLM v2 | MMLU-Pro (5-shot) | 34.57 | 37.82 | 109.4% |
| IFEval (0-shot) | 84.77 | 84.56 | 99.8% | |
| BBH (3-shot) | 25.47 | 27.20 | 106.8% | |
| Math-lvl-5 (4-shot) | 51.05 | 51.90 | 101.7% | |
| GPQA (0-shot) | 0.00 | 0.00 | --- | |
| MuSR (0-shot) | 10.02 | 10.65 | --- | |
| Average | 34.31 | 35.35 | 103.0% | |
| Multilingual | MGSM (0-shot) | 25.97 | 25.80 | 99.4% |
| Reasoning (generation) | AIME 2024 | 74.58 | 76.35 | 102.4% |
| AIME 2025 | 65.21 | 63.75 | 97.8% | |
| GPQA diamond | 58.59 | 61.11 | 104.3% | |
| Math-lvl-5 | 97.60 | 96.60 | 99.0% | |
| LiveCodeBench | 56.27 | 56.60 | 100.6% |