# 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 块，就设为 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 个 LoRA，就设为 1；或者比如设为 16。这是一个队列，因此 LoRA 可以热切换。</td></tr><tr><td><strong><code>--max-lora-rank</code></strong></td><td>所有 LoRA 的最大 rank。可选值为 <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>指定 tokenizer 路径，例如 <code>unsloth/gpt-oss-20b</code> 如果部署的模型使用了不同的 tokenizer。</td></tr><tr><td><strong><code>--hf-token</code></strong></td><td>如果是受限模型，按需添加你的 HuggingFace token</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.
