Views
No views yet
vllm serve RedHatAI/Apertus-70B-Instruct-2509-quantized.w4a161from 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/Apertus-70B-Instruct-2509-quantized.w4a16"
13
14messages = [
15 {"role": "user", "content": "Give me a short introduction to large language model."},
16]
17
18outputs = client.chat.completions.create(
19 model=model,
20 messages=messages,
21)
22
23generated_text = outputs.choices[0].message.content
24print(generated_text)1from llmcompressor.modifiers.quantization import QuantizationModifier
2from llmcompressor.transformers import oneshot
3from transformers import AutoModelForCausalLM, AutoTokenizer
4
5# Load model
6model_stub = "swiss-ai/Apertus-70B-Instruct-2509"
7model_name = model_stub.split("/")[-1]
8
9model = AutoModelForCausalLM.from_pretrained(model_stub, dtype="auto")
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 + "-quantized.w4a16"
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/Apertus-70B-Instruct-2509-quantized.w4a16",dtype=auto,add_bos_token=True,max_model_len=4096,tensor_parallel_size=2,gpu_memory_utilization=0.2,enable_chunked_prefill=True \
--tasks openllm \
--write_out \
--batch_size auto \
--output_path output_dir \
--show_config| Category | Metric | swiss-ai/Apertus-70B-Instruct-2509 | RedHatAI/Apertus-70B-Instruct-2509-quantized.w4a16 | Recovery (%) |
|---|---|---|---|---|
| OpenLLM V1 | ARC-Challenge (Acc-Norm, 25-shot) | 70.82 | 70.65 | 99.8 |
| GSM8K (Strict-Match, 5-shot) | 73.69 | 73.45 | 99.7 | |
| HellaSwag (Acc-Norm, 10-shot) | 86.23 | 85.67 | 99.4 | |
| MMLU (Acc, 5-shot) | 69.21 | 68.25 | 98.6 | |
| TruthfulQA (MC2, 0-shot) | 60.31 | 60.55 | 100.4 | |
| Winogrande (Acc, 5-shot) | 80.74 | 80.03 | 99.1 | |
| Average Score | 73.50 | 73.10 | 99.5 |