| 1 | # GGUF |
| 2 | |
| 3 | !!! warning |
| 4 | Please note that GGUF support in vLLM is highly experimental and under-optimized at the moment, it might be incompatible with other features. Currently, you can use GGUF as a way to reduce memory footprint. If you encounter any issues, please report them to the vLLM team. |
| 5 | |
| 6 | !!! note |
| 7 | GGUF support has migrated to OOT [vllm-gguf-plugin](https://github.com/vllm-project/vllm-gguf-plugin). Make sure you have GGUF plugin installed before serving a GGUF model. |
| 8 | |
| 9 | Before serving a GGUF model, make sure to install the [vllm-gguf-plugin](https://github.com/vllm-project/vllm-gguf-plugin): |
| 10 | |
| 11 | ```bash |
| 12 | uv pip install vllm-gguf-plugin |
| 13 | ``` |
| 14 | |
| 15 | To run a GGUF model with vLLM, you can use the `repo_id:quant_type` format to load directly from HuggingFace. For example, to load a Q4_K_M quantized model from [unsloth/Qwen3-0.6B-GGUF](https://huggingface.co/unsloth/Qwen3-0.6B-GGUF): |
| 16 | |
| 17 | ```bash |
| 18 | # We recommend using the tokenizer from base model to avoid long-time and buggy tokenizer conversion. |
| 19 | vllm serve unsloth/Qwen3-0.6B-GGUF:Q4_K_M --tokenizer Qwen/Qwen3-0.6B |
| 20 | ``` |
| 21 | |
| 22 | You can also add `--tensor-parallel-size 2` to enable tensor parallelism inference with 2 GPUs: |
| 23 | |
| 24 | ```bash |
| 25 | vllm serve unsloth/Qwen3-0.6B-GGUF:Q4_K_M \ |
| 26 | --tokenizer Qwen/Qwen3-0.6B \ |
| 27 | --tensor-parallel-size 2 |
| 28 | ``` |
| 29 | |
| 30 | Alternatively, you can download and use a local GGUF file: |
| 31 | |
| 32 | ```bash |
| 33 | wget https://huggingface.co/unsloth/Qwen3-0.6B-GGUF/resolve/main/Qwen3-0.6B-Q4_K_M.gguf |
| 34 | vllm serve ./Qwen3-0.6B-Q4_K_M.gguf --tokenizer Qwen/Qwen3-0.6B |
| 35 | ``` |
| 36 | |
| 37 | !!! warning |
| 38 | We recommend using the tokenizer from base model instead of GGUF model. Because the tokenizer conversion from GGUF is time-consuming and unstable, especially for some models with large vocab size. |
| 39 | |
| 40 | GGUF assumes that HuggingFace can convert the metadata to a config file. In case HuggingFace doesn't support your model you can manually create a config and pass it as hf-config-path |
| 41 | |
| 42 | ```bash |
| 43 | # If your model is not supported by HuggingFace you can manually provide a HuggingFace compatible config path |
| 44 | vllm serve unsloth/Qwen3-0.6B-GGUF:Q4_K_M \ |
| 45 | --tokenizer Qwen/Qwen3-0.6B \ |
| 46 | --hf-config-path Qwen/Qwen3-0.6B |
| 47 | ``` |
| 48 | |
| 49 | You can also use the GGUF model directly through the LLM entrypoint: |
| 50 | |
| 51 | ??? code |
| 52 | |
| 53 | ```python |
| 54 | from vllm import LLM, SamplingParams |
| 55 | |
| 56 | # In this script, we demonstrate how to pass input to the chat method: |
| 57 | conversation = [ |
| 58 | { |
| 59 | "role": "system", |
| 60 | "content": "You are a helpful assistant", |
| 61 | }, |
| 62 | { |
| 63 | "role": "user", |
| 64 | "content": "Hello", |
| 65 | }, |
| 66 | { |
| 67 | "role": "assistant", |
| 68 | "content": "Hello! How can I assist you today?", |
| 69 | }, |
| 70 | { |
| 71 | "role": "user", |
| 72 | "content": "Write an essay about the importance of higher education.", |
| 73 | }, |
| 74 | ] |
| 75 | |
| 76 | # Create a sampling params object. |
| 77 | sampling_params = SamplingParams(temperature=0.8, top_p=0.95) |
| 78 | |
| 79 | # Create an LLM using repo_id:quant_type format. |
| 80 | llm = LLM( |
| 81 | model="unsloth/Qwen3-0.6B-GGUF:Q4_K_M", |
| 82 | tokenizer="Qwen/Qwen3-0.6B", |
| 83 | ) |
| 84 | # Generate texts from the prompts. The output is a list of RequestOutput objects |
| 85 | # that contain the prompt, generated text, and other information. |
| 86 | outputs = llm.chat(conversation, sampling_params) |
| 87 | |
| 88 | # Print the outputs. |
| 89 | for output in outputs: |
| 90 | prompt = output.prompt |
| 91 | generated_text = output.outputs[0].text |
| 92 | print(f"Prompt: {prompt!r}, Generated text: {generated_text!r}") |
| 93 | ``` |