> 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-chu/nvfp4.md).

# Unsloth Dynamic NVFP4 実行ガイド

Unsloth Dynamic NVFP4 により、NVIDIA Blackwell GPU 上で高速かつ高精度な 4 ビット推論がどのように実現されるかを学びます。

Unsloth Dynamic NVFP4は、NVIDIA Blackwell GPU上で動作し、より高速で高精度な4ビット推論向けに設計された量子化モデル形式です。NVIDIAのネイティブなNVFP4精度と [Unsloth Dynamic 2.0](/docs/jp/ji-chu/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倍少ない空間で済みます！ そしてfloat8では仮数ビットが3なので、3^2 + 指数4 = 13で、これはFP32より41倍少ない空間です！

最後にfloat4は仮数ビット1つと指数2つで、必要空間は3です。これはFP32よりなんと179倍も少ない空間で、要するに **同じ空間で、GPUはFP32の乗算FLOPsに対して約179倍多くのFP4行列乗算を実行できます**!
{% endcolumn %}

{% column width="50%" %}
![](https://735611837-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FJQlcQbDGgw5qbkltc7jr%2Funknown.png?alt=media\&token=75d1ec98-3fa5-4b5a-b51a-5577ac5a96ca)
{% endcolumn %}
{% endcolumns %}

### NVFP4とMXFP4

<div><figure><img src="https://735611837-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FRDyKe2OmFRK0tDbrrnMb%2Fimage.png?alt=media&amp;token=affd39c0-11e9-458f-982f-181ebc327b82" alt=""><figcaption></figcaption></figure> <figure><img src="https://735611837-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2Fj2COTZX8rNX5un1JeaNU%2Fimage.png?alt=media&amp;token=9b5749d8-9e0e-4f04-8022-90379e9d544c" alt=""><figcaption></figcaption></figure></div>

MXFP4と呼ばれる別のFP4形式がありますが、次の2点によりNVFP4より精度が低くなります：

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

### 性能分析

新しい 動的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="https://735611837-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2F8zM7cg0Xgo2pAlop1iPW%2F01_qwen36_combined_throughput.png?alt=media&amp;token=23131a96-4c41-42d7-aa16-5bfb21bb44a3" alt="" width="563"><figcaption></figcaption></figure>

すべてのベンチマークは1x B200、128同時実行で測定しています。同時実行数を増やすと35Bは17,561トークン/秒まで向上します。また、ちょうど新しい [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="https://735611837-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FFhOUUUlRBj3dafGnmvhK%2F03_qwen36_combined_accuracy(7).png?alt=media&amp;token=9178447f-d5ae-4489-9bdc-73b2b7b1631b" 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に加えて、コーディング、ツール呼び出し、チャット向けに最適化した当社データセットを組み合わせて使用しています。

デコード速度（トークン/秒）では、当社版は27Bで1.03倍高速、35Bで1.17倍および1.22倍高速です。

<figure><img src="https://735611837-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FR3X2O3iOBhjMS1ekX7zO%2F03_qwen36_combined_decode.png?alt=media&amp;token=a8b34056-7178-4e0d-851b-9467fa0ba2f6" 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="https://735611837-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FZw91MhTauyOZGP5HT7bl%2Fimage.png?alt=media&amp;token=ae0051a9-af39-4ef7-8ed2-9f8c1fff33fc" 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は4ビットの重みと行列乗算を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="https://735611837-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FjG1C3y6GVWvnorRfmnIF%2Fqwen36_combined_output_length_reordered_estimated_no_footnote.png?alt=media&amp;token=2aa2d784-c082-476e-895a-4bea77385956" alt=""><figcaption></figcaption></figure>

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

NVFP4量子化版を実行するには、以下のQwen3.6-27Bを実行するコマンドを参照してください [vLLM](/docs/jp/ji-chu/inference-and-deployment/vllm-guide.md) そして [SGLang](/docs/jp/ji-chu/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="https://735611837-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2F40mWjyryioZIww8kxH61%2F02_throughput_nvfp4_vs_bf16.png?alt=media&amp;token=330f88e8-00d4-4573-8f79-24bd9886f2f9" 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 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/jp/ji-chu/nvfp4.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.
