> 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/moderu/tutorials/qwen3-how-to-run-and-fine-tune/qwen3-2507.md).

# Qwen3-2507: ローカル実行ガイド

Qwenは自社の [Qwen3](/docs/jp/moderu/tutorials/qwen3-how-to-run-and-fine-tune.md) 4B、30B、235Bモデル向けに2507（2025年7月）アップデートを公開し、「思考あり」と「思考なし」の両方のバリアントを導入しました。思考なしの「**Qwen3-30B-A3B-Instruct-2507**' と '**Qwen3-235B-A22B-Instruct-2507'** は256Kのコンテキストウィンドウ、指示追従の改善、多言語対応、アラインメントを備えています。

思考モデルの「**Qwen3-30B-A3B-Thinking-2507**' と '**Qwen3-235B-A22B-Thinking-2507**」は推論に優れており、235Bは論理、数学、科学、コーディング、高度な学術タスクでSOTA結果を達成しています。

[Unsloth](https://github.com/unslothai/unsloth) また、ファインチューニングと [強化学習（RL）](/docs/jp/meru/reinforcement-learning-rl-guide.md) Qwen3-2507モデルの — 2倍高速化、VRAM 70%削減、コンテキスト長8倍延長

<a href="#run-qwen3-30b-a3b-2507-tutorials" class="button secondary">30B-A3Bを実行</a><a href="/pages/fa5bc8c4a776b4aa07f35a8be3714e534db69c0d#run-qwen3-235b-a22b-2507-tutorials" class="button secondary">235B-A22Bを実行</a><a href="#fine-tuning-qwen3-2507-with-unsloth" class="button secondary">Qwen3-2507をファインチューニング</a>

**Unsloth** [**Dynamic 2.0**](/docs/jp/ji-ben/unsloth-dynamic-2.0-ggufs.md) **GGUF:**

| モデル                      | 実行用GGUF:                                                                                                                                                      |
| ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Qwen3-**4B-2507**        | [Instruct](https://huggingface.co/unsloth/Qwen3-4B-Instruct-2507-GGUF) • [Thinking](https://huggingface.co/unsloth/Qwen3-4B-Thinking-2507-GGUF)               |
| Qwen3-**30B-A3B**-2507   | [Instruct](#llama.cpp-run-qwen3-30b-a3b-instruct-2507-tutorial) • [Thinking](https://huggingface.co/unsloth/Qwen3-30B-A3B-Thinking-2507-GGUF)                 |
| Qwen3-**235B-A22B**-2507 | [Instruct](https://huggingface.co/unsloth/Qwen3-235B-A22B-Instruct-2507-GGUF) • [Thinking](https://huggingface.co/unsloth/Qwen3-235B-A22B-Thinking-2507-GGUF) |

## ⚙️ベストプラクティス

{% hint style="success" %}
ThinkingモデルとInstructモデルでは設定が異なります。\
Thinkingモデルではtemperature = 0.6ですが、Instructモデルではtemperature = 0.7です\
Thinkingモデルではtop\_p = 0.95ですが、Instructモデルではtop\_p = 0.8です
{% endhint %}

最適な性能を得るために、Qwenは以下の設定を推奨します:

| Instructモデル設定:                                                             | Thinkingモデル設定:                                                             |
| -------------------------------------------------------------------------- | -------------------------------------------------------------------------- |
| <mark style="background-color:blue;">`Temperature = 0.7`</mark>            | <mark style="background-color:blue;">`Temperature = 0.6`</mark>            |
| `Min_P = 0.00` （llama.cppのデフォルトは0.1です）                                     | `Min_P = 0.00` （llama.cppのデフォルトは0.1です）                                     |
| `Top_P = 0.80`                                                             | `Top_P = 0.95`                                                             |
| `TopK = 20`                                                                | `TopK = 20`                                                                |
| `presence_penalty = 0.0 ～ 2.0` （llama.cppのデフォルトでは無効ですが、繰り返しを減らすためにこれを使えます） | `presence_penalty = 0.0 ～ 2.0` （llama.cppのデフォルトでは無効ですが、繰り返しを減らすためにこれを使えます） |

**十分な出力長**: ほとんどのクエリでは、出力長を `32,768` トークンにするとよく、ほとんどのクエリには十分です。

両方のThinking向けのチャットテンプレート（thinkingには `<think></think>`）とInstructは以下のとおりです:

```
<|im_start|>user
やあ！<|im_end|>
<|im_start|>assistant
1+1はいくつ？<|im_end|>
<|im_start|>user
2<|im_end|>
<|im_start|>assistant
```

## 📖 Qwen3-30B-A3B-2507 チュートリアルを実行

以下は [Thinking](#thinking-qwen3-30b-a3b-thinking-2507) および [Instruct](#instruct-qwen3-30b-a3b-instruct-2507) モデルの各バージョン向けガイドです。

### Instruct: Qwen3-30B-A3B-Instruct-2507

これは思考しないモデルなので、 `thinking=False` を設定する必要はなく、モデルは `<think> </think>` ブロックを生成しません。

#### ⚙️ベストプラクティス

最適な性能を得るために、Qwenは次の設定を推奨します:

* 次を使うことを推奨します `temperature=0.7, top_p=0.8, top_k=20, min_p=0.0` `presence_penalty` を0〜2の間で、フレームワークが対応しているなら、際限のない繰り返しを減らすために設定します。
* **`temperature = 0.7`**
* `top_k = 20`
* `min_p = 0.00` （llama.cppのデフォルトは0.1です）
* **`top_p = 0.80`**
* `presence_penalty = 0.0 ～ 2.0` （llama.cppのデフォルトでは無効ですが、繰り返しを減らすためにこれを使えます） たとえば1.0を試してください。
* 最大で `262,144` コンテキストまでネイティブに対応していますが、 `32,768` トークンに設定するとRAM使用量を抑えられます

#### 🦙 Ollama: Qwen3-30B-A3B-Instruct-2507 チュートリアルを実行

1. インストール `ollama` まだなら！実行できるのは32Bまでのモデルのみです。

```bash
apt-get update
apt-get install pciutils -y
curl -fsSL https://ollama.com/install.sh | sh
```

2. モデルを実行しましょう！失敗した場合は別の端末で `ollama serve`を呼び出せます！私たちの修正と推奨パラメータ（temperatureなど）はすべて `params` に含めて Hugging Face にアップロードしています！

```bash
ollama run hf.co/unsloth/Qwen3-30B-A3B-Instruct-2507-GGUF:UD-Q4_K_XL
```

#### :sparkles: Llama.cpp: Qwen3-30B-A3B-Instruct-2507 チュートリアルを実行

1. 最新の `llama.cpp` オン [GitHub はこちら](https://github.com/ggml-org/llama.cpp)で入手してください。以下のビルド手順に従っても構いません。変更してください `-DGGML_CUDA=ON` を `-DGGML_CUDA=OFF` GPU がない場合、または CPU 推論だけを使いたい場合。 **Apple Mac / Metal デバイスの場合**、次のように設定し `-DGGML_CUDA=OFF` その後は通常どおり続けてください。Metal サポートはデフォルトで有効です。

```bash
apt-get update
apt-get install pciutils build-essential cmake curl libcurl4-openssl-dev -y
git clone https://github.com/ggml-org/llama.cpp
cmake llama.cpp -B llama.cpp/build \
    -DBUILD_SHARED_LIBS=OFF -DGGML_CUDA=ON -DLLAMA_CURL=ON
cmake --build llama.cpp/build --config Release -j --clean-first --target llama-cli llama-gguf-split
cp llama.cpp/build/bin/llama-* llama.cpp
```

2. HuggingFaceから直接取得できます:

   ```bash
   ./llama.cpp/llama-cli \
       -hf unsloth/Qwen3-30B-A3B-Instruct-2507-GGUF:Q4_K_XL \
       --jinja -ngl 99 --ctx-size 32768 \
       --temp 0.7 --min-p 0.0 --top-p 0.80 --top-k 20 --presence-penalty 1.0
   ```
3. 以下をインストールした後、経由でモデルをダウンロード: `pip install huggingface_hub hf_transfer` ）。UD\_Q4\_K\_XLまたは他の量子化版を選べます。

```python
# !pip install huggingface_hub hf_transfer
import os
os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "1"
from huggingface_hub import snapshot_download
snapshot_download(
    repo_id = "unsloth/Qwen3-30B-A3B-Instruct-2507-GGUF",
    local_dir = "unsloth/Qwen3-30B-A3B-Instruct-2507-GGUF",
    allow_patterns = ["*UD-Q4_K_XL*"],
)
```

### Thinking: Qwen3-30B-A3B-Thinking-2507

このモデルは思考モードと256Kコンテキストウィンドウのみにネイティブ対応しています。デフォルトのチャットテンプレートは `<think>` を自動的に追加するため、出力には閉じタグの `</think>` のみが見えることがあります。

#### ⚙️ベストプラクティス

最適な性能を得るために、Qwenは次の設定を推奨します:

* 次を使うことを推奨します `temperature=0.6, top_p=0.95, top_k=20, min_p=0.0` `presence_penalty` を0〜2の間で、フレームワークが対応しているなら、際限のない繰り返しを減らすために設定します。
* **`temperature = 0.6`**
* `top_k = 20`
* `min_p = 0.00` （llama.cppのデフォルトは0.1です）
* **`top_p = 0.95`**
* `presence_penalty = 0.0 ～ 2.0` （llama.cppのデフォルトでは無効ですが、繰り返しを減らすためにこれを使えます） たとえば1.0を試してください。
* 最大で `262,144` コンテキストまでネイティブに対応していますが、 `32,768` トークンに設定するとRAM使用量を抑えられます

#### 🦙 Ollama: Qwen3-30B-A3B-Instruct-2507 チュートリアルを実行

1. インストール `ollama` まだなら！実行できるのは32Bまでのモデルのみです。235B-A22Bのフルモデルを実行するには、 [こちらを参照](#run-qwen3-235b-a22b-instruct-2507).

```bash
apt-get update
apt-get install pciutils -y
curl -fsSL https://ollama.com/install.sh | sh
```

2. モデルを実行しましょう！失敗した場合は別の端末で `ollama serve`を呼び出せます！私たちの修正と推奨パラメータ（temperatureなど）はすべて `params` に含めて Hugging Face にアップロードしています！

```bash
ollama run hf.co/unsloth/Qwen3-30B-A3B-Thinking-2507-GGUF:UD-Q4_K_XL
```

#### :sparkles: Llama.cpp: Qwen3-30B-A3B-Instruct-2507 チュートリアルを実行

1. 最新の `llama.cpp` オン [GitHub はこちら](https://github.com/ggml-org/llama.cpp)で入手してください。以下のビルド手順に従っても構いません。変更してください `-DGGML_CUDA=ON` を `-DGGML_CUDA=OFF` GPU がない場合、または CPU 推論だけを使いたい場合。 **Apple Mac / Metal デバイスの場合**、次のように設定し `-DGGML_CUDA=OFF` その後は通常どおり続けてください。Metal サポートはデフォルトで有効です。

```bash
apt-get update
apt-get install pciutils build-essential cmake curl libcurl4-openssl-dev -y
git clone https://github.com/ggml-org/llama.cpp
cmake llama.cpp -B llama.cpp/build \
    -DBUILD_SHARED_LIBS=OFF -DGGML_CUDA=ON -DLLAMA_CURL=ON
cmake --build llama.cpp/build --config Release -j --clean-first --target llama-cli llama-gguf-split
cp llama.cpp/build/bin/llama-* llama.cpp
```

2. Hugging Faceから直接取得できます:

   ```bash
   ./llama.cpp/llama-cli \
       -hf unsloth/Qwen3-30B-A3B-Thinking-2507-GGUF:Q4_K_XL \
       --jinja -ngl 99 --ctx-size 32768 \
       --temp 0.6 --min-p 0.0 --top-p 0.95 --top-k 20 --presence-penalty 1.0
   ```
3. 以下をインストールした後、経由でモデルをダウンロード: `pip install huggingface_hub hf_transfer` ）。UD\_Q4\_K\_XLまたは他の量子化版を選べます。

```python
# !pip install huggingface_hub hf_transfer
import os
os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "1"
from huggingface_hub import snapshot_download
snapshot_download(
    repo_id = "unsloth/Qwen3-30B-A3B-Thinking-2507-GGUF",
    local_dir = "unsloth/Qwen3-30B-A3B-Thinking-2507-GGUF",
    allow_patterns = ["*UD-Q4_K_XL*"],
)
```

## 📖 実行 **Qwen3-235B-A22B-2507** チュートリアル

以下は [Thinking](#run-qwen3-235b-a22b-thinking-via-llama.cpp) および [Instruct](#run-qwen3-235b-a22b-instruct-via-llama.cpp) モデルの各バージョン向けガイドです。

### Thinking: Qwen3-**235B-A22B**-Thinking-2507

このモデルは思考モードと256Kコンテキストウィンドウのみにネイティブ対応しています。デフォルトのチャットテンプレートは `<think>` を自動的に追加するため、出力には閉じタグの `</think>` のみが見えることがあります。

#### :gear: ベストプラクティス

最適な性能を得るために、QwenはThinkingモデル向けに次の設定を推奨します:

* **`temperature = 0.6`**
* `top_k = 20`
* `min_p = 0.00` （llama.cppのデフォルトは0.1です）
* `top_p = 0.95`
* `presence_penalty = 0.0 ～ 2.0` （llama.cppのデフォルトでは無効ですが、繰り返しを減らすためにこれを使えます） たとえば1.0を試してください。
* **十分な出力長**: ほとんどのクエリでは、出力長を `32,768` トークンにするとよく、ほとんどのクエリには十分です。

#### :sparkles:llama.cppでQwen3-235B-A22B-Thinkingを実行:

Qwen3-235B-A22Bでは、最適化された推論と豊富なオプションのために、特にLlama.cppを使用します。

{% hint style="success" %}
もし **完全精度の未量子化版**が欲しいなら、私たちの `Q8_K_XL、Q8_0` または `BF16` 版を使ってください！
{% endhint %}

1. 最新の `llama.cpp` オン [GitHub はこちら](https://github.com/ggml-org/llama.cpp)で入手してください。以下のビルド手順に従っても構いません。変更してください `-DGGML_CUDA=ON` を `-DGGML_CUDA=OFF` GPU がない場合、または CPU 推論だけを使いたい場合。 **Apple Mac / Metal デバイスの場合**、次のように設定し `-DGGML_CUDA=OFF` その後は通常どおり続けてください。Metal サポートはデフォルトで有効です。

   ```bash
   apt-get update
   apt-get install pciutils build-essential cmake curl libcurl4-openssl-dev -y
   git clone https://github.com/ggml-org/llama.cpp
   cmake llama.cpp -B llama.cpp/build \
       -DBUILD_SHARED_LIBS=OFF -DGGML_CUDA=ON -DLLAMA_CURL=ON
   cmake --build llama.cpp/build --config Release -j --clean-first --target llama-cli llama-gguf-split
   cp llama.cpp/build/bin/llama-* llama.cpp
   ```
2. llama.cppを直接使ってモデルをダウンロードすることもできますが、通常は `huggingface_hub` を使うことを推奨します。

   ```bash
   ./llama.cpp/llama-cli \
       llama.cppを直接使うには、次を実行してください:
       --ctx-size 16384 \\
       --n-gpu-layers 99 \
       -hf unsloth/Qwen3-235B-A22B-Thinking-2507-GGUF:Q2_K_XL \
       --temp 0.6 \\
       -ot ".ffn_.*_exps.=CPU" \
       --top-p 0.95 \
       --top-k 20 \\
       --min-p 0.0 \
   ```
3. 以下をインストールした後、経由でモデルをダウンロード: `pip install huggingface_hub hf_transfer` --presence-penalty 1.0

   ```python
   # !pip install huggingface_hub hf_transfer
   import os
   ）。UD-Q2_K_XLや他の量子化版を選べます。
   from huggingface_hub import snapshot_download
   snapshot_download(
       os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "0" # 速度制限されることがあるため、無効化するには0に設定
       repo_id = "unsloth/Qwen3-235B-A22B-Thinking-2507-GGUF",
       local_dir = "unsloth/Qwen3-235B-A22B-Thinking-2507-GGUF",
   )
   ```
4. モデルを実行して、任意のプロンプトを試してください。
5. 編集 `--threads -1` CPUスレッド数用の `--ctx-size` コンテキスト長262114用、 `--n-gpu-layers 99` GPUオフロードのレイヤー数用です。GPUのメモリ不足になる場合は調整してみてください。また、CPUのみ推論の場合は削除してください。

{% hint style="success" %}
を使って `-ot ".ffn_.*_exps.=CPU"` で、すべてのMoE層をCPUにオフロードします！これにより、非MoE層をすべて1枚のGPUに収められ、生成速度が向上します。GPU容量がもっとある場合は、正規表現をカスタマイズしてより多くの層を収めることができます。
{% endhint %}

{% code overflow="wrap" %}

```bash
./llama.cpp/llama-cli \
    --model unsloth/Qwen3-235B-A22B-Thinking-2507-GGUF/UD-Q2_K_XL/Qwen3-235B-A22B-Thinking-2507-UD-Q2_K_XL-00001-of-00002.gguf \
    --ctx-size 16384 \\
    --n-gpu-layers 99 \
    -hf unsloth/Qwen3-235B-A22B-Thinking-2507-GGUF:Q2_K_XL \
    --seed 3407 \
    --temp 0.6 \\
    -ot ".ffn_.*_exps.=CPU" \
    --top-p 0.95 \
    --top-k 20
    --min-p 0.0 \
```

{% endcode %}

### Instruct: Qwen3-**235B-A22B**-Instruct-2507

これは思考しないモデルなので、 `thinking=False` を設定する必要はなく、モデルは `<think> </think>` ブロックを生成しません。

#### ⚙️ベストプラクティス

最適な性能を得るために、以下の設定を推奨します:

**1. サンプリングパラメータ**: 次を使うことを推奨します `temperature=0.7, top_p=0.8, top_k=20, min_p=0.` `presence_penalty` を0〜2の間で、フレームワークが対応しているなら、際限のない繰り返しを減らすために設定します。

2\. **十分な出力長**: ほとんどのクエリでは、出力長を `16,384` トークンにするとよく、Instructモデルには十分です。

3\. **出力形式の標準化:** ベンチマーク時には、モデル出力を標準化するためにプロンプトを使うことを推奨します。

* **数学問題**: 含めてください `段階的に推論し、最終回答を\boxed{}の中に入れてください。` をプロンプトに入れてください。
* **多肢選択問題**: 回答を標準化するため、次のJSON構造をプロンプトに追加してください: 「\`answer\`フィールドに、選択肢の文字だけを使って選択を示してください。例: \`"answer": "C"。

#### :sparkles:llama.cppでQwen3-235B-A22B-Instructを実行:

Qwen3-235B-A22Bでは、最適化された推論と豊富なオプションのために、特にLlama.cppを使用します。

{% hint style="info" %}
もし **完全精度の未量子化版**が欲しいなら、私たちの `Q8_K_XL、Q8_0` または `BF16` 版を使ってください！
{% endhint %}

1. 最新のllama.cppを [GitHub](https://github.com/ggml-org/llama.cpp) で取得してください。以下のビルド手順に従うこともできます。変更してください `-DGGML_CUDA=ON` を `-DGGML_CUDA=OFF` GPU がない場合、または CPU 推論だけを使いたい場合。 **Apple Mac / Metal デバイスの場合**、次のように設定し `-DGGML_CUDA=OFF` その後は通常どおり続けてください。Metal サポートはデフォルトで有効です。

```bash
apt-get update
apt-get install pciutils build-essential cmake curl libcurl4-openssl-dev -y
git clone https://github.com/ggml-org/llama.cpp
cmake llama.cpp -B llama.cpp/build \
    -DBUILD_SHARED_LIBS=OFF -DGGML_CUDA=ON -DLLAMA_CURL=ON
cmake --build llama.cpp/build --config Release -j --clean-first --target llama-cli llama-gguf-split
cp llama.cpp/build/bin/llama-* llama.cpp
```

2\. llama.cppを直接使ってモデルをダウンロードすることもできますが、通常は `huggingface_hub` llama.cppを直接使うには、次を実行してください:\\

```bash
./llama.cpp/llama-cli \
    -hf unsloth/Qwen3-235B-A22B-Instruct-2507-GGUF:Q2_K_XL \
    --ctx-size 16384 \\
    --n-gpu-layers 99 \
    -hf unsloth/Qwen3-235B-A22B-Thinking-2507-GGUF:Q2_K_XL \
    --temp 0.7 \\
    -ot ".ffn_.*_exps.=CPU" \
    --top-p 0.8 \\
    --top-k 20 \\
    --repeat-penalty 1.0
```

3\. 以下をインストールした後、経由でモデルをダウンロードしてください `pip install huggingface_hub hf_transfer` --presence-penalty 1.0

```python
# !pip install huggingface_hub hf_transfer
import os
）。UD-Q2_K_XLや他の量子化版を選べます。
from huggingface_hub import snapshot_download
snapshot_download(
    repo_id = "unsloth/Qwen3-235B-A22B-Instruct-2507-GGUF",
    local_dir = "unsloth/Qwen3-235B-A22B-Instruct-2507-GGUF",
    local_dir = "unsloth/Qwen3-235B-A22B-Thinking-2507-GGUF",
)
```

4\. モデルを実行して、任意のプロンプトを試してください。5. 編集 `--threads -1` CPUスレッド数用の `--ctx-size` コンテキスト長262114用、 `--n-gpu-layers 99` GPUオフロードのレイヤー数用です。GPUのメモリ不足になる場合は調整してみてください。また、CPUのみ推論の場合は削除してください。

{% hint style="success" %}
を使って `-ot ".ffn_.*_exps.=CPU"` で、すべてのMoE層をCPUにオフロードします！これにより、非MoE層をすべて1枚のGPUに収められ、生成速度が向上します。GPU容量がもっとある場合は、正規表現をカスタマイズしてより多くの層を収めることができます。
{% endhint %}

{% code overflow="wrap" %}

```bash
./llama.cpp/llama-cli \
    --model unsloth/Qwen3-235B-A22B-Instruct-2507-GGUF/UD-Q2_K_XL/Qwen3-235B-A22B-Instruct-2507-UD-Q2_K_XL-00001-of-00002.gguf \
    --ctx-size 16384 \\
    --n-gpu-layers 99 \
    -hf unsloth/Qwen3-235B-A22B-Thinking-2507-GGUF:Q2_K_XL \
    --temp 0.7 \\
    -ot ".ffn_.*_exps.=CPU" \
    --top-p 0.8 \\
    --top-k 20
```

{% endcode %}

### 🛠️ 生成速度の改善 <a href="#improving-generation-speed" id="improving-generation-speed"></a>

VRAMに余裕があれば、より多くのMoE層をオフロードするか、層全体をオフロードしてみてください。

通常は、 `-ot ".ffn_.*_exps.=CPU"` すべてのMoE層をCPUにオフロードします！これにより、非MoE層をすべて1枚のGPUに収められ、生成速度が向上します。GPU容量がもっとある場合は、正規表現をカスタマイズしてより多くの層を収めることができます。

GPUメモリがもう少しあるなら、次を試してください `-ot ".ffn_(up|down)_exps.=CPU"` これは上方向・下方向の投影MoE層をオフロードします。

次を試してください `-ot ".ffn_(up)_exps.=CPU"` GPUメモリがさらにある場合。これは上方向投影のMoE層だけをオフロードします。

正規表現をカスタマイズすることもできます。たとえば `-ot "\.(6|7|8|9|[0-9][0-9]|[0-9][0-9][0-9])\.ffn_(gate|up|down)_exps.=CPU"` は、6層目以降のゲート、上方向、下方向のMoE層をオフロードすることを意味します。

この [最新のllama.cppリリースは](https://github.com/ggml-org/llama.cpp/pull/14363) も高スループットモードを導入しています。 `llama-parallel`を使用してください。詳細は [こちら](https://github.com/ggml-org/llama.cpp/tree/master/examples/parallel)。また、 **KVキャッシュを4ビットに量子化することもできます** たとえばVRAM/RAMの移動を減らすことで、生成処理を高速化できます。 [次のセクション](#how-to-fit-long-context-256k-to-1m) ではKVキャッシュ量子化について説明します。

### 📐長いコンテキストを収める方法 <a href="#how-to-fit-long-context-256k-to-1m" id="how-to-fit-long-context-256k-to-1m"></a>

より長いコンテキストを収めるには、 **KV キャッシュ量子化** を使ってKとVのキャッシュをより低いビットに量子化できます。これにより、RAM/VRAM間のデータ移動が減るため生成速度も向上します。K量子化の許可オプション（デフォルトは `f16`）には以下が含まれます。

`--cache-type-k f32, f16, bf16, q8_0, q4_0, q4_1, iq4_nl, q5_0, q5_1`

やや精度を上げるには、 `_1` 版を使うべきです。少し遅くはなりますが。例えば `q4_1, q5_1` ですので、次を試してください `--cache-type-k q4_1`

Vキャッシュも量子化できますが、 **Flash Attention対応でllama.cppをコンパイルする** 必要があります。 `-DGGML_CUDA_FA_ALL_QUANTS=ON`、そして `--flash-attn` を通じて有効化してください。Flash Attentionをインストールした後は、次を使えます `--cache-type-v q4_1`

## 🦥 UnslothでQwen3-2507をファインチューニング

Unslothは [Qwen3](/docs/jp/moderu/tutorials/qwen3-how-to-run-and-fine-tune.md#fine-tuning-qwen3-with-unsloth) Qwen3-2507のファインチューニングを2倍高速化し、VRAM使用量を70%削減し、8倍長いコンテキスト長をサポートします。Qwen3-2507は30Bバリアントのみのリリースだったため、QLoRA（4ビット）でモデルをファインチューニングするには約40GBのA100 GPUが必要になります。

ノートブックの場合、Colabの無料16GB GPUにはモデルが収まらないため、40GBのA100を使う必要があります。会話用ノートブックを利用できますが、データセットは自分のものに置き換えてください。今回はモデルに推論能力がないため、データセットに推論を組み込む必要はありません。

* [Qwen3 (14B) Reasoning + Conversational ノートブック](https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Qwen3_\(14B\)-Reasoning-Conversational.ipynb)

古いバージョンの Unsloth を使っている場合やローカルでファインチューニングしている場合は、最新バージョンの Unsloth をインストールしてください:

```bash
pip install --upgrade --force-reinstall --no-cache-dir unsloth unsloth_zoo
```

### Qwen3-2507 MOEモデルのファインチューニング

ファインチューニングのサポートにはMOEモデル: 30B-A3Bと235B-A22Bが含まれます。Qwen3-30B-A3BはUnslothで30GB VRAMで動作します。MoEのファインチューニングでは、ルーター層をファインチューニングするのはおそらく良い考えではないため、デフォルトで無効化しています。

**Qwen3-2507-4B ノートブック:** [Thinking](https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Qwen3_\(4B\)-Thinking.ipynb) および [Instruct](https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Qwen3_\(4B\)-Instruct.ipynb)

30B-A3Bは30GB VRAMに収まりますが、QLoRAファインチューニング用に16ビットの完全なモデルをダウンロードしてその場で4ビットに変換する必要があるため、RAMまたはディスク容量が不足する可能性があります。これは4ビットBnB MOEモデルを直接インポートする際の問題によるものです。これはMOEモデルのみに影響します。

{% hint style="warning" %}
MOEモデルをファインチューニングする場合は、 `FastModel` を使ってください、 `FastLanguageModel`
{% endhint %}

```python
from unsloth import FastModel
import torch
model, tokenizer = FastModel.from_pretrained(
    model_name = "unsloth/Qwen3-30B-A3B-Instruct-2507",
    max_seq_length = 2048, # 長いコンテキストなら任意で選択！
    load_in_4bit = True,  # メモリ削減のための 4 ビット量子化
    load_in_8bit = False, # [NEW!] 少し正確で、2倍のメモリを使います
    full_finetuning = False, # [新機能!] 完全ファインチューニングに対応しました!
    # token = "hf_...", # ゲート付きモデルを使う場合はこれを使用
)
```

<figure><img src="/files/660ad1e8074c7fda524859db13f0518677d570b2" alt=""><figcaption></figcaption></figure>


---

# 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/moderu/tutorials/qwen3-how-to-run-and-fine-tune/qwen3-2507.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.
