> 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 で動作する量子化モデル形式で、より高速で高精度な 4bit 推論向けに設計されています。NVIDIA のネイティブな NVFP4 精度と [Unsloth Dynamic 2.0](/docs/jp/ji-ben/unsloth-dynamic-2.0-ggufs.md) の量子化を組み合わせて、VRAM 使用量を削減しつつ速度を向上させながらモデル精度を維持します。このガイドでは FP4 量子化を解説し、NVFP4 を他の形式と比較し、さらに [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" %}
**すべての** [**Gemma 4**](#gemma-4) **モデルは現在、Unsloth Dynamic NVFP4 量子化として利用できます:** E2B、E4B、12B Unified、26B-A4B MoE、31B Dense。

ぜひ [Unsloth Dynamic NVFP4 Collection](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 と MXFP4

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

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

1. NVFP4 は MXFP4 の 32 に対してブロックサイズ 16 を使用します。これにより外れ値をより簡単に分離でき、重みのより小さなサブセットごとにスケーリング係数を与えられるため、精度が向上します
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 のような NVIDIA Blackwell GPU が必要です。旧世代 GPU では、私たちの GGUF がよく動作します！

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

すべてのベンチマークは 1x B200 で同時実行数 128 を使用しています。同時実行数を増やすと 35B は 17,561 トークン/秒まで向上する可能性があります。さらに、2 つの 35B-A3B NVFP4 版もリリースします:

* [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>

<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 と並べて、コーディング、ツール呼び出し、チャット向けに最適化したデータセットを組み合わせています。

Decode 速度（1人あたりのトークン数）では、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 は 4bit 重みと行列積を Blackwell Tensor Core 上で直接実行します。私たちの 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 が自動で最適なものを選びます。**

| モデル             | 方式    | バックエンド             | decode tok/s | thr out 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.
