今回は、画像生成用のモデルをGGUF形式に変換する方法です。
まず「GGUF」について触れておくと、モデルを「量子化」することで軽量化・高速化を実現するためのフォーマットです。もともとはLLM(ChatGPTなどの大規模言語モデル)の分野で、巨大なモデルを家庭用PCでも動作させるために開発されたものですが、最近では「FLUX.1」の登場をきっかけに、画像生成の界隈でも広く普及しています。
この方法で効率的な画像生成ができるのか、試してみました。
「SDXLもGGUF化すれば効率が上がるのでは?」と調べ始めたのがきっかけですが、結論から書くと、私の環境(RTX 5070 / VRAM 12GB)ではSDXLをGGUF化するメリットはほとんどなく、むしろ生成速度が低下したという結果でした。
Geminiに聞きながら原因を考えましたが、恐らく以下の理由からです。
- VRAM容量の余裕:SDXL(約6GB)はVRAM 12GBでロードしきれるため、そもそもGGUFで軽量化する必要性がない。
- 計算のオーバーヘッド:GGUF形式は推論(画像生成)のたびに「デクォンタイズ(展開処理)」が発生し、これが待ち時間となり生成速度が遅くなる。
- GPU性能のミスマッチ:RTX5070はFP16やFP8の演算に最適化されているが、GGUF形式だとその恩恵を受けられない。
というわけで、VRAMに余裕があるならGGUFに変換せず動かすのがベストという結論に至りました。
とはいえ、VRAMに収まらないモデルを動かすのであればGGUF化は有効な選択肢です。それに、今後、より大きなモデルを扱う際の備忘録も兼ね、今回調べた内容は記事に昇華させておきます。
1. 必要なツール類のセットアップ
まずは事前準備として、GGUF変換に必要なツール類をセットアップします。既にインストール済みならスキップし先の手順に進みます。
1-1. MSVC ビルドツールのセットアップ
Visual Studio 2026 に含まれている、MSVCビルドツールをセットアップします。
Visual Studio 2026 のダウンロード
Microsoftの公式サイトへアクセスし、無料で利用できるCommunity版をダウンロードします。


MSVCビルドツール のインストール
ダウンロードしたインストーラを実行します。
表示されるワークロードの選択画面で、「C++によるデスクトップ開発」にチェックを入れて「インストール」ボタンをクリックします。

1-2. cmake のセットアップ
「cmake」をセットアップします。
cmake のダウンロード
Microsoftの公式サイトからダウンロードします。
ここではZIP版をダウンロードしますが、Installer版でも構いません。

cmake のインストール
ダウンロードしたZIPファイル(例: cmake-4.2.1-windows-x86_64.zip)を展開(解凍)します。
展開されたフォルダを、任意の分かりやすい場所に配置します。このブログでは、以下の位置に配置しました。
I:\tools\cmake-4.2.1-windows-x86_64※ZIP版は配置するだけでインストール完了です。Installer版を選んだ場合は、指示に従ってインストールを完了させてください。
1-3. Git のセットアップ
「Git」をセットアップします。
Git のダウンロード
下記の公式サイトからダウンロードします。ここでは「Git for Windows/x64 Portable.(ポータブル版)」を選択していますが、「Git for Windows/x64 Setup.(インストーラー版)」でも構いません。

Git のインストール
ダウンロードした自己解凍形式のZIPファイル(例: PortableGit-2.52.0-64-bit.7z.exe)を実行すると、フォルダが展開されます。
展開後のフォルダを任意の分かりやすい場所に配置します。このブログでは、以下の位置に配置しました。
I:\tools\PortableGitパスの設定
Gitの実行ファイルまでのパスを環境変数Pathに追加します。追加するパスは以下の通りです。
I:\tools\PortableGit\binここでの環境変数に追加する具体的な手順は割愛しますが、前回の記事で詳しく触れていますので、参考にしてみてください。
1-4. Python のセットアップ
「Python」をセットアップします。
Python のダウンロード
公式サイトからダウンロードできますが、最新版では上手くいかなかったため、バージョン 3.12 を選択しています。


Python のインストール
ダウンロードしたインストーラーを実行します。
インストール画面下部にある「Add python.exe to PATH」にチェックを入れてから「Install Now」をクリックして開始します。
※既に別のバージョンのPythonがインストールされている場合は、チェックの有無を含め、適宜対応してください。

