> 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/jp/ji-ben/nvfp4.md).

# Unsloth Dynamic NVFP4 実行ガイド

Unsloth Dynamic NVFP4 は、NVIDIA Blackwell GPU 上で動作する量子化モデル形式で、より高速かつ高精度な4ビット推論向けに設計されています。NVIDIA ネイティブの NVFP4 精度と [Unsloth Dynamic 2.0](/docs/jp/ji-ben/dynamic-3.0-ggufs.md) 量子化を組み合わせ、VRAM 使用量を減らしつつ速度を向上させます。このガイドでは FP4 量子化を解説し、NVFP4 を他の形式と比較し、次のようなモデルを実行する方法を示します。 [Qwen3.8](/docs/jp/moderu/qwen3.8.md), [Gemma 4](/docs/jp/moderu/gemma-4.md) と [Qwen3.6](/docs/jp/moderu/qwen3.6.md) RTX 5050-5090、B200、RTX PRO 6000 などのGPU上で、vLLM または SGLang を使ってローカルに実行できます。

Dynamic NVFP4 は、すべての層を FP4 に押し込むのではなく、重要な層を FP8 (W8A8) または BF16 のままにし、残りを W4A4 (W4A16 ではない) にすることで動作します。これにより最大で **2.5倍高速な推論** W4A4 が Blackwell GPU の FP4 Tensor Core を活用するためです。すべての量子化版について、FP8 KV キャッシュのキャリブレーションも提供しており、 **コンテキスト長を2倍に延長**.

{% hint style="success" %}
**8月14日：** [**Qwen3.8-27B**](/docs/jp/moderu/qwen3.8.md) **が、私たちの NVFP4 量子化版とともに公開されました。**

