Views
No views yet
1from vllm import LLM, SamplingParams
2from transformers import AutoTokenizer
3
4model_id = "RedHatAI/GLM-4.6-FP8-dynamic"
5number_gpus = 4
6
7sampling_params = SamplingParams(temperature=0.6, top_p=0.9, max_tokens=256)
8
9tokenizer = AutoTokenizer.from_pretrained(model_id)
10
11messages = [
12 {"role": "system", "content": "You are a pirate chatbot who always responds in pirate speak!"},
13 {"role": "user", "content": "Who are you?"},
14]
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 transformers import AutoModelForCausalLM, AutoTokenizer
2
3from llmcompressor import oneshot
4from llmcompressor.modifiers.quantization import QuantizationModifier
5from llmcompressor.utils import dispatch_for_generation
6
7MODEL_ID = "zai-org/GLM-4.6"
8
9# Load model.
10model = AutoModelForCausalLM.from_pretrained(
11 MODEL_ID, torch_dtype="auto", trust_remote_code=True, device_map=None
12)
13tokenizer = AutoTokenizer.from_pretrained(MODEL_ID, trust_remote_code=True)
14
15# Configure the quantization algorithm and scheme.
16recipe = QuantizationModifier(
17 targets="Linear",
18 scheme="FP8_DYNAMIC",
19 ignore = [
20 "lm_head",
21 ]
22)
23
24# Apply quantization.
25# FP8_DYNAMIC uses data-free quantization, so no calibration dataset needed
26oneshot(model=model, recipe=recipe, trust_remote_code_model=True)
27
28# Save to disk in compressed-tensors format.
29SAVE_DIR = "./" + MODEL_ID.rstrip("/").split("/")[-1] + "-FP8-dynamic"
30model.save_pretrained(SAVE_DIR, save_compressed=True)
31tokenizer.save_pretrained(SAVE_DIR)
32| Category | Metric | zai-org/GLM-4.6-FP8 | RedHatAI/GLM-4.6-FP8-dynamic (this model) | Recovery | |
|---|---|---|---|---|---|
| Leaderboard | MMLU Pro | 50.65% | 50.25% | 99.21% | |
| IFEVAL | 91.97 | 92.69% | 100.78% | ||
| Reasoning | AIME25 | 96.67% | 93.33% | 96.54% | |
| Math-500 (0-shot) | 88.80% | 90.40% | 101.80% | ||
| GPQA (Diamond, 0-shot) | 81.82% | 77.78% | 95.06% |
lm_eval --model local-chat-completions \
--tasks mmlu_pro \
--model_args "model=RedHatAI/GLM-4.6-FP8-dynamic,max_length=90000,base_url=http://0.0.0.0:3758/v1/chat/completions,num_concurrent=128,max_retries=3,tokenized_requests=False,tokenizer_backend=None,timeout=1200" \
--num_fewshot 5 \
--apply_chat_template \
--fewshot_as_multiturn \
--output_path ./ \
--seed 42 \
--gen_kwargs "do_sample=True,temperature=1.0,top_p=0.95,max_gen_toks=64000"
lm_eval --model local-chat-completions \
--tasks leaderboard_ifeval \
--model_args "model=RedHatAI/GLM-4.6-FP8-dynamic,max_length=90000,base_url=http://0.0.0.0:3758/v1/chat/completions,num_concurrent=128,max_retries=3,tokenized_requests=False,tokenizer_backend=None,timeout=1200" \
--num_fewshot 5 \
--apply_chat_template \
--fewshot_as_multiturn \
--output_path ./ \
--seed 42 \
--gen_kwargs "do_sample=True,temperature=1.0,top_p=0.95,max_gen_toks=64000"litellm_config.yaml:
model_parameters:
provider: "hosted_vllm"
model_name: "hosted_vllm/redhatai-glm-4.6-FP8-dynamic"
base_url: "http://0.0.0.0:3759/v1"
api_key: ""
timeout: 3600
concurrent_requests: 128
generation_parameters:
temperature: 1.0
max_new_tokens: 131072
top_p: 0.95
seed: 0
lighteval endpoint litellm litellm_config.yaml \
"aime25|0,math_500|0,gpqa:diamond|0" \
--output-dir ./ \
--save-details