Views
No views yet
1from vllm import LLM, SamplingParams
2from transformers import AutoTokenizer
3
4model_id = "RedHatAI/Qwen3-30B-A3B-Thinking-2507.w4a16"
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)1from llmcompressor.modifiers.quantization import GPTQModifier
2from llmcompressor.transformers import oneshot
3from transformers import AutoModelForCausalLM, AutoTokenizer
4
5# Load model
6model_stub = "Qwen/Qwen3-30B-A3B-Thinking"
7model_name = model_stub.split("/")[-1]
8
9num_samples = 1024
10max_seq_len = 8192
11
12model = AutoModelForCausalLM.from_pretrained(model_stub)
13
14tokenizer = AutoTokenizer.from_pretrained(model_stub)
15
16def preprocess_fn(example):
17 return {"text": tokenizer.apply_chat_template(example["messages"], add_generation_prompt=False, tokenize=False)}
18
19ds = load_dataset("neuralmagic/LLM_compression_calibration", split="train")
20ds = ds.map(preprocess_fn)
21
22# Configure the quantization algorithm and scheme
23recipe = GPTQModifier(
24 ignore: ["lm_head"]
25 config_groups={"group_0": {"targets": ["Linear"], "weights": { "num_bits": 4, "type": int, "strategy": "group", "group_size": 128, "symmetric": true, "dynamic": false, "observer": "mse" } } },
26 dampening_frac=0.01,
27)
28
29# Apply quantization
30oneshot(
31 model=model,
32 dataset=ds,
33 recipe=recipe,
34 max_seq_length=max_seq_len,
35 num_calibration_samples=num_samples,
36)
37
38# Save to disk in compressed-tensors format
39save_path = model_name + "-quantized.w4a16"
40model.save_pretrained(save_path)
41tokenizer.save_pretrained(save_path)
42print(f"Model and tokenizer saved to: {save_path}")vllm serve RedHatAI/Qwen3-30B-A3B-Thinking-2507.w4a16 --max-model-len 262144 --reasoning-parser deepseek_r1lm_eval --model local-chat-completions \
--tasks mmlu_pro_chat \
--model_args "model=RedHatAI/Qwen3-30B-A3B-Thinking-2507.w4a16,max_length=262144,base_url=http://0.0.0.0:8000/v1/chat/completions,num_concurrent=64,max_retries=3,tokenized_requests=False,tokenizer_backend=None,timeout=1200" \
--num_fewshot 0 \
--apply_chat_template \
--gen_kwargs "do_sample=True,temperature=0.6,top_p=0.95,top_k=20,min_p=0.0,max_gen_toks=64000lm_eval --model local-chat-completions \
--tasks ifeval \
--model_args "model=RedHatAI/Qwen3-30B-A3B-Thinking-2507.w4a16,max_length=262144,base_url=http://0.0.0.0:8000/v1/chat/completions,num_concurrent=64,max_retries=3,tokenized_requests=False,tokenizer_backend=None,timeout=1200" \
--num_fewshot 0 \
--apply_chat_template \
--gen_kwargs "do_sample=True,temperature=0.6,top_p=0.95,top_k=20,min_p=0.0,max_gen_toks=64000lm_eval --model local-chat-completions \
--tasks gsm8k_platinum_cot_llama \
--model_args "model=RedHatAI/Qwen3-30B-A3B-Thinking-2507.w4a16,max_length=262144,base_url=http://0.0.0.0:8000/v1/chat/completions,num_concurrent=64,max_retries=3,tokenized_requests=False,tokenizer_backend=None,timeout=1200" \
--num_fewshot 0 \
--apply_chat_template \
--gen_kwargs "do_sample=True,temperature=0.6,top_p=0.95,top_k=20,min_p=0.0,max_gen_toks=640001model_parameters:
2 model_name: RedHatAI/Qwen3-30B-A3B-Thinking-2507.w4a16
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: 32000lighteval endpoint litellm lighteval_model_arguments.yaml \
"aime25|0,math_500|0,gpqa:diamond|0"| Benchmark | Qwen3-30B-A3B Thinking | Qwen3-30B-A3B Thinking.w4a16 (this model) | Recovery (%) |
|---|---|---|---|
| GSM8k Platinum (0-shot) | 85.55 | 72.65 | 84.91 |
| MMLU-Pro (0-shot) | 80.71 | 79.06 | 97.96 |
| IfEval (0-shot) | 90.09 | 90.29 | 100.22 |
| AIME 2025 | 86.67 | 83.33 | 96.15 |
| GPQA diamond | 71.50 | 71.59 | 100.12 |
| Math 500 | 90.75 | 93.10 | 102.59 |