Views
No views yet
1from vllm import LLM, SamplingParams
2from transformers import AutoTokenizer
3
4model_id = "neuralmagic/Meta-Llama-3.1-405B-Instruct-FP8-dynamic"
5number_gpus = 8
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, max_model_len=4096)
19
20outputs = llm.generate(prompts, sampling_params)
21
22generated_text = outputs[0].outputs[0].text
23print(generated_text)1import torch
2
3from transformers import AutoTokenizer
4
5from llmcompressor.transformers import SparseAutoModelForCausalLM, oneshot
6from llmcompressor.transformers.compression.helpers import ( # noqa
7 calculate_offload_device_map,
8 custom_offload_device_map,
9)
10
11recipe = """
12quant_stage:
13 quant_modifiers:
14 QuantizationModifier:
15 ignore: ["lm_head"]
16 config_groups:
17 group_0:
18 weights:
19 num_bits: 8
20 type: float
21 strategy: channel
22 dynamic: false
23 symmetric: true
24 input_activations:
25 num_bits: 8
26 type: float
27 strategy: token
28 dynamic: true
29 symmetric: true
30 targets: ["Linear"]
31"""
32
33model_stub = "meta-llama/Meta-Llama-3.1-405B-Instruct"
34model_name = model_stub.split("/")[-1]
35
36device_map = calculate_offload_device_map(
37 model_stub, reserve_for_hessians=False, num_gpus=8, torch_dtype="auto"
38)
39
40model = SparseAutoModelForCausalLM.from_pretrained(
41 model_stub, torch_dtype="auto", device_map=device_map
42)
43
44output_dir = f"./{model_name}-FP8-dynamic"
45
46oneshot(
47 model=model,
48 recipe=recipe,
49 output_dir=output_dir,
50 save_compressed=True,
51 tokenizer=AutoTokenizer.from_pretrained(model_stub),
52)| Benchmark | Meta-Llama-3.1-405B-Instruct | Meta-Llama-3.1-405B-Instruct-FP8-dynamic (this model) | Recovery |
| Arena Hard | 67.4 (67.3 / 67.5) | 66.7 (66.7 / 66.6) | 99.0% |
| OpenLLM v1 | |||
| MMLU (5-shot) | 87.4 | 87.5 | 100.0% |
| MMLU-cot (0-shot) | 88.1 | 88.1 | 100.0% |
| ARC Challenge (0-shot) | 95.0 | 95.0 | 100.0% |
| GSM-8K-cot (8-shot, strict-match) | 96.0 | 95.8 | 99.8% |
| Hellaswag (10-shot) | 88.5 | 88.5 | 99.9% |
| Winogrande (5-shot) | 87.2 | 88.0 | 100.9% |
| TruthfulQA (0-shot, mc2) | 65.3 | 65.3 | 99.9% |
| Average | 86.8 | 86.9 | 100.0% |
| OpenLLM v2 | |||
| MMLU-Pro (5-shot) | 59.7 | 59.4 | 99.4% |
| IFEval (0-shot) | 87.7 | 86.8 | 99.0% |
| BBH (3-shot) | 67.0 | 67.1 | 100.1% |
| Math-|v|-5 (4-shot) | 39.0 | 38.8 | 99.7% |
| GPQA (0-shot) | 19.5 | 19.0 | 97.4% |
| MuSR (0-shot) | 19.5 | 20.8 | 106.9% |
| Average | 48.7 | 48.7 | 99.9% |
| Coding | |||
| HumanEval pass@1 | 86.8 | 87.0 | 100.2% |
| HumanEval+ pass@1 | 80.1 | 81.0 | 101.1% |
lm_eval \
--model vllm \
--model_args pretrained="neuralmagic/Meta-Llama-3.1-405B-Instruct-FP8-dynamic",dtype=auto,add_bos_token=True,max_model_len=4096,max_gen_toks=10,tensor_parallel_size=8 \
--tasks mmlu_llama_3.1_instruct \
--apply_chat_template \
--fewshot_as_multiturn \
--num_fewshot 5 \
--batch_size autolm_eval \
--model vllm \
--model_args pretrained="neuralmagic/Meta-Llama-3.1-405B-Instruct-FP8-dynamic",dtype=auto,add_bos_token=True,max_model_len=4096,max_gen_toks=1024,tensor_parallel_size=8 \
--tasks mmlu_cot_0shot_llama_3.1_instruct \
--apply_chat_template \
--num_fewshot 0 \
--batch_size autolm_eval \
--model vllm \
--model_args pretrained="neuralmagic/Meta-Llama-3.1-405B-Instruct-FP8-dynamic",dtype=auto,add_bos_token=True,max_model_len=4096,tensor_parallel_size=8 \
--tasks arc_challenge_llama_3.1_instruct \
--apply_chat_template \
--num_fewshot 0 \
--batch_size autolm_eval \
--model vllm \
--model_args pretrained="neuralmagic/Meta-Llama-3.1-405B-Instruct-FP8-dynamic",dtype=auto,add_bos_token=True,max_model_len=4096,tensor_parallel_size=8 \
--tasks gsm8k_cot_llama_3.1_instruct \
--apply_chat_template \
--fewshot_as_multiturn \
--num_fewshot 8 \
--batch_size autolm_eval \
--model vllm \
--model_args pretrained="neuralmagic/Meta-Llama-3.1-405B-Instruct-FP8-dynamic",dtype=auto,add_bos_token=True,max_model_len=4096,tensor_parallel_size=8 \
--tasks hellaswag \
--num_fewshot 10 \
--batch_size autolm_eval \
--model vllm \
--model_args pretrained="neuralmagic/Meta-Llama-3.1-405B-Instruct-FP8-dynamic",dtype=auto,add_bos_token=True,max_model_len=4096,tensor_parallel_size=8 \
--tasks winogrande \
--num_fewshot 5 \
--batch_size autolm_eval \
--model vllm \
--model_args pretrained="neuralmagic/Meta-Llama-3.1-405B-Instruct-FP8-dynamic",dtype=auto,add_bos_token=True,max_model_len=4096,tensor_parallel_size=8 \
--tasks truthfulqa \
--num_fewshot 0 \
--batch_size autolm_eval \
--model vllm \
--model_args pretrained="neuralmagic/Meta-Llama-3.1-405B-Instruct-FP8-dynamic",dtype=auto,max_model_len=4096,tensor_parallel_size=8,enable_chunked_prefill=True \
--apply_chat_template \
--fewshot_as_multiturn \
--tasks leaderboard \
--batch_size autopython3 codegen/generate.py \
--model neuralmagic/Meta-Llama-3.1-405B-Instruct-FP8-dynamic \
--bs 16 \
--temperature 0.2 \
--n_samples 50 \
--root "." \
--dataset humaneval \
--tp 8python3 evalplus/sanitize.py \
humaneval/neuralmagic--Meta-Llama-3.1-405B-Instruct-FP8-dynamic_vllm_temp_0.2evalplus.evaluate \
--dataset humaneval \
--samples humaneval/neuralmagic--Meta-Llama-3.1-405B-Instruct-FP8-dynamic_vllm_temp_0.2-sanitized