Views
No views yet

vllm serve RedHatAI/Qwen3.6-35B-A3B-NVFP4 --reasoning-parser qwen3 --moe_backend flashinfer_cutlass.1import torch
2from compressed_tensors.utils import save_mtp_tensors_to_checkpoint
3from datasets import load_dataset
4from transformers import AutoProcessor, Qwen3_5MoeForConditionalGeneration
5
6from llmcompressor import oneshot
7from llmcompressor.modifiers.quantization import QuantizationModifier
8
9# NOTE: This example requires transformers >= v5
10
11MODEL_ID = "Qwen/Qwen3.6-35B-A3B"
12
13# Load model.
14model = Qwen3_5MoeForConditionalGeneration.from_pretrained(MODEL_ID, dtype="auto")
15processor = AutoProcessor.from_pretrained(MODEL_ID)
16
17# No need to include mtp layers as they are not loaded
18# through Qwen3_5MoeForConditionalGeneration
19recipe = QuantizationModifier(
20 targets="Linear",
21 scheme="NVFP4",
22 ignore=[
23 "re:.*lm_head",
24 "re:visual.*",
25 "re:model.visual.*",
26 "re:.*mlp.gate$",
27 "re:.*embed_tokens$",
28 "re:.*shared_expert_gate$",
29 "re:.*linear_attn.*",
30 ],
31)
32
33NUM_CALIBRATION_SAMPLES = 256
34MAX_SEQUENCE_LENGTH = 4096
35
36ds = load_dataset(
37 "HuggingFaceH4/ultrachat_200k",
38 split=f"train_sft[:{NUM_CALIBRATION_SAMPLES}]",
39)
40ds = ds.select_columns(["messages"])
41ds = ds.shuffle(seed=42)
42
43
44def preprocess_function(example):
45 messages = [
46 {"role": m["role"], "content": [{"type": "text", "text": m["content"]}]}
47 for m in example["messages"]
48 ]
49 return processor.apply_chat_template(
50 messages,
51 tokenize=True,
52 return_dict=True,
53 add_generation_prompt=False,
54 processor_kwargs={
55 "return_tensors": "pt",
56 "padding": False,
57 "truncation": True,
58 "max_length": MAX_SEQUENCE_LENGTH,
59 "add_special_tokens": False,
60 },
61 )
62
63
64ds = ds.map(preprocess_function, batched=False, remove_columns=ds.column_names)
65
66
67def data_collator(batch):
68 assert len(batch) == 1
69 return {key: torch.tensor(value) for key, value in batch[0].items()}
70
71
72# Apply quantization.
73oneshot(
74 model=model,
75 recipe=recipe,
76 dataset=ds,
77 max_seq_length=MAX_SEQUENCE_LENGTH,
78 num_calibration_samples=NUM_CALIBRATION_SAMPLES,
79 moe_calibrate_all_experts=True,
80 data_collator=data_collator,
81)
82
83# Save to disk in compressed-tensors format.
84SAVE_DIR = MODEL_ID.rstrip("/").split("/")[-1] + "-NVFP4"
85model.save_pretrained(SAVE_DIR)
86processor.save_pretrained(SAVE_DIR)
87
88# MTP layers are excluded from the model through Qwen3_5MoeForConditionalGeneration
89# Save them as-is from the original checkpoint into the quantized output.
90save_mtp_tensors_to_checkpoint(source_model=MODEL_ID, dest_dir=SAVE_DIR)
91--language-model-only.| Benchmark | Qwen/Qwen3.6-35B-A3B | RedHatAI/Qwen3.6-35B-A3B-NVFP4 | Recovery (%) |
|---|---|---|---|
| GSM8k Platinum (0-shot) | 95.73 | 96.08 | 100.37 |
| IfEval (0-shot) | 93.09 | 92.45 | 99.31 |
| AIME 2025 | 92.92 | 91.25 | 98.21 |
| GPQA diamond | 84.51 | 84.68 | 100.20 |
| Math 500 | 84.80 | 85.00 | 100.24 |
| Lcb Codegeneration V6 | 77.33 | 74.67 | 96.55 |
| MMLU Pro Chat | 85.32 | 84.70 | 99.28 |
| BFCLv4 Overall | 57.83 | 56.10 | 97.01 |
| BFCLv4 Single Turn | 53.81 | 53.45 | 99.34 |
| BFCLv4 Multi-Turn | 62.25 | 58.13 | 93.38 |
| BFCLv4 Agentic | 49.91 | 49.31 | 98.80 |
| SWEBench Verified | 54.8 | 50.2 | 91.61 |
vllm serve RedHatAI/Qwen3.6-35B-A3B-NVFP4 --reasoning-parser qwen3 --language-model-only --max-model-len 96000lm_eval --model local-chat-completions \
--tasks gsm8k_platinum_cot_llama \
--model_args "model=RedHatAI/Qwen3.6-35B-A3B-NVFP4,max_length=96000,base_url=http://0.0.0.0:8000/v1/chat/completions,num_concurrent=128,max_retries=3,tokenized_requests=False,tokenizer_backend=None,timeout=2400" \
--num_fewshot 0 \
--apply_chat_template \
--output_path results.json \
--seed 42 \
--gen_kwargs "do_sample=true,temperature=1.0,top_p=0.95,top_k=20,min_p=0.0,max_gen_toks=64000,presence_penalty=1.5,repetition_penalty=1.0,seed=42"lm_eval --model local-chat-completions \
--tasks ifeval \
--model_args "model=RedHatAI/Qwen3.6-35B-A3B-NVFP4,max_length=96000,base_url=http://0.0.0.0:8000/v1/chat/completions,num_concurrent=128,max_retries=3,tokenized_requests=False,tokenizer_backend=None,timeout=2400" \
--apply_chat_template \
--output_path results.json \
--seed 42 \
--gen_kwargs "do_sample=true,temperature=1.0,top_p=0.95,top_k=20,min_p=0.0,max_gen_toks=64000,presence_penalty=1.5,repetition_penalty=1.0,seed=42"lm_eval --model local-chat-completions \
--tasks mmlu_pro_chat \
--model_args "model=RedHatAI/Qwen3.6-35B-A3B-NVFP4,max_length=96000,base_url=http://0.0.0.0:8000/v1/chat/completions,num_concurrent=128,max_retries=3,tokenized_requests=False,tokenizer_backend=None,timeout=3600" \
--num_fewshot 0 \
--apply_chat_template \
--output_path results.json \
--seed 42 \
--gen_kwargs "do_sample=true,temperature=1.0,top_p=0.95,top_k=20,min_p=0.0,max_gen_toks=64000,presence_penalty=1.5,repetition_penalty=1.0,seed=42"1model_parameters:
2 provider: "hosted_vllm"
3 model_name: "hosted_vllm/RedHatAI/Qwen3.6-35B-A3B-NVFP4"
4 base_url: "http://0.0.0.0:8000/v1"
5 api_key: ""
6 timeout: 2400
7 concurrent_requests: 64
8 generation_parameters:
9 temperature: 1.0
10 max_new_tokens: 64000
11 top_p: 0.95
12 top_k: 20
13 min_p: 0.0
14 presence_penalty: 1.5
15 repetition_penalty: 1.0
16 seed: 0lighteval endpoint litellm litellm_config.yaml \
"math_500|0,gpqa:diamond|0,lcb:codegeneration_v6|0" \
--output-dir results \
--save-detailslighteval endpoint litellm litellm_config.yaml \
"aime25|0" \
--output-dir results \
--save-detailsbfcl_eval/constants/model_config.pyapi_inference_model_map:1"Qwen3.6-35B-A3B-NVFP4": ModelConfig(
2 model_name="Qwen3.6-35B-A3B-NVFP4",
3 display_name="Qwen3.6-35B-A3B-NVFP4 (FC)",
4 url="https://huggingface.co/RedHatAI/Qwen3.6-35B-A3B-NVFP4",
5 org="Google",
6 license="Apache 2.0",
7 model_handler=OpenAICompletionsHandler,
8 input_price=None,
9 output_price=None,
10 is_fc_model=True,
11 underscore_to_dot=True,
12),bfcl_eval/constants/supported_models.py"Qwen3.6-35B-A3B-NVFP4" to the SUPPORTED_MODELS list.--served-model-name flag ensures BFCL can find the model by its registered slug).bfcl generate --model Qwen3.6-35B-A3B-NVFP4 --test-category all
bfcl evaluate --model Qwen3.6-35B-A3B-NVFP4 --test-category all