# vLLM 引擎参数

vLLM 引擎参数、标志、选项，用于在 vLLM 上部署模型。

<table><thead><tr><th width="212.9000244140625">参数</th><th>示例与使用场景</th></tr></thead><tbody><tr><td><strong><code>--gpu-memory-utilization</code></strong></td><td>默认 0.9。vLLM 可使用的显存占比。若出现内存不足则降低该值。可以尝试设置为 0.95 或 0.97。</td></tr><tr><td><strong><code>--max-model-len</code></strong></td><td>设置最大序列长度。若出现内存不足请减小该值！例如设置 <strong><code>--max-model-len 32768</code></strong> 以仅使用 32K 序列长度。</td></tr><tr><td><strong><code>--quantization</code></strong></td><td>使用 fp8 进行动态 float8 量化。与 <strong><code>--kv-cache-dtype</code></strong> fp8 一起使用以启用 float8 KV 缓存。</td></tr><tr><td><strong><code>--kv-cache-dtype</code></strong></td><td>使用 <code>fp8</code> 作为 float8 KV 缓存可将内存使用量减少约 50%。</td></tr><tr><td><strong><code>--port</code></strong></td><td>默认是 8000。如何访问 vLLM 的本地地址，例如 http://localhost:8000</td></tr><tr><td><strong><code>--api-key</code></strong></td><td>可选 - 设置访问模型的密码（或不设置密码）。</td></tr><tr><td><strong><code>--tensor-parallel-size</code></strong></td><td>默认是 1。将模型在张量维度上拆分。设置为你使用的 GPU 数量 - 如果有 4 块 GPU 就设为 4；8 块就设为 8。需要有 NCCL，否则可能会很慢。</td></tr><tr><td><strong><code>--pipeline-parallel-size</code></strong></td><td>默认是 1。将模型在层维度上拆分。与 <strong><code>--pipeline-parallel-size</code></strong> 一起使用，其中 TP 用于每个节点内部，PP 用于跨多节点设置（将 PP 设为节点数）</td></tr><tr><td><strong><code>--enable-lora</code></strong></td><td>启用 LoRA 服务。适用于部署 Unsloth 微调的 LoRA。</td></tr><tr><td><strong><code>--max-loras</code></strong></td><td>同时想要部署的 LoRA 数量。设置为 1 表示 1 个 LoRA，或例如 16。它是一个队列，因此 LoRA 可以热插拔。</td></tr><tr><td><strong><code>--max-lora-rank</code></strong></td><td>所有 LoRA 的最大秩。可能的选项有 <code>8</code>, <code>16</code>, <code>32</code>, <code>64</code>, <code>128</code>, <code>256</code>, <code>320</code>, <code>512</code></td></tr><tr><td><strong><code>--dtype</code></strong></td><td>允许 <code>auto</code>, <code>bfloat16</code>, <code>float16</code> Float8 和其他量化使用不同的标志 - 参见 <code>--quantization</code></td></tr><tr><td><strong><code>--tokenizer</code></strong></td><td>指定分词器路径，例如 <code>unsloth/gpt-oss-20b</code> 如果所部署的模型使用不同的分词器时使用。</td></tr><tr><td><strong><code>--hf-token</code></strong></td><td>如需访问受限模型，请添加你的 HuggingFace 令牌</td></tr><tr><td><strong><code>--swap-space</code></strong></td><td>默认是 4GB。用于 CPU 卸载。若有显存可减少，显存较低的 GPU 可增加该值。</td></tr><tr><td><strong><code>--seed</code></strong></td><td>vLLM 的默认值为 0</td></tr><tr><td><strong><code>--disable-log-stats</code></strong></td><td>禁用诸如吞吐量、服务器请求等日志记录。</td></tr><tr><td><strong><code>--enforce-eager</code></strong></td><td>禁用编译。加载更快，但推理更慢。</td></tr><tr><td><strong><code>--disable-cascade-attn</code></strong></td><td>对于 vLLM &#x3C; 0.11.0 的强化学习运行很有用，因为 Cascade Attention 在 A100 GPU 上有些小问题（Unsloth 已修复此问题）</td></tr></tbody></table>

### :tada:Float8 量化

例如，要使用 Float8 KV 缓存和量化托管 Llama 3.3 70B Instruct（支持 128K 上下文长度），可以尝试：

```bash
vllm serve unsloth/Llama-3.3-70B-Instruct \
    --quantization fp8 \
    --kv-cache-dtype fp8
    --gpu-memory-utilization 0.97 \
    --max-model-len 65536
```

### :shaved\_ice:LoRA 热插拔 / 动态 LoRA

要启用最多同时热插拔（更换）4 个 LoRA 的 LoRA 服务，首先设置环境标志以允许热插拔：

参见我们的 [LoRA 热切换指南](/docs/zh/ji-chu/inference-and-deployment/vllm-guide/lora-hot-swapping-guide.md) 以获取更多详情。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://unsloth.ai/docs/zh/ji-chu/inference-and-deployment/vllm-guide/vllm-engine-arguments.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
