> For the complete documentation index, see [llms.txt](https://unsloth.ai/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://unsloth.ai/docs/zh/ji-chu-zhi-shi/inference-and-deployment/vllm-guide/vllm-engine-arguments.md).

# 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 可使用多少 VRAM。若发生内存不足，请降低该值。可尝试设置为 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 的最大秩。可选值有 <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 卸载使用。若你有足够 VRAM 可降低此值，或在低内存 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 Cache 和量化方式托管 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 热插拔指南](/docs/zh/ji-chu-zhi-shi/inference-and-deployment/vllm-guide/lora-hot-swapping-guide.md) 了解更多细节。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
