Views
No views yet
lm_head onlypip install vllm>=0.6.01from vllm import LLM, SamplingParams
2
3# Load the NVFP4 W4A4 quantized model
4llm = LLM(
5 model="JongYeop/Llama-3.1-8B-Instruct-NVFP4-W4A4",
6 quantization="fp4" # or "nvfp4"
7)
8
9# Generate text
10prompts = ["Hello, my name is"]
11sampling_params = SamplingParams(temperature=0.7, top_p=0.9, max_tokens=100)
12outputs = llm.generate(prompts, sampling_params)
13
14for output in outputs:
15 print(output.outputs[0].text)1from transformers import AutoTokenizer, AutoModelForCausalLM
2
3tokenizer = AutoTokenizer.from_pretrained("JongYeop/Llama-3.1-8B-Instruct-NVFP4-W4A4")
4model = AutoModelForCausalLM.from_pretrained(
5 "JongYeop/Llama-3.1-8B-Instruct-NVFP4-W4A4",
6 device_map="auto"
7)
8
9messages = [
10 {"role": "system", "content": "You are a helpful assistant."},
11 {"role": "user", "content": "What is the capital of France?"}
12]
13
14input_ids = tokenizer.apply_chat_template(messages, return_tensors="pt").to(model.device)
15output = model.generate(input_ids, max_new_tokens=100)
16print(tokenizer.decode(output[0], skip_special_tokens=True))recipe.yaml.1quant_stage:
2 quant_modifiers:
3 QuantizationModifier:
4 ignore: ["lm_head"]
5 scheme: "NVFP4" # NVIDIA FP4 format
6 targets: ["Linear"]| Format | Model Size | Compression | KV Cache | Notes |
|---|---|---|---|---|
| BF16 (Original) | ~16GB | 1.0x | bf16 | Full precision |
| FP8 W8A8 | ~8.5GB | 1.9x | bf16 | Good balance |
| NVFP4 W4A4 | ~5.7GB | 2.8x | bf16 | Higher compression |
| FP8 W8A8+KV | ~8.0GB | 2.0x | fp8 | Full quantization |
1@software{llm-compressor,
2 title = {LLM Compressor},
3 author = {vLLM Team},
4 url = {https://github.com/vllm-project/llm-compressor},
5 year = {2024}
6}
7
8@article{llama3,
9 title={Llama 3 Model Card},
10 author={AI@Meta},
11 year={2024},
12 url={https://github.com/meta-llama/llama3}
13}