# Unsloth 基准测试

* 有关更详细的基准测试，请阅读我们的 [Llama 3.3 博客](https://unsloth.ai/blog/llama3-3).
* Unsloth 的基准测试也由以下机构进行 [🤗Hugging Face](https://huggingface.co/blog/unsloth-trl).

{% hint style="warning" %}
如果你的速度一开始看起来较慢，很可能是因为 `torch.compile` 通常需要大约 5 分钟（或更长时间）来预热并完成编译。请确保在测量吞吐量时 **在** 它完全加载之后进行，因为在更长的运行中，Unsloth 应该会快得多。
{% endhint %}

在 H100 和 [Blackwell](https://unsloth.ai/docs/zh/bo-ke/fine-tuning-llms-with-blackwell-rtx-50-series-and-unsloth) GPU 上测试。我们使用 Alpaca 数据集进行测试，批量大小为 2，梯度累积步数为 4，秩 = 32，并对所有线性层（q、k、v、o、gate、up、down）应用了 QLoRA：

<table data-full-width="false"><thead><tr><th>模型</th><th>显存</th><th>🦥Unsloth 速度</th><th>🦥显存减少</th><th>🦥更长的上下文</th><th>😊Hugging Face + FA2</th></tr></thead><tbody><tr><td>Llama 3.3（70B）</td><td>80GB</td><td>2x</td><td>>75%</td><td>13 倍更长</td><td>1x</td></tr><tr><td>Llama 3.1（8B）</td><td>80GB</td><td>2x</td><td>>70%</td><td>12 倍更长</td><td>1x</td></tr></tbody></table>

## 上下文长度基准

{% hint style="info" %}
由于我们的更多数据会使 Unsloth 使用更少的显存，原因在于我们的 [梯度检查点](https://unsloth.ai/blog/long-context) 算法 + 苹果的 CCE 算法！
{% endhint %}

### **Llama 3.1（8B）最大上下文长度**

我们测试了 Llama 3.1（8B）Instruct，并对所有线性层（Q、K、V、O、gate、up 和 down）进行了 4bit QLoRA，秩 = 32，批量大小为 1。我们将所有序列填充到某个最大序列长度，以模拟长上下文微调的工作负载。

| GPU 显存 | 🦥Unsloth 上下文长度 | Hugging Face + FA2 |
| ------ | --------------- | ------------------ |
| 8 GB   | 2,972           | 内存溢出（OOM）          |
| 12 GB  | 21,848          | 932                |
| 16 GB  | 40,724          | 2,551              |
| 24 GB  | 78,475          | 5,789              |
| 40 GB  | 153,977         | 12,264             |
| 48 GB  | 191,728         | 15,502             |
| 80 GB  | 342,733         | 28,454             |

### **Llama 3.3（70B）最大上下文长度**

我们在 80GB 的 A100 上测试了 Llama 3.3（70B）Instruct，并对所有线性层（Q、K、V、O、gate、up 和 down）进行了 4bit QLoRA，秩 = 32，批量大小为 1。我们将所有序列填充到某个最大序列长度，以模拟长上下文微调的工作负载。

| GPU 显存 | 🦥Unsloth 上下文长度 | Hugging Face + FA2 |
| ------ | --------------- | ------------------ |
| 48 GB  | 12,106          | 内存溢出（OOM）          |
| 80 GB  | 89,389          | 6,916              |


---

# 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/unsloth-benchmarks.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.