1-5. ComfyUI-GGUF のセットアップ
「ComfyUI-GGUF」をクローンします。これは本来ComfyUIのカスタムノードですが、ここでは同梱されているGGUF変換ツールの利用が目的となります。
リポジトリのクローン
Gitコマンドで ComfyUI-GGUF をクローンします。ここでは I:\tools にクローンしています。
cd I:\tools
git clone https://github.com/city96/ComfyUI-GGUF下記は実行結果です。
I:\>cd I:\tools
I:\tools>git clone https://github.com/city96/ComfyUI-GGUF
Cloning into 'ComfyUI-GGUF'...
remote: Enumerating objects: 783, done.
remote: Counting objects: 100% (484/484), done.
remote: Compressing objects: 100% (182/182), done.
remote: Total 783 (delta 439), reused 302 (delta 302), pack-reused 299 (from 1)
Receiving objects: 100% (783/783), 182.11 KiB | 5.06 MiB/s, done.
Resolving deltas: 100% (524/524), done.
I:\tools>dir | findstr GGUF
2026/01/04 12:29 <DIR> ComfyUI-GGUF
I:\tools>Python 仮想環境の作成
必須ではありませんが、Pythonの環境を別にしたいので仮想環境(venv)を用意します。ここでは I:\tools\ComfyUI-GGUF 内に作成します。
cd I:\tools\ComfyUI-GGUF
python -m venv venv下記は実行結果です。
i:\>cd I:\tools\ComfyUI-GGUF
I:\tools\ComfyUI-GGUF>python -m venv venv
I:\tools\ComfyUI-GGUF>dir
Volume in drive I is AI
Volume Serial Number is A8B1-D895
Directory of I:\tools\ComfyUI-GGUF
2026/01/04 13:40 <DIR> .
2026/01/04 12:40 <DIR> ..
2026/01/04 12:29 3,351 .gitignore
2026/01/04 12:29 12,338 dequant.py
2026/01/04 12:29 11,558 LICENSE
2026/01/04 12:29 17,135 loader.py
2026/01/04 12:29 13,393 nodes.py
2026/01/04 12:29 12,201 ops.py
2026/01/04 12:29 419 pyproject.toml
2026/01/04 12:29 3,274 README.md
2026/01/04 12:29 71 requirements.txt
2026/01/04 12:40 <DIR> tools
2026/01/04 13:40 <DIR> venv
2026/01/04 12:29 309 __init__.py
10 File(s) 74,049 bytes
4 Dir(s) 1,239,358,373,888 bytes free
I:\tools\ComfyUI-GGUF>依存関係のインストール
「ComfyUI-GGUF」が要求するパッケージや、PyTorchなどをインストールします。
仮想環境の有効化
まず、作成したPython仮想環境を有効にします。
cd I:\tools\ComfyUI-GGUF
.\venv\Scripts\activate下記は実行結果です。
I:\>cd I:\tools\ComfyUI-GGUF
I:\tools\ComfyUI-GGUF>.\venv\Scripts\activate
(venv) I:\tools\ComfyUI-GGUF>pip のアップグレード
pipを最新にします。引き続き仮想環境で下記のコマンドを実行します。
python -m pip install --upgrade pip下記は実行結果です。
(venv) I:\tools\ComfyUI-GGUF>python -m pip install --upgrade pip
Requirement already satisfied: pip in i:\tools\comfyui-gguf\venv\lib\site-packages (25.0.1)
Collecting pip
Using cached pip-25.3-py3-none-any.whl.metadata (4.7 kB)
Using cached pip-25.3-py3-none-any.whl (1.8 MB)
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 25.0.1
Uninstalling pip-25.0.1:
Successfully uninstalled pip-25.0.1
Successfully installed pip-25.3
(venv) I:\tools\ComfyUI-GGUF>ComfyUI-GGUF 要求パッケージのインストール
ComfyUI-GGUFが動作するために必要なパッケージを一括でインストールします。引き続き仮想環境で下記のコマンドを実行します。
python -m pip install -r requirements.txt下記は実行結果です。
(venv) I:\tools\ComfyUI-GGUF>cd I:\tools\ComfyUI-GGUF
(venv) I:\tools\ComfyUI-GGUF>python -m pip install -r requirements.txt
Collecting gguf>=0.13.0 (from -r requirements.txt (line 2))
Using cached gguf-0.17.1-py3-none-any.whl.metadata (4.3 kB)
Collecting sentencepiece (from -r requirements.txt (line 4))
Using cached sentencepiece-0.2.1-cp312-cp312-win_amd64.whl.metadata (10 kB)
Collecting protobuf (from -r requirements.txt (line 5))
Using cached protobuf-6.33.2-cp310-abi3-win_amd64.whl.metadata (593 bytes)
Collecting numpy>=1.17 (from gguf>=0.13.0->-r requirements.txt (line 2))
Using cached numpy-2.4.0-cp312-cp312-win_amd64.whl.metadata (6.6 kB)
Collecting pyyaml>=5.1 (from gguf>=0.13.0->-r requirements.txt (line 2))
Using cached pyyaml-6.0.3-cp312-cp312-win_amd64.whl.metadata (2.4 kB)
Collecting tqdm>=4.27 (from gguf>=0.13.0->-r requirements.txt (line 2))
Using cached tqdm-4.67.1-py3-none-any.whl.metadata (57 kB)
Collecting colorama (from tqdm>=4.27->gguf>=0.13.0->-r requirements.txt (line 2))
Using cached colorama-0.4.6-py2.py3-none-any.whl.metadata (17 kB)
Using cached gguf-0.17.1-py3-none-any.whl (96 kB)
Using cached sentencepiece-0.2.1-cp312-cp312-win_amd64.whl (1.1 MB)
Using cached protobuf-6.33.2-cp310-abi3-win_amd64.whl (436 kB)
Using cached numpy-2.4.0-cp312-cp312-win_amd64.whl (12.3 MB)
Using cached pyyaml-6.0.3-cp312-cp312-win_amd64.whl (154 kB)
Using cached tqdm-4.67.1-py3-none-any.whl (78 kB)
Using cached colorama-0.4.6-py2.py3-none-any.whl (25 kB)
Installing collected packages: sentencepiece, pyyaml, protobuf, numpy, colorama, tqdm, gguf
Successfully installed colorama-0.4.6 gguf-0.17.1 numpy-2.4.0 protobuf-6.33.2 pyyaml-6.0.3 sentencepiece-0.2.1 tqdm-4.67.1
(venv) I:\tools\ComfyUI-GGUF>PyTorch とその他パッケージのインストール
同様に、GGUF変換処理の実行に必要な、PyTorchやその他のパッケージをインストールします。引き続き仮想環境で下記のコマンドを実行します。
pip install torch torchvision safetensors packaging --extra-index-url https://download.pytorch.org/whl/cu130下記は実行結果です。
(venv) I:\tools\ComfyUI-GGUF>pip install torch torchvision safetensors packaging --extra-index-url https://download.pytorch.org/whl/cu130
Looking in indexes: https://pypi.org/simple, https://download.pytorch.org/whl/cu130
Collecting torch
Using cached https://download.pytorch.org/whl/cu130/torch-2.9.1%2Bcu130-cp312-cp312-win_amd64.whl.metadata (29 kB)
Collecting torchvision
Using cached https://download.pytorch.org/whl/cu130/torchvision-0.24.1%2Bcu130-cp312-cp312-win_amd64.whl.metadata (6.1 kB)
Collecting safetensors
Using cached safetensors-0.7.0-cp38-abi3-win_amd64.whl.metadata (4.2 kB)
Collecting packaging
Using cached packaging-25.0-py3-none-any.whl.metadata (3.3 kB)
Collecting filelock (from torch)
Downloading filelock-3.20.2-py3-none-any.whl.metadata (2.1 kB)
Collecting typing-extensions>=4.10.0 (from torch)
Using cached https://download.pytorch.org/whl/typing_extensions-4.15.0-py3-none-any.whl.metadata (3.3 kB)
Collecting sympy>=1.13.3 (from torch)
Using cached sympy-1.14.0-py3-none-any.whl.metadata (12 kB)
Collecting networkx>=2.5.1 (from torch)
Using cached networkx-3.6.1-py3-none-any.whl.metadata (6.8 kB)
Collecting jinja2 (from torch)
Using cached https://download.pytorch.org/whl/jinja2-3.1.6-py3-none-any.whl.metadata (2.9 kB)
Collecting fsspec>=0.8.5 (from torch)
Using cached fsspec-2025.12.0-py3-none-any.whl.metadata (10 kB)
Collecting setuptools (from torch)
Using cached setuptools-80.9.0-py3-none-any.whl.metadata (6.6 kB)
Requirement already satisfied: numpy in i:\tools\comfyui-gguf\venv\lib\site-packages (from torchvision) (2.4.0)
Collecting pillow!=8.3.*,>=5.3.0 (from torchvision)
Downloading pillow-12.1.0-cp312-cp312-win_amd64.whl.metadata (9.0 kB)
Collecting mpmath<1.4,>=1.1.0 (from sympy>=1.13.3->torch)
Using cached mpmath-1.3.0-py3-none-any.whl.metadata (8.6 kB)
Collecting MarkupSafe>=2.0 (from jinja2->torch)
Downloading markupsafe-3.0.3-cp312-cp312-win_amd64.whl.metadata (2.8 kB)
Using cached https://download.pytorch.org/whl/cu130/torch-2.9.1%2Bcu130-cp312-cp312-win_amd64.whl (1862.1 MB)
Using cached https://download.pytorch.org/whl/cu130/torchvision-0.24.1%2Bcu130-cp312-cp312-win_amd64.whl (8.9 MB)
Using cached safetensors-0.7.0-cp38-abi3-win_amd64.whl (341 kB)
Using cached packaging-25.0-py3-none-any.whl (66 kB)
Using cached fsspec-2025.12.0-py3-none-any.whl (201 kB)
Using cached networkx-3.6.1-py3-none-any.whl (2.1 MB)
Downloading pillow-12.1.0-cp312-cp312-win_amd64.whl (7.0 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 7.0/7.0 MB 10.1 MB/s 0:00:00
Using cached sympy-1.14.0-py3-none-any.whl (6.3 MB)
Using cached mpmath-1.3.0-py3-none-any.whl (536 kB)
Using cached https://download.pytorch.org/whl/typing_extensions-4.15.0-py3-none-any.whl (44 kB)
Downloading filelock-3.20.2-py3-none-any.whl (16 kB)
Using cached https://download.pytorch.org/whl/jinja2-3.1.6-py3-none-any.whl (134 kB)
Downloading markupsafe-3.0.3-cp312-cp312-win_amd64.whl (15 kB)
Using cached setuptools-80.9.0-py3-none-any.whl (1.2 MB)
Installing collected packages: mpmath, typing-extensions, sympy, setuptools, safetensors, pillow, packaging, networkx, MarkupSafe, fsspec, filelock, jinja2, torch, torchvision
Successfully installed MarkupSafe-3.0.3 filelock-3.20.2 fsspec-2025.12.0 jinja2-3.1.6 mpmath-1.3.0 networkx-3.6.1 packaging-25.0 pillow-12.1.0 safetensors-0.7.0 setuptools-80.9.0 sympy-1.14.0 torch-2.9.1+cu130 torchvision-0.24.1+cu130 typing-extensions-4.15.0
(venv) I:\tools\ComfyUI-GGUF>1-6. カスタム llama.cpp のビルド
GGUFの変換・量子化を行うツールとして、画像生成モデルに対応させた「llama.cpp」をビルドします。手順はComfyUI-GGUFのドキュメントを参考に進めます。
llama.cpp のクローン
まず、llama.cpp のリポジトリをクローンします。ここでは I:\tools\ComfyUI-GGUF\tools にクローンしています。これまでと同様に、以降も仮想環境を有効にした状態で作業を行います。
cd I:\tools\ComfyUI-GGUF\tools
git clone https://github.com/ggerganov/llama.cpp下記は実行結果です。
(venv) I:\>cd i:\tools\ComfyUI-GGUF\tools
(venv) i:\tools\ComfyUI-GGUF\tools>git clone https://github.com/ggerganov/llama.cpp
Cloning into 'llama.cpp'...
remote: Enumerating objects: 74889, done.
remote: Counting objects: 100% (158/158), done.
remote: Compressing objects: 100% (115/115), done.
remote: Total 74889 (delta 109), reused 43 (delta 43), pack-reused 74731 (from 2)
Receiving objects: 100% (74889/74889), 274.11 MiB | 10.50 MiB/s, done.
Resolving deltas: 100% (54291/54291), done.
Updating files: 100% (2097/2097), done.
(venv) i:\tools\ComfyUI-GGUF\tools>llama.cpp へのパッチ適用
llama.cpp に、画像生成AIに対応させるための改造パッチを適用します。
cd I:\tools\ComfyUI-GGUF\tools\llama.cpp
git checkout tags/b3962
git apply ..\lcpp.patch下記は実行結果です。
(venv) i:\tools\ComfyUI-GGUF\tools>cd I:\tools\ComfyUI-GGUF\tools\llama.cpp
(venv) I:\tools\ComfyUI-GGUF\tools\llama.cpp>git checkout tags/b3962
Note: switching to 'tags/b3962'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:
git switch -c <new-branch-name>
Or undo this operation with:
git switch -
Turn off this advice by setting config variable advice.detachedHead to false
HEAD is now at c8c07d658 llama : fix empty batch causing llama_batch_allocr to crash (#9966)
(venv) I:\tools\ComfyUI-GGUF\tools\llama.cpp>git apply ..\lcpp.patch
(venv) I:\tools\ComfyUI-GGUF\tools\llama.cpp>llama.cpp のビルド環境構築
パッチを適用したllama.cppをビルドするための環境を構築します。引き続き仮想環境でコマンドを実行します。
※ cmake.exe のパス(例: I:\tools\cmake-4.2.1-windows-x86_64\bin\cmake.exe)は、ご自身の環境に合わせて適宜読み替えてください。
mkdir build
"I:\tools\cmake-4.2.1-windows-x86_64\bin\cmake.exe" -B build -G "Visual Studio 18 2026" -A x64 -DCMAKE_CXX_STANDARD=17 -DCMAKE_CXX_STANDARD_REQUIRED=ON下記は実行結果です。
(venv) I:\tools\ComfyUI-GGUF\tools\llama.cpp>mkdir build
(venv) I:\tools\ComfyUI-GGUF\tools\llama.cpp>"I:\tools\cmake-4.2.1-windows-x86_64\bin\cmake.exe" -B build -G "Visual Studio 18 2026" -A x64 -DCMAKE_CXX_STANDARD=17 -DCMAKE_CXX_STANDARD_REQUIRED=ON
-- Selecting Windows SDK version 10.0.26100.0 to target Windows 10.0.26200.
-- The C compiler identification is MSVC 19.50.35721.0
-- The CXX compiler identification is MSVC 19.50.35721.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/18/Community/VC/Tools/MSVC/14.50.35717/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/18/Community/VC/Tools/MSVC/14.50.35717/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Git: I:/tools/PortableGit/bin/git.exe (found version "2.52.0.windows.1")
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - not found
-- Found Threads: TRUE
-- Found OpenMP_C: -openmp (found version "2.0")
-- Found OpenMP_CXX: -openmp (found version "2.0")
-- Found OpenMP: TRUE (found version "2.0")
-- OpenMP found
-- Using llamafile
CMake Warning at ggml/src/CMakeLists.txt:274 (message):
AMX requires gcc version > 11.0. Turning off GGML_AMX.
-- Warning: ccache not found - consider installing it for faster compilation or disable this warning with GGML_CCACHE=OFF
-- CMAKE_SYSTEM_PROCESSOR: AMD64
-- CMAKE_GENERATOR_PLATFORM: x64
-- x86 detected
-- Performing Test HAS_AVX_1
-- Performing Test HAS_AVX_1 - Success
-- Performing Test HAS_AVX2_1
-- Performing Test HAS_AVX2_1 - Success
-- Performing Test HAS_FMA_1
-- Performing Test HAS_FMA_1 - Success
-- Performing Test HAS_AVX512_1
-- Performing Test HAS_AVX512_1 - Failed
-- Performing Test HAS_AVX512_2
-- Performing Test HAS_AVX512_2 - Failed
-- Configuring done (9.0s)
-- Generating done (0.7s)
-- Build files have been written to: I:/tools/ComfyUI-GGUF/tools/llama.cpp/build
(venv) I:\tools\ComfyUI-GGUF\tools\llama.cpp>ソースファイルの一部修正
このままビルドするとエラーが発生するため、手順に従いソースファイルの一部を修正します。修正対象のファイルは log.cpp で、これをメモ帳などで直接修正します。
I:\tools\ComfyUI-GGUF\tools\llama.cpp\common\log.cpp修正箇所は下記の通り、3~4行目を追記します。
#include "log.h"
#define _SILENCE_CXX23_CHRONO_DEPRECATION_WARNING
#include <chrono>
#include <condition_variable>
#include <cstdarg>
#include <cstdio>
#include <mutex>
:(省略)llama.cpp のビルド実行
最後に、llama.cppのビルドを実行します。
※ cmake.exe のパスは、ご自身の環境に合わせて適宜読み替えてください。
cd I:\tools\ComfyUI-GGUF\tools\llama.cpp
"I:\tools\cmake-4.2.1-windows-x86_64\bin\cmake.exe" --build build --config Debug -j10 --target llama-quantize下記は実行結果です。いくつか警告も出ていますが問題なく動くようです。(長いですが全ログ載せておきます)
(venv) I:\>cd I:\tools\ComfyUI-GGUF\tools\llama.cpp
(venv) I:\tools\ComfyUI-GGUF\tools\llama.cpp>"I:\tools\cmake-4.2.1-windows-x86_64\bin\cmake.exe" --build build --config Debug -j10 --target llama-quantize
MSBuild のバージョン 18.0.5+e22287bf1 (.NET Framework)
1>Checking Build System
Generating build details from Git
-- Found Git: I:/tools/PortableGit/bin/git.exe (found version "2.52.0.windows.1")
Building Custom Rule I:/tools/ComfyUI-GGUF/tools/llama.cpp/common/CMakeLists.txt
build-info.cpp
build_info.vcxproj -> I:\tools\ComfyUI-GGUF\tools\llama.cpp\build\common\build_info.dir\Debug\build_info.lib
Building Custom Rule I:/tools/ComfyUI-GGUF/tools/llama.cpp/ggml/src/CMakeLists.txt
ggml.c
ggml-alloc.c
ggml-quants.c
C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\ucrt\assert.h(21,9): warning C4005: 'static_assert': マクロが再定
義されました。 [I:\tools\ComfyUI-GGUF\tools\llama.cpp\build\ggml\src\ggml.vcxproj]
(compiling source file '../../../ggml/src/ggml-quants.c')
I:\tools\ComfyUI-GGUF\tools\llama.cpp\ggml\src\ggml-common.h(62,9):
'static_assert' の以前の定義を確認してください
ggml-aarch64.c
C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\ucrt\assert.h(21,9): warning C4005: 'static_assert': マクロが再定
義されました。 [I:\tools\ComfyUI-GGUF\tools\llama.cpp\build\ggml\src\ggml.vcxproj]
(compiling source file '../../../ggml/src/ggml-aarch64.c')
I:\tools\ComfyUI-GGUF\tools\llama.cpp\ggml\src\ggml-common.h(62,9):
'static_assert' の以前の定義を確認してください
コードを生成中...
ggml-backend.cpp
sgemm.cpp
コードを生成中...
Auto build dll exports
ライブラリ I:/tools/ComfyUI-GGUF/tools/llama.cpp/build/ggml/src/Debug/ggml.lib とオブジェクト I:/tools/ComfyUI-GGUF/tools/llam
a.cpp/build/ggml/src/Debug/ggml.exp を作成中
ggml.vcxproj -> I:\tools\ComfyUI-GGUF\tools\llama.cpp\build\bin\Debug\ggml.dll
Building Custom Rule I:/tools/ComfyUI-GGUF/tools/llama.cpp/src/CMakeLists.txt
llama.cpp
I:\tools\ComfyUI-GGUF\tools\llama.cpp\src\llama.cpp(6183,38): warning C4305: '=': 'double' から 'float' へ切り詰めます。 [I:\tool
s\ComfyUI-GGUF\tools\llama.cpp\build\src\llama.vcxproj]
llama-vocab.cpp
I:\tools\ComfyUI-GGUF\tools\llama.cpp\src\llama-vocab.cpp(147,26): warning C4244: 'return': 'long' から 'uint8_t' への変換です。
データが失われる可能性があります。 [I:\tools\ComfyUI-GGUF\tools\llama.cpp\build\src\llama.vcxproj]
I:\tools\ComfyUI-GGUF\tools\llama.cpp\src\llama-vocab.cpp(606,82): warning C4267: '=': 'size_t' から 'llm_symbol::index'
に変換しました。データが失われているかもしれません。 [I:\tools\ComfyUI-GGUF\tools\llama.cpp\build\src\llama.vcxproj]
I:\tools\ComfyUI-GGUF\tools\llama.cpp\src\llama-vocab.cpp(609,61): warning C4267: '=': 'size_t' から 'int' に変換しました。データが失わ
れているかもしれません。 [I:\tools\ComfyUI-GGUF\tools\llama.cpp\build\src\llama.vcxproj]
I:\tools\ComfyUI-GGUF\tools\llama.cpp\src\llama-vocab.cpp(702,37): warning C4267: '初期化中': 'size_t' から 'int' に変換しました。データ
が失われているかもしれません。 [I:\tools\ComfyUI-GGUF\tools\llama.cpp\build\src\llama.vcxproj]
I:\tools\ComfyUI-GGUF\tools\llama.cpp\src\llama-vocab.cpp(702,25): warning C4267: '初期化中': 'size_t' から 'const int' に変換しま
した。データが失われているかもしれません。 [I:\tools\ComfyUI-GGUF\tools\llama.cpp\build\src\llama.vcxproj]
I:\tools\ComfyUI-GGUF\tools\llama.cpp\src\llama-vocab.cpp(1752,20): warning C4267: 'return': 'size_t' から 'int32_t' に変換し
ました。データが失われているかもしれません。 [I:\tools\ComfyUI-GGUF\tools\llama.cpp\build\src\llama.vcxproj]
llama-grammar.cpp
llama-sampling.cpp
I:\tools\ComfyUI-GGUF\tools\llama.cpp\src\llama-sampling.cpp(122,18): warning C4267: '=': 'size_t' から 'int32_t' に変換しました
。データが失われているかもしれません。 [I:\tools\ComfyUI-GGUF\tools\llama.cpp\build\src\llama.vcxproj]
I:\tools\ComfyUI-GGUF\tools\llama.cpp\src\llama-sampling.cpp(401,28): warning C4267: 'return': 'size_t' から 'int' に変換しまし
た。データが失われているかもしれません。 [I:\tools\ComfyUI-GGUF\tools\llama.cpp\build\src\llama.vcxproj]
I:\tools\ComfyUI-GGUF\tools\llama.cpp\src\llama-sampling.cpp(1036,32): warning C4244: '=': 'double' から 'float' への変換です。デ
ータが失われる可能性があります。 [I:\tools\ComfyUI-GGUF\tools\llama.cpp\build\src\llama.vcxproj]
I:\tools\ComfyUI-GGUF\tools\llama.cpp\src\llama-sampling.cpp(1041,33): warning C4244: '/=': 'double' から 'float' への変換です。
データが失われる可能性があります。 [I:\tools\ComfyUI-GGUF\tools\llama.cpp\build\src\llama.vcxproj]
I:\tools\ComfyUI-GGUF\tools\llama.cpp\src\llama-sampling.cpp(1122,24): warning C4267: '=': 'size_t' から 'int' に変換しました。デー
タが失われているかもしれません。 [I:\tools\ComfyUI-GGUF\tools\llama.cpp\build\src\llama.vcxproj]
I:\tools\ComfyUI-GGUF\tools\llama.cpp\src\llama-sampling.cpp(1221,68): warning C4244: '引数': 'const int32_t' から 'float'
への変換です。データが失われる可能性があります。 [I:\tools\ComfyUI-GGUF\tools\llama.cpp\build\src\llama.vcxproj]
I:\tools\ComfyUI-GGUF\tools\llama.cpp\src\llama-sampling.cpp(1576,74): warning C4267: '引数': 'size_t' から 'const _Ty' に変換
しました。データが失われているかもしれません。 [I:\tools\ComfyUI-GGUF\tools\llama.cpp\build\src\llama.vcxproj]
I:\tools\ComfyUI-GGUF\tools\llama.cpp\src\llama-sampling.cpp(1576,74): warning C4267: with [I:\tools\ComfyUI-GG
UF\tools\llama.cpp\build\src\llama.vcxproj]
I:\tools\ComfyUI-GGUF\tools\llama.cpp\src\llama-sampling.cpp(1576,74): warning C4267: [ [I:\tools\ComfyUI-GGUF\
tools\llama.cpp\build\src\llama.vcxproj]
I:\tools\ComfyUI-GGUF\tools\llama.cpp\src\llama-sampling.cpp(1576,74): warning C4267: _Ty=int32_t [I:\tools
\ComfyUI-GGUF\tools\llama.cpp\build\src\llama.vcxproj]
I:\tools\ComfyUI-GGUF\tools\llama.cpp\src\llama-sampling.cpp(1576,74): warning C4267: ] [I:\tools\ComfyUI-GGUF\
tools\llama.cpp\build\src\llama.vcxproj]
I:\tools\ComfyUI-GGUF\tools\llama.cpp\src\llama-sampling.cpp(1735,76): warning C4267: '引数': 'size_t' から 'int32_t' に変換しま
した。データが失われているかもしれません。 [I:\tools\ComfyUI-GGUF\tools\llama.cpp\build\src\llama.vcxproj]
I:\tools\ComfyUI-GGUF\tools\llama.cpp\src\llama-sampling.cpp(1849,115): warning C4267: '引数': 'size_t' から 'int32_t' に変換し
ました。データが失われているかもしれません。 [I:\tools\ComfyUI-GGUF\tools\llama.cpp\build\src\llama.vcxproj]
I:\tools\ComfyUI-GGUF\tools\llama.cpp\src\llama-sampling.cpp(1852,115): warning C4267: '引数': 'size_t' から 'int32_t' に変換し
ました。データが失われているかもしれません。 [I:\tools\ComfyUI-GGUF\tools\llama.cpp\build\src\llama.vcxproj]
I:\tools\ComfyUI-GGUF\tools\llama.cpp\src\llama-sampling.cpp(1856,115): warning C4267: '引数': 'size_t' から 'int32_t' に変換し
ました。データが失われているかもしれません。 [I:\tools\ComfyUI-GGUF\tools\llama.cpp\build\src\llama.vcxproj]
I:\tools\ComfyUI-GGUF\tools\llama.cpp\src\llama-sampling.cpp(1859,115): warning C4267: '引数': 'size_t' から 'int32_t' に変換し
ました。データが失われているかもしれません。 [I:\tools\ComfyUI-GGUF\tools\llama.cpp\build\src\llama.vcxproj]
I:\tools\ComfyUI-GGUF\tools\llama.cpp\src\llama-sampling.cpp(1865,25): warning C4267: '初期化中': 'size_t' から 'int' に変換しました
。データが失われているかもしれません。 [I:\tools\ComfyUI-GGUF\tools\llama.cpp\build\src\llama.vcxproj]
I:\tools\ComfyUI-GGUF\tools\llama.cpp\src\llama-sampling.cpp(1866,25): warning C4267: '初期化中': 'size_t' から 'int' に変換しました
。データが失われているかもしれません。 [I:\tools\ComfyUI-GGUF\tools\llama.cpp\build\src\llama.vcxproj]
I:\tools\ComfyUI-GGUF\tools\llama.cpp\src\llama-sampling.cpp(1930,16): warning C4244: '=': 'double' から 'float' への変換です。デ
ータが失われる可能性があります。 [I:\tools\ComfyUI-GGUF\tools\llama.cpp\build\src\llama.vcxproj]
unicode.cpp
unicode-data.cpp
コードを生成中...
Auto build dll exports
ライブラリ I:/tools/ComfyUI-GGUF/tools/llama.cpp/build/src/Debug/llama.lib とオブジェクト I:/tools/ComfyUI-GGUF/tools/llama.cp
p/build/src/Debug/llama.exp を作成中
llama.vcxproj -> I:\tools\ComfyUI-GGUF\tools\llama.cpp\build\bin\Debug\llama.dll
Building Custom Rule I:/tools/ComfyUI-GGUF/tools/llama.cpp/common/CMakeLists.txt
arg.cpp
I:\tools\ComfyUI-GGUF\tools\llama.cpp\common\arg.cpp(1942,41): warning C4834: [[nodiscard]] 属性を持つ関数の戻り値を破棄しています [I:\too
ls\ComfyUI-GGUF\tools\llama.cpp\build\common\common.vcxproj]
common.cpp
console.cpp
I:\tools\ComfyUI-GGUF\tools\llama.cpp\common\console.cpp(256,30): warning C4267: '初期化中': 'size_t' から 'DWORD' に変換しました。デー
タが失われているかもしれません。 [I:\tools\ComfyUI-GGUF\tools\llama.cpp\build\common\common.vcxproj]
I:\tools\ComfyUI-GGUF\tools\llama.cpp\common\console.cpp(410,28): warning C4267: '初期化中': 'size_t' から 'int' に変換しました。データが
失われているかもしれません。 [I:\tools\ComfyUI-GGUF\tools\llama.cpp\build\common\common.vcxproj]
json-schema-to-grammar.cpp
I:\tools\ComfyUI-GGUF\tools\llama.cpp\common\json-schema-to-grammar.cpp(139,46): warning C4267: '引数': 'size_t' から 'int'
に変換しました。データが失われているかもしれません。 [I:\tools\ComfyUI-GGUF\tools\llama.cpp\build\common\common.vcxproj]
I:\tools\ComfyUI-GGUF\tools\llama.cpp\common\json-schema-to-grammar.cpp(139,37): warning C4267: '引数': 'size_t' から 'int'
に変換しました。データが失われているかもしれません。 [I:\tools\ComfyUI-GGUF\tools\llama.cpp\build\common\common.vcxproj]
I:\tools\ComfyUI-GGUF\tools\llama.cpp\common\json-schema-to-grammar.cpp(154,50): warning C4267: '引数': 'size_t' から 'int'
に変換しました。データが失われているかもしれません。 [I:\tools\ComfyUI-GGUF\tools\llama.cpp\build\common\common.vcxproj]
I:\tools\ComfyUI-GGUF\tools\llama.cpp\common\json-schema-to-grammar.cpp(154,41): warning C4267: '引数': 'size_t' から 'int'
に変換しました。データが失われているかもしれません。 [I:\tools\ComfyUI-GGUF\tools\llama.cpp\build\common\common.vcxproj]
I:\tools\ComfyUI-GGUF\tools\llama.cpp\common\json-schema-to-grammar.cpp(234,29): warning C4267: '引数': 'size_t' から 'int'
に変換しました。データが失われているかもしれません。 [I:\tools\ComfyUI-GGUF\tools\llama.cpp\build\common\common.vcxproj]
I:\tools\ComfyUI-GGUF\tools\llama.cpp\common\json-schema-to-grammar.cpp(245,33): warning C4267: '引数': 'size_t' から 'int'
に変換しました。データが失われているかもしれません。 [I:\tools\ComfyUI-GGUF\tools\llama.cpp\build\common\common.vcxproj]
I:\tools\ComfyUI-GGUF\tools\llama.cpp\common\json-schema-to-grammar.cpp(558,60): warning C4101: 'e': ローカル変数は 1 度も使われていま
せん。 [I:\tools\ComfyUI-GGUF\tools\llama.cpp\build\common\common.vcxproj]
log.cpp
ngram-cache.cpp
I:\tools\ComfyUI-GGUF\tools\llama.cpp\common\ngram-cache.cpp(23,51): warning C4244: '引数': 'int64_t' から 'const int' への変換
です。データが失われる可能性があります。 [I:\tools\ComfyUI-GGUF\tools\llama.cpp\build\common\common.vcxproj]
I:\tools\ComfyUI-GGUF\tools\llama.cpp\common\ngram-cache.cpp(103,16): warning C4267: '初期化中': 'size_t' から 'int' に変換しました。
データが失われているかもしれません。 [I:\tools\ComfyUI-GGUF\tools\llama.cpp\build\common\common.vcxproj]
I:\tools\ComfyUI-GGUF\tools\llama.cpp\common\ngram-cache.cpp(150,34): warning C4267: '初期化中': 'size_t' から 'int' に変換しました。
データが失われているかもしれません。 [I:\tools\ComfyUI-GGUF\tools\llama.cpp\build\common\common.vcxproj]
I:\tools\ComfyUI-GGUF\tools\llama.cpp\common\ngram-cache.cpp(150,24): warning C4267: '初期化中': 'size_t' から 'const int' に変
換しました。データが失われているかもしれません。 [I:\tools\ComfyUI-GGUF\tools\llama.cpp\build\common\common.vcxproj]
I:\tools\ComfyUI-GGUF\tools\llama.cpp\common\ngram-cache.cpp(159,82): warning C4267: '初期化中': 'size_t' から 'int' に変換しました。
データが失われているかもしれません。 [I:\tools\ComfyUI-GGUF\tools\llama.cpp\build\common\common.vcxproj]
I:\tools\ComfyUI-GGUF\tools\llama.cpp\common\ngram-cache.cpp(159,38): warning C4267: '初期化中': 'size_t' から 'const int' に変
換しました。データが失われているかもしれません。 [I:\tools\ComfyUI-GGUF\tools\llama.cpp\build\common\common.vcxproj]
I:\tools\ComfyUI-GGUF\tools\llama.cpp\common\ngram-cache.cpp(173,77): warning C4267: '初期化中': 'size_t' から 'int' に変換しました。
データが失われているかもしれません。 [I:\tools\ComfyUI-GGUF\tools\llama.cpp\build\common\common.vcxproj]
I:\tools\ComfyUI-GGUF\tools\llama.cpp\common\ngram-cache.cpp(173,38): warning C4267: '初期化中': 'size_t' から 'const int' に変
換しました。データが失われているかもしれません。 [I:\tools\ComfyUI-GGUF\tools\llama.cpp\build\common\common.vcxproj]
I:\tools\ComfyUI-GGUF\tools\llama.cpp\common\ngram-cache.cpp(205,50): warning C4267: '初期化中': 'size_t' から 'int32_t' に変換し
ました。データが失われているかもしれません。 [I:\tools\ComfyUI-GGUF\tools\llama.cpp\build\common\common.vcxproj]
I:\tools\ComfyUI-GGUF\tools\llama.cpp\common\ngram-cache.cpp(205,31): warning C4267: '初期化中': 'size_t' から 'const int32_t
' に変換しました。データが失われているかもしれません。 [I:\tools\ComfyUI-GGUF\tools\llama.cpp\build\common\common.vcxproj]
sampling.cpp
I:\tools\ComfyUI-GGUF\tools\llama.cpp\common\sampling.cpp(159,39): warning C4267: '引数': 'size_t' から 'int32_t' に変換しました。デ
ータが失われているかもしれません。 [I:\tools\ComfyUI-GGUF\tools\llama.cpp\build\common\common.vcxproj]
train.cpp
コードを生成中...
common.vcxproj -> I:\tools\ComfyUI-GGUF\tools\llama.cpp\build\common\Debug\common.lib
Building Custom Rule I:/tools/ComfyUI-GGUF/tools/llama.cpp/examples/quantize/CMakeLists.txt
quantize.cpp
llama-quantize.vcxproj -> I:\tools\ComfyUI-GGUF\tools\llama.cpp\build\bin\Debug\llama-quantize.exe
(venv) I:\tools\ComfyUI-GGUF\tools\llama.cpp>2. ComfyUI を利用したモデル要素の抽出と変換
ComfyUIを使い、Checkpointから「U-Net」、「Text-Encoder(CLIP)」、「VAE」を抽出します。
2-1. 抽出用ワークフローの作成
4つのノードが必要で、それぞれ「Load Checkpoint」、「ModelSave」、「CLIPSave」、「VAESave」を下図のようにつないだワークフローを作ります。また、実験台とするモデルですが、今回は「animaPencilXL_v500.safetensors」を利用させてもらいます。
抽出の実行ですが、Load Checkpointノードに対象とするモデル(Checkpoint)を指定しワークフローを実行します。その後、ComfyUIのoutputフォルダに各モデルが出力されます。

一応ワークフローのJSONを載せておきます。下記のJSONをコピーしてComfyUI上でペーストするとワークフローが読み込めると思います。
{
"id": "81e8e280-6c70-4cd7-8f74-ec7da72f7c26",
"revision": 0,
"last_node_id": 5,
"last_link_id": 3,
"nodes": [
{
"id": 3,
"type": "ModelSave",
"pos": [
700.3187411994279,
252.92720686404974
],
"size": [
270,
58
],
"flags": {},
"order": 1,
"mode": 0,
"inputs": [
{
"name": "model",
"type": "MODEL",
"link": 1
}
],
"outputs": [],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.6.0",
"Node name for S&R": "ModelSave"
},
"widgets_values": [
"diffusion_models/ComfyUI"
]
},
{
"id": 5,
"type": "CLIPSave",
"pos": [
704.0649458178405,
360.9733537367794
],
"size": [
270,
58
],
"flags": {},
"order": 2,
"mode": 0,
"inputs": [
{
"name": "clip",
"type": "CLIP",
"link": 2
}
],
"outputs": [],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.6.0",
"Node name for S&R": "CLIPSave"
},
"widgets_values": [
"clip/ComfyUI"
]
},
{
"id": 4,
"type": "VAESave",
"pos": [
705.9212522052587,
468.4806029932258
],
"size": [
270,
58
],
"flags": {},
"order": 3,
"mode": 0,
"inputs": [
{
"name": "vae",
"type": "VAE",
"link": 3
}
],
"outputs": [],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.6.0",
"Node name for S&R": "VAESave"
},
"widgets_values": [
"vae/ComfyUI_vae"
]
},
{
"id": 2,
"type": "CheckpointLoaderSimple",
"pos": [
359.94010337662644,
255.12272257025467
],
"size": [
270,
98
],
"flags": {},
"order": 0,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "MODEL",
"type": "MODEL",
"links": [
1
]
},
{
"name": "CLIP",
"type": "CLIP",
"links": [
2
]
},
{
"name": "VAE",
"type": "VAE",
"links": [
3
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.6.0",
"Node name for S&R": "CheckpointLoaderSimple"
},
"widgets_values": [
"SDXL\\2D\\animaPencilXL_v500.safetensors"
]
}
],
"links": [
[
1,
2,
0,
3,
0,
"MODEL"
],
[
2,
2,
1,
5,
0,
"CLIP"
],
[
3,
2,
2,
4,
0,
"VAE"
]
],
"groups": [],
"config": {},
"extra": {
"ds": {
"scale": 2.3579476910000023,
"offset": [
-145.56614105651755,
-79.1030742422984
]
},
"workflowRendererVersion": "LG",
"frontendVersion": "1.34.9"
},
"version": 0.4
}2-2. 抽出されたモデルのリネーム
必須ではないですが、識別しやすいように、抽出された各モデルのファイル名を変更します。
- U-Net: output\diffusion_models\ComfyUI_00001_.safetensors
→ animaPencilXL_v500_unet.safetensors - Text-Encoder (CLIP-L): output\clip\ComfyUI_clip_l_00001_.safetensors
→ animaPencilXL_v500_clipl.safetensors - Text-Encoder (CLIP-G): output\clip\ComfyUI_clip_g_00001_.safetensors
→ animaPencilXL_v500_clipg.safetensors - VAE: ComfyUI\output\vae\ComfyUI_vae_00001_.safetensors
→ animaPencilXL_v500_vae.safetensors
2-3. GGUF(F16)への変換
いよいよGGUFへの変換処理です。
U-Netに当たる「animaPencilXL_v500_unet.safetensors」を任意の作業用フォルダに移動します。ここでは下記の位置とします。
I:\tools\ComfyUI-GGUF\tools\model-work下記のコマンドを実行し、ComfyUI-GGUFに同梱されている変換用プログラムを使い、モデルをGGUF形式に変換します。
cd I:\tools\ComfyUI-GGUF\tools\model-work
..\..\venv\Scripts\activate
python ..\convert.py --src .\animaPencilXL_v500_unet.safetensors変換が終わるとGGUF形式のモデルが作成されます。
補足ですが、この時点では形式(フォーマット)が変わっただけなので、精度やファイルサイズの変化はほとんどありません。
animaPencilXL_v500_unet-F16.gguf下記は実行結果です。
I:\tools\ComfyUI-GGUF\tools>cd I:\tools\ComfyUI-GGUF\tools\model-work
I:\tools\ComfyUI-GGUF\tools\model-work>..\..\venv\Scripts\activate
(venv) I:\tools\ComfyUI-GGUF\tools\model-work>python ..\convert.py --src .\animaPencilXL_v500_unet.safetensors
input_blocks.0.0.bias torch.float16 --> F16, shape = {320}
input_blocks.0.0.weight torch.float16 --> F16, shape = {256, 45}
input_blocks.1.0.emb_layers.1.bias torch.float16 --> F16, shape = {320}
:(省略)
time_embed.2.bias torch.float16 --> F16, shape = {1280}
time_embed.2.weight torch.float16 --> F16, shape = {1280, 1280}
100%|████████████████████████████████████████████████████████████████████████████| 1680/1680 [00:00<00:00, 9861.49it/s]
Writing: 100%|█████████████████████████████████████████████████████████████████| 5.13G/5.13G [00:02<00:00, 2.03Gbyte/s]
(venv) I:\tools\ComfyUI-GGUF\tools\model-work>dir animaPencil*
Volume in drive I is AI
Volume Serial Number is A8B1-D895
Directory of I:\tools\ComfyUI-GGUF\tools\model-work
2026/01/04 20:24 5,135,086,048 animaPencilXL_v500_unet-F16.gguf
2026/01/04 19:56 5,135,177,504 animaPencilXL_v500_unet.safetensors
2 File(s) 10,270,263,552 bytes
0 Dir(s) 1,186,445,668,352 bytes free
(venv) I:\tools\ComfyUI-GGUF\tools\model-work>2-4. 低ビット量子化による圧縮
変換したGGUF(F16)形式のモデルを低ビット化します。
ここで実行する llama-quantize.exe による変換処理で、F16(16ビット)だったモデルをQ8(8ビット)やQ6(6ビット)といった低ビット形式へ変換すると、ファイルサイズがコンパクト化します。この際、K-Quantsなどの技術で「情報の削り方」が最適化されるため、低ビット化しても見た目や回答の精度が極端に悪くなるということはないようです。
先程に続き、下記のコマンドを実行し、GGUFの「Q4_K_S」に変換します。
..\llama.cpp\build\bin\Debug\llama-quantize.exe .\animaPencilXL_v500_unet-F16.gguf .\animaPencilXL_v500_unet-Q4_K_S.gguf Q4_K_Sllama-quantize.exe で指定するパラメータは下記の通りです。
llama-quantize.exe [入力:変換元のGGUFファイルパス] [出力:変換後のGGUFファイルパス] [量子化タイプ]また、[量子化タイプ] を指定するオプションですが、下記の表にある「量子化タイプ」から任意の値を指定することで、変換後のモデル精度を調整できます。(表はGeminiによるまとめ)
| カテゴリ | 量子化タイプ | ビット数 (bpw) | 特徴・推奨される用途 |
|---|---|---|---|
| 無圧縮 | F32 | 32 | 完全な元データ。デバッグや特殊な用途以外では使いません。 |
| 標準 | F16 / BF16 | 16 | 量子化のマスターデータ用。VRAMが非常に豊富な環境向け。 |
| 高精度 | Q8_0 | ~8.5 | 実用上の最高峰。 ほぼ劣化がなく、8ビットで計算効率も良い。 |
| K-Quants | Q6_K | ~6.6 | 非常に高精度。Q8との差はほぼ体感不能。ファイルサイズを少し削れます。 |
| Q5_K_M | ~5.7 | 高精度モデルの推奨。 性能低下を抑えたい場合の第一選択肢。 | |
| Q5_K_S | ~5.5 | Q5_K_Mよりわずかに軽量。 | |
| Q4_K_M | ~4.8 | 【標準・推奨】 迷ったらこれ。知能とサイズのバランスが最高。 | |
| Q4_K_S | ~4.6 | Q4_K_Mよりわずかに軽量。速度を少しでも優先したい時。 | |
| Q3_K_L | ~3.8 | 3ビットクラスで精度を粘りたい時。 | |
| Q3_K_M | ~3.7 | 3ビットクラスのバランス型。 | |
| Q3_K_S | ~3.3 | メモリが極めて少ない環境用。 | |
| Q2_K | ~2.6 | 最小サイズ。知能の低下が激しいため、最終手段。 | |
| レガシー | Q4_0 / Q4_1 | 4.5 / 5.0 | 旧方式。現在のPC環境では、より賢い Q4_K_M の使用を強く推奨。 |
変換を実行すると、指定した量子化タイプで変換されたGGUFモデルが作成されます。この時点で量子化タイプに応じたファイルサイズになります。
2026/01/04 21:01 1,508,776,928 animaPencilXL_v500_unet-Q4_K_S.gguf下記は実行結果です。
(venv) I:\tools\ComfyUI-GGUF\tools\model-work>..\llama.cpp\build\bin\Debug\llama-quantize.exe .\animaPencilXL_v500_unet-F16.gguf .\animaPencilXL_v500_unet-Q4_K_S.gguf Q4_K_S
main: build = 3962 (c8c07d658)
main: built with MSVC 19.50.35721.0 for x64
main: quantizing '.\animaPencilXL_v500_unet-F16.gguf' to '.\animaPencilXL_v500_unet-Q4_K_S.gguf' as Q4_K_S
llama_model_loader: loaded meta data with 135 key-value pairs and 1680 tensors from .\animaPencilXL_v500_unet-F16.gguf (version GGUF V3 (latest))
llama_model_loader: Dumping metadata keys/values. Note: KV overrides do not apply in this output.
llama_model_loader: - kv 0: general.architecture str = sdxl
llama_model_loader: - kv 1: general.quantization_version u32 = 2
llama_model_loader: - kv 2: general.file_type u32 = 1
llama_model_loader: - kv 3: comfy.gguf.orig_shape.input_blocks.0.0.weight arr[i32,4] = [320, 4, 3, 3]
llama_model_loader: - kv 4: comfy.gguf.orig_shape.input_blocks.1.0.in_layers.2.weight arr[i32,4] = [320, 320, 3, 3]
llama_model_loader: - kv 5: comfy.gguf.orig_shape.input_blocks.1.0.out_layers.3.weight arr[i32,4] = [320, 320, 3, 3]
llama_model_loader: - kv 6: comfy.gguf.orig_shape.input_blocks.2.0.in_layers.2.weight arr[i32,4] = [320, 320, 3, 3]
:(省略)
[1679/1680] time_embed.2.bias - [ 1280, 1, 1, 1], type = f16, size = 0.002 MB
[1680/1680] time_embed.2.weight - [ 1280, 1280, 1, 1], type = f16, size = 3.125 MB
llama_model_quantize_internal: model size = 4897.05 MB
llama_model_quantize_internal: quant size = 1438.73 MB
main: quantize time = 369722.72 ms
main: total time = 369722.72 ms
(venv) I:\tools\ComfyUI-GGUF\tools\model-work>2-5. 変換後のモデルをComfyUIに実装(配置)
変換したモデルと、Checkpointから抽出された「Text-Encoder(CLIP)」、「VAE」を、ComfyUIのモデルフォルダに配置します。ここでは下記の通り配置しました。
※SDXLベースのモデルの場合だと、切り出されたText-EncoderやVAEは、SDXL標準のものがほとんどです。既に利用可能なモデルがあるなら場合は、改めて配置する必要はありません。
I:\ai-generator\ComfyUI\ComfyUI\models
├\unet
│└animaPencilXL_v500_unet-Q4_K_S.gguf
├\clip
│├animaPencilXL_v500_clipl.safetensors
│└animaPencilXL_v500_clipg.safetensors
├\vae
│└animaPencilXL_v500_vae.safetensors
:3. GGUFモデルを使った画像生成
GGUFに変換したモデルを使い、ComfyUIで画像生成を試します。
3-1. ComfyUI-GGUFのインストール
画像生成を試す前に、GGUFを利用するためのノード、「ComfyUI-GGUF」カスタムノードをインストールしておきます。インストールはマネージャー機能の「Custom Nodes Manager」からインストールします。手順は、「GGUF」を検索し、「ComfyUI-GGUF」にチェックを入れインストールするだけです。ComfyUIを再起動すると有効化されます。
また、ここまでの手順で同じものをクローンしていますが、カスタムノードとごっちゃにしたくなかった理由から、別扱いとしています。