**すべて** [**Gemma 4**](#gemma-4) **モデルは現在、Unsloth Dynamic NVFP4 量子化版として利用できます：** E2B、E4B、12B Unified、26B-A4B MoE、31B Dense。

次を確認してください [Unsloth Dynamic NVFP4 コレクション](https://huggingface.co/collections/unsloth/nvfp4) すべてのモデルアップロードを対象に。
{% endhint %}

### Float4 と他の精度

より高速な GPU では、 **行列乗算の数値精度を下げることです**。行列乗算ユニットに必要なトランジスタ数は、 **仮数の二乗**に関係しています。仮数によって、数値にどれだけの「小数」桁を持たせられるかが決まります。つまり、ビット数が多いほど小数をより正確に表現できます。たとえば、仮数ビットが多ければ 0.121332 を表現できますが、仮数ビットが少ないと 0.1 に丸められます。

{% columns %}
{% column width="50%" %}
FP32 には 23 個の仮数ビットがあるため、23^2 + 8 指数ビット = 537 の領域が必要です。Bfloat16 には 7 個の仮数ビットがあるので、7^2 + 8 指数 = 57 の領域です。つまり、bfloat16 は FP32 より約 9 倍少ない領域で済みます。さらに、仮数ビットが 3 個の float8 では 3^2 + 4 指数 = 13 となり、FP32 より 41 倍少ない領域で済みます！

最後に、float4 は仮数ビット 1 個と指数 2 個なので、必要な領域は 3。これは FP32 より驚異の 179 倍少ない領域で済むことを意味し、実質的には **同じ領域で、GPU は FP32 の乗算 FLOPs と比べて約 179 倍多くの FP4 行列乗算を実行できます**!
{% endcolumn %}

{% column width="50%" %}
![](/files/21ae59dd96276bf76dc7cf3fa9caac1e595789ba)
{% endcolumn %}
{% endcolumns %}

### NVFP4 vs MXFP4

<div><figure><img src="/files/68535f1d270fcc0fe59080c7a89437e5b96c840f" alt=""><figcaption></figcaption></figure> <figure><img src="/files/f92e640a8c249ab304fc2ce69dbde52bb49fbf98" alt=""><figcaption></figcaption></figure></div>

MXFP4 と呼ばれる別の FP4 形式があります。NVFP4 より精度が低いのは、次の 2 つの理由によります：

1. NVFP4 はブロックサイズ 16 を使用しますが、MXFP4 は 32 です。これにより外れ値を分離しやすくなり、より小さな重みのサブセットごとにスケーリング係数を与えられるため、精度が向上します
2. 各ブロックで E8M0（2 のべき乗によるスケーリング）ではなく E4M3 (FP8) スケールを使用します。FP8 型のブロックサイズを使う方が、特に LLM ではかなり良さそうです。

### 性能分析

私たちの新しい Dynamic NVFP4 Qwen3.6 量子化版は約**2.5倍高速** 他の NVFP4 量子化版よりも高速で、 **より高い性能** および同等のファイルサイズです。Qwen3.6-27B NVFP4 を実行してください **2.5倍高速** で **24GB VRAM** および Qwen3.6-35B-A3B **1.7倍高速** で **32GB VRAM**。さらに私たちは **FP8 KV キャッシュのキャリブレーション** を追加し、コンテキスト長を2倍に延長できます！NVFP4 には、RTX 50X、DGX Spark（参照 [#dgx-spark-with-nvfp4-quants](#dgx-spark-with-nvfp4-quants "mention")）、B200、B300 GPU が必要です。古い GPU では、私たちの GGUF がよく動作します！

<figure><img src="/files/1e9f182217e232a6973dc71d63984eda9e0961ad" alt="" width="563"><figcaption></figcaption></figure>

すべてのベンチマークは 1x B200、128 同時実行で行っています。より高い同時実行数では 35B が 17,561 tokens/s まで向上します。さらに、私たちは新しい [Qwen3.8](/docs/jp/moderu/qwen3.8.md) NVFP4 量子化版も公開しました：

* [Qwen3.8-27B NVFP4](https://huggingface.co/unsloth/Qwen3.8-27B-NVFP4) (新規)

35B-A3B の NVFP4 版も 2 種類公開します：

* [Qwen3.6-35B-A3B-NVFP4-Fast](https://huggingface.co/unsloth/Qwen3.6-35B-A3B-NVFP4-Fast) これは完全な W4A4 量子化版で、1.79倍高速です
* [Qwen3.6-35B-A3B-NVFP4](https://huggingface.co/unsloth/Qwen3.6-35B-A3B-NVFP4) こちらは少し大きいですが、より高精度で 1.56倍高速です

精度ベンチマークでは、FP8、BF16、NVIDIA の NVFP4、そして私たちの NVFP4 に対して MMLU-Pro、AIME 2025、GPQA を実施しました。より高速な量子化版もすべてで同様の結果を示しています：

<figure><img src="/files/b19c4e11d384d29146fddfe25b759e18a4ba80c3" alt=""><figcaption></figcaption></figure>

| Qwen3.8-27B (新規)                                                           |
| -------------------------------------------------------------------------- |
| [Qwen3.8-27B NVFP4](https://huggingface.co/unsloth/Qwen3.8-27B-NVFP4) (新規) |

<table><thead><tr><th width="372.5999755859375">Qwen3.6-35B-A3B</th><th>Qwen3.6-27B</th></tr></thead><tbody><tr><td><a href="https://huggingface.co/unsloth/Qwen3.6-35B-A3B-NVFP4">Qwen3.6-35B-A3B-NVFP4</a> (1.56倍高速)</td><td><a href="https://huggingface.co/unsloth/Qwen3.6-27B-NVFP4">Qwen3.6-27B-NVFP4</a> (2.5倍高速)</td></tr><tr><td><a href="https://huggingface.co/unsloth/Qwen3.6-35B-A3B-NVFP4-Fast">Qwen3.6-35B-A3B-NVFP4-Fast</a> (1.79倍高速)</td><td></td></tr></tbody></table>

**追加の高速化のため、MTP テンソルも量子化版に直接組み込まれています。** 精度向上は、Qwen3.6 のチャットテンプレートとデータセットキャリブレーションの改善によるものです。以前のチャットテンプレート更新を活用し、コード生成やツール呼び出しの一貫性を高めつつ、ループやその他報告されている問題を減らしています。キャリブレーションでは、UltraChat に加えて、コード生成、ツール呼び出し、チャット向けに最適化した私たちのデータセットを組み合わせています。

デコード速度（tokens per person）では、私たちのものは 27B で 1.03倍高速、35B で 1.17倍および 1.22倍高速です。

<figure><img src="/files/8d4c0dbc8c8d4748567e9f3b37040f0e218100aa" alt="" width="563"><figcaption></figcaption></figure>

### 概要

以下は、Gemma 4 や Qwen3.6 を含む、使用可能なモデルのハードウェア要件です。あわせて、得られる全体的な速度向上もご覧ください：

#### Gemma 4：

| Gemma 4 のバリアント                                                     | 必要な VRAM | BF16 より高速 |
| ------------------------------------------------------------------ | -------: | --------: |
| [E2B](https://huggingface.co/unsloth/gemma-4-E2B-it-NVFP4)         |     7 GB |   1.12倍高速 |
| [E4B](https://huggingface.co/unsloth/gemma-4-E4B-it-NVFP4)         |     9 GB |   1.22倍高速 |
| [12B Unified](https://huggingface.co/unsloth/gemma-4-12b-it-NVFP4) |    11 GB |   1.26倍高速 |
| [26B A4B](https://huggingface.co/unsloth/gemma-4-26B-A4B-it-NVFP4) |    26 GB |   1.41倍高速 |
| [31B](https://huggingface.co/unsloth/gemma-4-31B-it-NVFP4)         |    32 GB |   1.45倍高速 |

<figure><img src="/files/4be465fbffe804dae8002ce19bdbfa30382add76" alt="" width="563"><figcaption></figcaption></figure>

#### Qwen3.6：

| Qwen3.6 のバリアント                                                            | 必要な VRAM | 他の NVFP4 量子化版より高速 |
| ------------------------------------------------------------------------- | -------: | ----------------: |
| [27B](https://huggingface.co/unsloth/Qwen3.6-27B-NVFP4)                   |    24 GB |            2.5倍高速 |
| [35B A3B](https://huggingface.co/unsloth/Qwen3.6-35B-A3B-NVFP4)           |    32 GB |           1.56倍高速 |
| [35B A3B Fast](https://huggingface.co/unsloth/Qwen3.6-35B-A3B-NVFP4-Fast) |    32 GB |           1.79倍高速 |

### NVFP4 ベンチマーク

NVFP4 は Blackwell Tensor Core 上で 4 ビット重みと行列乗算を直接実行します。私たちの Qwen3.6 NVFP4 量子化版は W4A4 を使うため、実際に FP4 Tensor Core を利用し、W4A16 を使う NVIDIA のものよりデコードが高速です。精度を維持するために層を動的に量子化しており、FP8 と BF16 との比較を含め、すべての量子化版について MMLU-Pro、AIME 2025、GPQA を実施しました。

**Qwen3.6-27B NVFP4 精度ベンチマーク**

| 提供元     | MMLU-Pro |  GPQA | AIME 2025 |
| ------- | -------: | ----: | --------: |
| Unsloth |    86.25 | 86.34 |     93.12 |
| NVIDIA  |    85.96 | 86.87 |     93.12 |
| FP8     |    86.11 | 86.87 |     93.75 |
| BF16    |    85.96 | 88.13 |     93.33 |

**Qwen3.6-35B-A3B NVFP4 精度ベンチマーク**

| 提供元              | MMLU-Pro |  GPQA | AIME 2025 |
| ---------------- | -------: | ----: | --------: |
| Unsloth          |    85.85 | 86.74 |     92.29 |
| **Unsloth Fast** |    85.58 | 87.75 |     91.67 |
| NVIDIA           |    85.60 | 87.12 |     91.88 |
| FP8              |    85.75 | 86.74 |     93.12 |
| BF16             |    85.75 | 86.36 |     92.50 |

すべてのベンチマークの出力長も確認しましたが、同等だったため、新しい NVFP4 量子化版が長く考え込むことはなく、量子化の目的を損ないません！（つまり、2倍高速でも 2倍多く考えるなら無意味です）

<figure><img src="/files/34080d2a8c3d4e4c6edcbaca990a86fb2b7270dc" alt=""><figcaption></figcaption></figure>

## **NVFP4 チュートリアルを実行**

NVFP4 量子化版を実行するには、以下の Qwen3.6-27B を実行するコマンドを参照してください [vLLM](/docs/jp/ji-ben/inference-and-deployment/vllm-guide.md) と [SGLang](/docs/jp/ji-ben/inference-and-deployment/sglang-guide.md) （モデル名は `Qwen3.6-35-A3B-NVFP4`).&#x20;

### **vLLM チュートリアル**

すべての NVFP4 モデルを [vLLM](https://github.com/vllm-project/vllm)で実行できます。MoE バックエンドは選択しないでください。vLLM に選ばせてください。たとえば Marlin は 2.5倍遅いです！参照 [#marlin-vs-flashinfer-vs-cutlass-vs-cute-dsl](#marlin-vs-flashinfer-vs-cutlass-vs-cute-dsl "mention")DGX Spark をお持ちの場合は、参照 [#dgx-spark-serving](#dgx-spark-serving "mention") 次を使用する必要があります `--moe-backend flashinfer_b12x` さもないと、推論がかなり遅くなります。

別の venv に vLLM をインストールするには：

{% code overflow="wrap" expandable="true" %}

```bash
uv venv unsloth-nvfp4-env --python 3.13
source unsloth-nvfp4-env/bin/activate
uv pip install "vllm>=0.25.0" "flashinfer-python>=0.6.13" "nvidia-cutlass-dsl>=4.5.2" \\
    --torch-backend=auto
```

{% endcode %}

次に、35B Fast バリアントをサーブするには：

```shell
vllm serve unsloth/Qwen3.6-35B-A3B-NVFP4-Fast
```

変更 `unsloth/Qwen3.6-35B-A3B-NVFP4-Fast` を NVFP4 量子化版の名前に！

MTP / speculative decoding（デコードは高速ですが、スループットはやや低下）を有効にするには、次を使用します：

```bash
vllm serve unsloth/Qwen3.6-35B-A3B-NVFP4-Fast
    --speculative-config '{"method": "mtp", "num_speculative_tokens": 2}'
```

Torchcodec に関する問題が発生した場合は、以下を実行してから vllm を再起動してください。

{% code overflow="wrap" expandable="true" %}

```bash
sudo apt-get update
sudo apt-get install -y ffmpeg
```

{% endcode %}

### **DGX Spark チュートリアル**

DGX Spark に正しいカーネルが入っていることを確認するには（さもないと **推論が2倍遅くなります**）、まず次を確認します：

{% code overflow="wrap" expandable="true" %}

```bash
python -c "
import torch; from vllm.utils.flashinfer import has_flashinfer_b12x_gemm as g, has_flashinfer_b12x_moe as m
cap = torch.cuda.get_device_capability(); print('cap', cap, '| b12x gemm', g(), '| b12x moe', m()); assert cap[0] == 12 and g() and m(), 'b12x unavailable: serving would degrade to marlin W4A16'"
```

{% endcode %}

エラーにならないはずです。もしエラーになる場合は、vllm を更新するか、次で再インストールしてください：

{% code overflow="wrap" expandable="true" %}

```bash
uv venv unsloth-nvfp4-env --python 3.13
source unsloth-nvfp4-env/bin/activate
uv pip install "vllm>=0.25.0" "flashinfer-python>=0.6.13" "nvidia-cutlass-dsl>=4.5.2" \\
    --torch-backend=auto
```

{% endcode %}

DGX Spark で vLLM を使ってサーブするには：

{% code overflow="wrap" expandable="true" %}

```shellscript
export CUTE_DSL_ARCH=sm_121a
vllm serve unsloth/Qwen3.6-35B-A3B-NVFP4-Fast --moe-backend flashinfer_b12x
```

{% endcode %}

Torchcodec に関する問題が発生した場合は、以下を実行してから vllm を再起動してください。

{% code overflow="wrap" expandable="true" %}

```bash
sudo apt-get update
sudo apt-get install -y ffmpeg
```

{% endcode %}

### **SGLang チュートリアル：**

すべての NVFP4 モデルを [SGLang](https://github.com/sgl-project/sglang)。モデル名は目的のものに置き換えるのを忘れないでください。

**Qwen3.6：**

```bash
python -m sglang.launch_server --model-path unsloth/Qwen3.6-27B-NVFP4 --speculative-algorithm NEXTN \\
     --speculative-num-steps 3 --speculative-eagle-topk 1 --speculative-num-draft-tokens 4
```

**Gemma 4：**

```bash
python -m sglang.launch_server --model-path unsloth/Gemma-4-31B-NVFP4 --speculative-algorithm NEXTN \\
     --speculative-num-steps 3 --speculative-eagle-topk 1 --speculative-num-draft-tokens 4
```

### Gemma 4 およびその他

Gemma 4 の各バリアントには、現在 Unsloth Dynamic NVFP4 チェックポイントがあります。

Gemma-4 は、1x B200 で 128 同時実行時、BF16 と比べてスループットが最大 1.44倍向上すると示しています。Qwen3.5-122B-A10B は 1.38倍高速で、GLM-4.7-Flash は 1.27倍高速です。

<figure><img src="/files/e40a35df412c1d4a806a0e594f1e2268ba4204cf" alt=""><figcaption></figcaption></figure>

### Marlin vs Flashinfer vs cutlass vs cute-DSL

Marlin カーネルは W4A4 をうまくサポートしていないことも確認しました。これを有効にすると性能が 2.5倍低下します。したがって、CUTLASS、Flashinfer-TRTLLM、または Cute-DSL（vLLM で自動有効化）を使用してください！また、DGX Spark をお持ちの場合は、参照 [#dgx-spark-serving](#dgx-spark-serving "mention") 次を使用する必要があります `--moe-backend flashinfer_b12x` さもないと、推論が 2.5倍遅くなります。

**したがって、バックエンドは設定しないでください。vLLM が最適なものを自動選択します。**

| モデル             | 方式    | バックエンド             | デコード tok/s | スループット tok/s |
| --------------- | ----- | ------------------ | ---------- | ------------ |
| NVIDIA 27B      | W4A16 | marlin（自動）         | 115.6      | 2,403        |
| unsloth 27B     | W4A4  | marlin             | 105.6      | 2,127        |
| unsloth 27B     | W4A4  | cutlass            | 113.5      | 6,681        |
| unsloth 27B     | W4A4  | flashinfer\_trtllm | 112.6      | 6,158        |
| unsloth 27B     | W4A4  | **cute-DSL（自動）**   | 125.9      | **6,863**    |
| NVIDIA 35B-A3B  | W4A4  | marlin（自動）         | 240.8      | 8,721        |
| unsloth 35B-A3B | W4A4  | marlin             | 215.8      | 8,619        |
| unsloth 35B-A3B | W4A4  | cutlass            | 158.3      | 11,017       |
| unsloth 35B-A3B | W4A4  | **cute-DSL（自動）**   | 295.2      | **15,636**   |


---

# 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 dynamically by asking a question.

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

```
GET https://unsloth.ai/docs/jp/ji-ben/nvfp4.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