8-2. Checkpoint を使った画像生成
まず比較の指標として、変換まえのCheckpoint形式のモデルで画像生成してみました。バッチ数を4とし、4回ほど実行した結果、1回あたりの生成時間は約24秒程でした。

生成された画像はこのような感じです。




ワークフローのJSONも載せておきます。
{
"id": "640c0627-17c2-4fc0-a842-d7a239ec18e4",
"revision": 0,
"last_node_id": 10,
"last_link_id": 13,
"nodes": [
{
"id": 4,
"type": "VAEDecode",
"pos": [
1423.144237375777,
351.1863984351665
],
"size": [
140,
46
],
"flags": {},
"order": 5,
"mode": 0,
"inputs": [
{
"name": "samples",
"type": "LATENT",
"link": 1
},
{
"name": "vae",
"type": "VAE",
"link": 12
}
],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": [
3
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.6.0",
"Node name for S&R": "VAEDecode"
},
"widgets_values": []
},
{
"id": 5,
"type": "SaveImage",
"pos": [
1625.6950668775016,
350.2577213196425
],
"size": [
605.0864012021036,
511.0428249436512
],
"flags": {},
"order": 6,
"mode": 0,
"inputs": [
{
"name": "images",
"type": "IMAGE",
"link": 3
}
],
"outputs": [],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.6.0",
"Node name for S&R": "SaveImage"
},
"widgets_values": [
"ComfyUI"
]
},
{
"id": 6,
"type": "CLIPTextEncode",
"pos": [
685.1329953158062,
690.9306206194436
],
"size": [
400,
200
],
"flags": {},
"order": 3,
"mode": 0,
"inputs": [
{
"name": "clip",
"type": "CLIP",
"link": 11
}
],
"outputs": [
{
"name": "CONDITIONING",
"type": "CONDITIONING",
"links": [
8
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.6.0",
"Node name for S&R": "CLIPTextEncode"
},
"widgets_values": [
"(worst quality, low quality, normal quality:1.4), lowres, (bad anatomy, bad hands:1.2), error, missing fingers, extra digit, fewer digits, cropped, jpeg artifacts, signature, watermark, username, blurry, (flat color, airbrushed, retouched, plastic skin:1.2), (large breasts, huge breasts, thick thighs, wide hips:1.3), (fancy dress, fur, jewelry, ornaments:1.3), (indoor, outdoor, furniture, bar, city, trees, street, building:1.4), (full body, feet, legs:1.2), 3d, render, doll, long neck, bad proportion\n"
]
},
{
"id": 8,
"type": "EmptyLatentImage",
"pos": [
814.2778624696863,
938.1377786004564
],
"size": [
270,
106
],
"flags": {},
"order": 0,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "LATENT",
"type": "LATENT",
"links": [
9
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.6.0",
"Node name for S&R": "EmptyLatentImage"
},
"widgets_values": [
1024,
1024,
4
]
},
{
"id": 9,
"type": "KSampler",
"pos": [
1104.9192261060537,
353.03986950954675
],
"size": [
270,
262
],
"flags": {},
"order": 4,
"mode": 0,
"inputs": [
{
"name": "model",
"type": "MODEL",
"link": 13
},
{
"name": "positive",
"type": "CONDITIONING",
"link": 7
},
{
"name": "negative",
"type": "CONDITIONING",
"link": 8
},
{
"name": "latent_image",
"type": "LATENT",
"link": 9
}
],
"outputs": [
{
"name": "LATENT",
"type": "LATENT",
"links": [
1
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.6.0",
"Node name for S&R": "KSampler"
},
"widgets_values": [
1039960531812470,
"randomize",
20,
7,
"euler",
"simple",
1
]
},
{
"id": 7,
"type": "CLIPTextEncodeSDXL",
"pos": [
686.2777258669978,
352.8293980253587
],
"size": [
400,
286
],
"flags": {},
"order": 2,
"mode": 0,
"inputs": [
{
"name": "clip",
"type": "CLIP",
"link": 10
}
],
"outputs": [
{
"name": "CONDITIONING",
"type": "CONDITIONING",
"links": [
7
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.6.0",
"Node name for S&R": "CLIPTextEncodeSDXL"
},
"widgets_values": [
1024,
1024,
0,
0,
1024,
1024,
"(upper body:1.3), (waist up:1.2), 1girl, young woman, slender body, black hair, bob hair, hair over one eye, black eyes, (mesmerizing detailed eyes:1.1), (defined iris:1.1), glassy eyes, sharp eyesight, eyelashes, (extremely detailed skin:1.1), (visible pores:1.1), skin texture, realistic skin, soft skin luster, villainess, smirk, closed mouth, masterpiece, best quality, high res, very aesthetic, (detailed face:1.4), evil smile, lush lips, cinematic composition, 8k, sharp focus, glossy texture, shadow gradation, visual harmony\nBREAK\ncasual clothes, oversized hoodie, denim shorts, sneakers, choker, earrings, looking away, beautiful face\nBREAK\nsimple background, white background, standalone, solo, high aesthetic sense, Hype4realistic\n",
"(upper body:1.3), (waist up:1.2), 1girl, young woman, slender body, black hair, bob hair, hair over one eye, black eyes, (mesmerizing detailed eyes:1.1), (defined iris:1.1), glassy eyes, sharp eyesight, eyelashes, (extremely detailed skin:1.1), (visible pores:1.1), skin texture, realistic skin, soft skin luster, villainess, smirk, closed mouth, masterpiece, best quality, high res, very aesthetic, (detailed face:1.4), evil smile, lush lips, cinematic composition, 8k, sharp focus, glossy texture, shadow gradation, visual harmony\nBREAK\ncasual clothes, oversized hoodie, denim shorts, sneakers, choker, earrings, looking away, beautiful face\nBREAK\nsimple background, white background, standalone, solo, high aesthetic sense, Hype4realistic\n"
]
},
{
"id": 10,
"type": "CheckpointLoaderSimple",
"pos": [
347.5825118341702,
198.68190762072524
],
"size": [
270,
98
],
"flags": {},
"order": 1,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "MODEL",
"type": "MODEL",
"links": [
13
]
},
{
"name": "CLIP",
"type": "CLIP",
"links": [
10,
11
]
},
{
"name": "VAE",
"type": "VAE",
"links": [
12
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.6.0",
"Node name for S&R": "CheckpointLoaderSimple"
},
"widgets_values": [
"SDXL\\2D\\animaPencilXL_v500.safetensors"
]
}
],
"links": [
[
1,
9,
0,
4,
0,
"LATENT"
],
[
3,
4,
0,
5,
0,
"IMAGE"
],
[
7,
7,
0,
9,
1,
"CONDITIONING"
],
[
8,
6,
0,
9,
2,
"CONDITIONING"
],
[
9,
8,
0,
9,
3,
"LATENT"
],
[
10,
10,
1,
7,
0,
"CLIP"
],
[
11,
10,
1,
6,
0,
"CLIP"
],
[
12,
10,
2,
4,
1,
"VAE"
],
[
13,
10,
0,
9,
0,
"MODEL"
]
],
"groups": [],
"config": {},
"extra": {
"ds": {
"scale": 0.7627768444385473,
"offset": [
-122.95317969369965,
84.86583909569725
]
},
"workflowRendererVersion": "LG",
"frontendVersion": "1.34.9"
},
"version": 0.4
}8-3. GGUF (Q4_K_S) を使った画像生成
続いて、GGUF(Q4_K_S)に変換したモデルで画像生成をしました。モデルをロードするノードは変えていますが、プロンプト及びその他はそのままにし、同様の条件で実行した結果、1回あたりの生成時間は約37秒程でした。
結果、生成速度が低下しましたが、原因をGeminiに聞いたところ、RTX50シリーズ等は、GGUF変換前の FP16/BF16 と、特に FP8 の演算に最適化されており、GGUF形式は直接扱えないようでした。このため、画像生成をするたび FP16 などへの展開処理(デクォンタイズ)が発生し、それがオーバーヘッドとなり生成速度の低下につながったようです。

生成された画像はこのような感じです。クオリティ的な違いは感じませんでした。




ワークフローのJSONも載せておきます。
{
"id": "95ad4895-64b2-42ef-9faa-82f4bf1a2376",
"revision": 0,
"last_node_id": 9,
"last_link_id": 9,
"nodes": [
{
"id": 8,
"type": "VAELoader",
"pos": [
1002.1032471812396,
87.29373328214672
],
"size": [
270,
58
],
"flags": {},
"order": 0,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "VAE",
"type": "VAE",
"links": [
8
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.6.0",
"Node name for S&R": "VAELoader"
},
"widgets_values": [
"animaPencilXL_v500_vae.safetensors"
]
},
{
"id": 1,
"type": "UnetLoaderGGUF",
"pos": [
705.6346114341623,
87.25881757093367
],
"size": [
270,
58
],
"flags": {},
"order": 1,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "MODEL",
"type": "MODEL",
"links": [
4
]
}
],
"properties": {
"cnr_id": "comfyui-gguf",
"ver": "1.1.9",
"Node name for S&R": "UnetLoaderGGUF"
},
"widgets_values": [
"animaPencilXL_v500_unet-Q4_K_S.gguf"
]
},
{
"id": 2,
"type": "DualCLIPLoader",
"pos": [
253.30720953431683,
87.7305349640841
],
"size": [
270,
130
],
"flags": {},
"order": 2,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "CLIP",
"type": "CLIP",
"links": [
1,
2
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.6.0",
"Node name for S&R": "DualCLIPLoader"
},
"widgets_values": [
"animaPencilXL_v500_clipl.safetensors",
"animaPencilXL_v500_clipg.safetensors",
"sdxl",
"default"
]
},
{
"id": 7,
"type": "VAEDecode",
"pos": [
1321.0786919596026,
240.85573328214656
],
"size": [
140,
46
],
"flags": {},
"order": 7,
"mode": 0,
"inputs": [
{
"name": "samples",
"type": "LATENT",
"link": 7
},
{
"name": "vae",
"type": "VAE",
"link": 8
}
],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": [
9
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.6.0",
"Node name for S&R": "VAEDecode"
},
"widgets_values": []
},
{
"id": 9,
"type": "SaveImage",
"pos": [
1523.6295214613272,
239.92705616662255
],
"size": [
605.0864012021036,
511.0428249436512
],
"flags": {},
"order": 8,
"mode": 0,
"inputs": [
{
"name": "images",
"type": "IMAGE",
"link": 9
}
],
"outputs": [],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.6.0",
"Node name for S&R": "SaveImage"
},
"widgets_values": [
"ComfyUI"
]
},
{
"id": 4,
"type": "CLIPTextEncode",
"pos": [
583.0674498996322,
580.5999554664236
],
"size": [
400,
200
],
"flags": {},
"order": 4,
"mode": 0,
"inputs": [
{
"name": "clip",
"type": "CLIP",
"link": 1
}
],
"outputs": [
{
"name": "CONDITIONING",
"type": "CONDITIONING",
"links": [
6
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.6.0",
"Node name for S&R": "CLIPTextEncode"
},
"widgets_values": [
"(worst quality, low quality, normal quality:1.4), lowres, (bad anatomy, bad hands:1.2), error, missing fingers, extra digit, fewer digits, cropped, jpeg artifacts, signature, watermark, username, blurry, (flat color, airbrushed, retouched, plastic skin:1.2), (large breasts, huge breasts, thick thighs, wide hips:1.3), (fancy dress, fur, jewelry, ornaments:1.3), (indoor, outdoor, furniture, bar, city, trees, street, building:1.4), (full body, feet, legs:1.2), 3d, render, doll, long neck, bad proportion\n"
]
},
{
"id": 3,
"type": "CLIPTextEncodeSDXL",
"pos": [
584.2121804508238,
242.49873287233876
],
"size": [
400,
286
],
"flags": {},
"order": 5,
"mode": 0,
"inputs": [
{
"name": "clip",
"type": "CLIP",
"link": 2
}
],
"outputs": [
{
"name": "CONDITIONING",
"type": "CONDITIONING",
"links": [
5
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.6.0",
"Node name for S&R": "CLIPTextEncodeSDXL"
},
"widgets_values": [
1024,
1024,
0,
0,
1024,
1024,
"(upper body:1.3), (waist up:1.2), 1girl, young woman, slender body, black hair, bob hair, hair over one eye, black eyes, (mesmerizing detailed eyes:1.1), (defined iris:1.1), glassy eyes, sharp eyesight, eyelashes, (extremely detailed skin:1.1), (visible pores:1.1), skin texture, realistic skin, soft skin luster, villainess, smirk, closed mouth, masterpiece, best quality, high res, very aesthetic, (detailed face:1.4), evil smile, lush lips, cinematic composition, 8k, sharp focus, glossy texture, shadow gradation, visual harmony\nBREAK\ncasual clothes, oversized hoodie, denim shorts, sneakers, choker, earrings, looking away, beautiful face\nBREAK\nsimple background, white background, standalone, solo, high aesthetic sense, Hype4realistic\n",
"(upper body:1.3), (waist up:1.2), 1girl, young woman, slender body, black hair, bob hair, hair over one eye, black eyes, (mesmerizing detailed eyes:1.1), (defined iris:1.1), glassy eyes, sharp eyesight, eyelashes, (extremely detailed skin:1.1), (visible pores:1.1), skin texture, realistic skin, soft skin luster, villainess, smirk, closed mouth, masterpiece, best quality, high res, very aesthetic, (detailed face:1.4), evil smile, lush lips, cinematic composition, 8k, sharp focus, glossy texture, shadow gradation, visual harmony\nBREAK\ncasual clothes, oversized hoodie, denim shorts, sneakers, choker, earrings, looking away, beautiful face\nBREAK\nsimple background, white background, standalone, solo, high aesthetic sense, Hype4realistic\n"
]
},
{
"id": 6,
"type": "EmptyLatentImage",
"pos": [
712.2123170535123,
827.8071134474363
],
"size": [
270,
106
],
"flags": {},
"order": 3,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "LATENT",
"type": "LATENT",
"links": [
3
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.6.0",
"Node name for S&R": "EmptyLatentImage"
},
"widgets_values": [
1024,
1024,
4
]
},
{
"id": 5,
"type": "KSampler",
"pos": [
1002.8536806898792,
242.70920435652684
],
"size": [
270,
262
],
"flags": {},
"order": 6,
"mode": 0,
"inputs": [
{
"name": "model",
"type": "MODEL",
"link": 4
},
{
"name": "positive",
"type": "CONDITIONING",
"link": 5
},
{
"name": "negative",
"type": "CONDITIONING",
"link": 6
},
{
"name": "latent_image",
"type": "LATENT",
"link": 3
}
],
"outputs": [
{
"name": "LATENT",
"type": "LATENT",
"links": [
7
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.6.0",
"Node name for S&R": "KSampler"
},
"widgets_values": [
89022167045847,
"randomize",
20,
7,
"euler",
"simple",
1
]
}
],
"links": [
[
1,
2,
0,
4,
0,
"CLIP"
],
[
2,
2,
0,
3,
0,
"CLIP"
],
[
3,
6,
0,
5,
3,
"LATENT"
],
[
4,
1,
0,
5,
0,
"MODEL"
],
[
5,
3,
0,
5,
1,
"CONDITIONING"
],
[
6,
4,
0,
5,
2,
"CONDITIONING"
],
[
7,
5,
0,
7,
0,
"LATENT"
],
[
8,
8,
0,
7,
1,
"VAE"
],
[
9,
7,
0,
9,
0,
"IMAGE"
]
],
"groups": [],
"config": {},
"extra": {
"ds": {
"scale": 0.7627768444385473,
"offset": [
-71.83175082380022,
160.83884194224876
]
},
"workflowRendererVersion": "LG",
"frontendVersion": "1.34.9"
},
"version": 0.4
}さいごに
というわけで、今回はGGUFへの変換方法をまとめてみました。
冒頭でも触れましたが、改めて結論を述べると、「VRAMに収まるサイズのモデルであれば、GGUF変換は不要」です。個人的には期待外れな結果となりましたが、SD3.5やFLUX.1といったVRAM消費の激しいモデルを扱う際や、高解像度のアップスケールを行う際には、有効な選択肢となりえますので、そんな場面で活用していきたいなと思います。
GGUF変換手順の概要
記事全体が長くなったので、実施手順を概要ベースでまとめておきます。
- GGUF変換環境の準備
- Visual Studio
- cmake
- Git
- Python
- Comfyui-GGUF (+ llama.cpp)
- モデルの入手(Checkpoint)
- モデルから「U-Net」部分を抽出
→U-Net以外が含まれているとGGUF変換が失敗する可能性があるため - 抽出したモデルをGGUF(F16)に変換
→ここで Safetensors から GGUF にフォーマットが変換される - GGUF(F16)をGGUF(Q4_K_Sなど)に変換
→ここで低ビットのk-quants形式に変換される - GGUF変換したモデルをComfyUIに実装(unetフォルダに配置)
- 変換したモデルを使い画像生成
ComfyUI-ModelQuantizer について
今回の方法以外にも、「ComfyUI-ModelQuantizer」というカスタムノードでも、GGUFへの変換ができるようです。
ただ、GGUFへの変換部分は ComfyUI-GGUI をラップしただけのようで、今回同様にツール類のセットアップが必要そうでした。とはいえ、Comfy-UI上で変換することができるようなので、コマンドを叩くよりは簡単に変換できそうです。



コメント