ggk
One package for working with GGUF models locally: an OpenAI-compatible LLM server, a diffusion image/video/audio generator and a GGUF metadata/tensor editor with a built-in quantizer — three panels on one GUI, powered by one unified engine compiled in a single build on top of gk, an independent tensor library. There is no ggml anywhere in the tree.
Install
pip install ggk
The build compiles the bundled engine (CPU by default, Metal on macOS). GPU backends are opt-in at install time:
GGK_CUDA=1 pip install ggk # NVIDIA
GGK_HIP=1 pip install ggk # AMD ROCm
GGK_VULKAN=1 pip install ggk # Vulkan
Each switch drives the whole engine — the server, the diffusion runtime and the multimodal projectors all evaluate their graphs on the one gk build.
Building a wheel
On Windows (CUDA) use the script; it is the whole recipe in one place:
build-wheel.bat :: CUDA wheel -> dist\, log -> build-wheel-<timestamp>.log
build-wheel.bat mytag sdist :: named log, plus the sdist
build-wheel.bat check :: preflight only
It runs from a vcvars64 shell with Ninja, builds with --wheel so the
CMake tree stays at build/{wheel_tag} and reruns are incremental, redirects
TEMP/TMP into .buildtmp\ inside the tree, checks the toolchain, free
disk, macOS ._* sidecars and a stale generator cache before starting, and
retries once (incrementally) if the first pass fails. GGK_CUDA=0 turns CUDA
off, CMAKE_ARGS passes extra defines, GGK_BUILD_NO_ISOLATION=1 passes -n
to build (needs pip install scikit-build-core ninja) so a build never
waits on PyPI.
Elsewhere, or by hand:
python -m build --wheel
Why the temp redirect, and why --wheel is not optional for a GPU build:
plain python -m build builds an sdist first and compiles the wheel from
it, unpacked into the OS temp directory; scikit-build-core also stages the
wheel tree there, and nvcc keeps its intermediates there. scikit-build-core
stamps every sdist member with a fixed 2022 date for reproducibility, so to
Windows' daily idle-time temp cleanup (Storage Sense "temporary files", the
DiskCleanup\SilentCleanup task — "delete files older than 7 days") the
unpacked sources are four years old, and an unattended multi-hour CUDA build
is exactly when the machine counts as idle. The sweep lands as missing source
files mid-compile, or at the very end as
FileNotFoundError: ...\wheel\scripts from the packaging step. Nothing in
the tree is at fault, and the retry succeeds because the sweep runs once a day.
With --wheel the build directory is in the tree; with TEMP in the tree
nothing the build owns is in the swept directory at all.
Use Ninja rather than -G "Visual Studio 17 2022": scikit-build-core passes
no -j on the pyproject path and CMake's Visual Studio generator does not set
/MP, so an MSBuild-driven build compiles one file at a time. nvcc needs MSVC
as its host compiler on Windows, hence the vcvars64 shell.
The build works its own architecture list out from nvcc and the installed
GPUs. A wheel built on one machine for another should say what it targets:
-DGK_CUDA_ARCHITECTURES="75;86;89;120".
Run
ggk # unified GUI — Server / Diffuser / Editor panels
python -m ggk # same thing
Each panel also runs on its own, exactly like the standalone gguf-server / gguf-diffusion / gguf-editor packages did:
ggk server # LLM server GUI
ggk diffuser # image generation GUI
ggk editor # GGUF editor GUI
And the engines are directly scriptable from the CLI:
ggk server engine -- --model model.gguf --port 8888
ggk diffuser engine -- -m sd.gguf -p "a lighthouse at dusk" -o out.png
ggk editor quantize -m in.gguf -o out-q4_k.gguf --type q4_k
ggk editor devices
Any other leading option is a diffusion engine command line as is:
ggk --diffusion-model flux3-image-klein-nvfp4.gguf --vae pig_flux2_vae_fp32-f16.gguf \
--llm qwen3vl-4b-it-q4_k_m.gguf -r sheep.png -p "a sheep in sunglasses" \
--cfg-scale 1 --steps 4 --sampling-method euler --diffusion-fa -o out.png
FLUX.3 prompt upsampler
FLUX.3 Image Klein is trained on the captions its prompt upsampler writes (a
Qwen3.5-9B VLM); the text encoder is Qwen3-VL-4B. The upsampler runs on the
bundled LLM server engine before the diffusion engine starts, with Black Forest
Labs' external-VLM system prompts (src/ggk/diffuser/pup_prompts_external_vlm.json):
ggk --diffusion-model flux3-image-klein-nvfp4.gguf --vae pig_flux2_vae_fp32-f16.gguf \
--llm qwen3vl-4b-it-q4_k_m.gguf --prompt-upsampler qwen3.5-9b-q4_k_m.gguf \
-r sheep.png -p "a sheep in sunglasses" --cfg-scale 1 --steps 4 -o out.png
--llm qwen3.5-9b-q4_k_m.gguf on a FLUX.3 run means the same (the Qwen3-VL-4B
GGUF next to the diffusion model is used as the text encoder). Reference images
go to the upsampler through its mmproj-*.gguf, found by name next to the model
or given with --prompt-upsampler-vision. --prompt-upsampler-out caption.txt
keeps the caption, --no-prompt-upsampler sends the prompt as typed, and
python -m ggk.diffuser.pup --model qwen3.5-9b-q4_k_m.gguf -p "..." upsamples alone.
A gguf_trainer qwen35_bridge adapter replaces the 9B upsampler with the
pig_clip student (the mmproj stays Qwen3.5's): the pair goes in the same slots
and conditions the DiT directly through the adapter's FLUX.3 bank head, so no
caption is written and the Qwen3-VL-4B --llm is not loaded. An adapter
trained with klein_target = prompt (gguf_trainer 0.0.14+) carries a
token-aligned bank: the engine rebuilds FLUX.3's template over the student's
own tokens, hands each bank row the student state of its token, and passes
the real rows padded to the next multiple of 80 to the DiT (ggk 0.9.4+ —
an older engine ignores the alignment and renders noise). An adapter trained
on the upsampler caption (0.0.13) follows the prompt only loosely and the
engine warns about it:
ggk --diffusion-model flux3-image-klein-nvfp4.gguf --vae pig_flux2_vae_fp32-f16.gguf \
--llm qwen3vl-4b-it-q4_k_m.gguf --prompt-upsampler pig_clip-f16.gguf \
--prompt-upsampler-adapter pig_qwen3.5_9b_adapter-f16.gguf \
--prompt-upsampler-vision mmproj-qwen3.5-9b-f16.gguf \
-r sheep.png -p "a sheep in sunglasses" --cfg-scale 1 --steps 4 -o out.png
A gguf_trainer qwen3vl_flux3 adapter replaces the Qwen3-VL-4B text
encoder instead (ggk 0.9.5+): --llm pig_clip-*.gguf --llm-adapter pig_qwen3vl_4b_it_adapter-f16.gguf. The student runs FLUX.3's template with
the pads at rope position 1 exactly like the 4B, and the adapter emits the
8-layer stack (layers 4..32) per row; the prompt upsampler stays an
independent front end, so --prompt-upsampler qwen3.5-9b-q4_k_m.gguf [--prompt-upsampler-vision mmproj-qwen3.5-9b-f16.gguf] combines with it:
ggk --diffusion-model flux3-image-klein-nvfp4.gguf --vae pig_flux2_vae_fp32-f16.gguf \
--llm pig_clip-f16.gguf --llm-adapter pig_qwen3vl_4b_it_adapter-f16.gguf \
--prompt-upsampler qwen3.5-9b-q4_k_m.gguf --prompt-upsampler-vision mmproj-qwen3.5-9b-f16.gguf \
-r sheep.png -p "a sheep in sunglasses" --cfg-scale 1 --steps 4 -o out.png
MOSS-Image (Base / SFT)
MOSS-Image is a 5B single-stream DiT on the FLUX.2 VAE whose text encoder is
Qwen3.5-9B itself (last hidden state, chat template with an open <think>
block). Pass the stock llama.cpp Qwen3.5 GGUF as --llm; its 248k-token
tokenizer is read from the GGUF's metadata, no tokenizer file needed. The
upstream schedule is a flow shift of 5 (--flow-shift overrides), 1024 px is
native and dimensions must be multiples of 16; a CFG run skips DiT layer 22 on
the negative branch like the reference pipeline.
ggk --diffusion-model moss-image-sft-q4_k_s.gguf --vae pig_flux2_vae_fp32-f16.gguf \
--llm qwen3.5-9b-q4_k_m.gguf -p "a lovely cat holding a sign that says moss" \
--cfg-scale 3 --steps 30 -o out.png
The DiT has no reference-latent path. With --llm_vision mmproj-qwen3.5-9b-f16.gguf
a -r reference image goes through Qwen3.5's vision tower into the user turn
(before the prompt, with Qwen3-VL M-RoPE positions), so the text features are
image-conditioned; it never enters the VAE or the DiT:
ggk --diffusion-model moss-image-sft-q4_k_s.gguf --vae pig_flux2_vae_fp32-f16.gguf \
--llm qwen3.5-9b-q4_k_m.gguf --llm_vision mmproj-qwen3.5-9b-f16.gguf \
-r sheep.png -p "a sheep in sunglasses" --cfg-scale 1 --steps 4 --diffusion-fa -o out.png
The same gguf_trainer qwen35_bridge adapter (pack "MOSS-Image + FLUX.3
Klein") stands in for the 9B text encoder: --llm pig_clip-*.gguf --llm-adapter pig_qwen3.5_9b_adapter-f16.gguf, with the stock --llm_vision mmproj-qwen3.5-9b-f16.gguf for references. The adapter GGUF carries the Qwen3.5
vocabulary, so no Qwen3.5 GGUF is needed at all:
ggk --diffusion-model moss-image-sft-nvfp4.gguf --vae pig_flux2_vae_fp32-f16.gguf \
--llm pig_clip-f16.gguf --llm-adapter pig_qwen3.5_9b_adapter-f16.gguf \
--llm_vision mmproj-qwen3.5-9b-f16.gguf --ref-image sheep.png \
-p "a sheep in sunglasses" --sampling-method euler --diffusion-fa -o out.png
Reference images are resized (Qwen3-VL smart_resize, multiples of 32) to at most 1024x1024 pixels, i.e. 1024 vision tokens.
Fibo 2.0 Dev / Edit Turbo
Fibo 2.0 (briaai) is a Lumina-style 8B DiT on the FLUX.2 VAE whose text
encoder is Qwen3-VL-4B: fifteen hidden layers ({5,7,...,35}) are RMS-normalized
per token and gathered into six 7680-wide bundles, one for the DiT's text
Perceiver and one per injection block. Prompts are plain text or Bria's
structured JSON caption; an empty negative is the null caption the model was
trained with. The schedule is FLUX-style (dynamic shift from the token count,
--flow-shift and --scheduler discrete give ComfyUI's fixed 1.15 instead).
Dimensions are multiples of 16. Edit Turbo is distilled for 4 steps at CFG 1:
ggk --diffusion-model fibo2-edit-turbo-q3_k_m.gguf --vae pig_flux2_vae_fp32-f16.gguf \
--llm qwen3vl-4b-it-q4_k_m.gguf --llm_vision mmproj-qwen3vl-4b-it-f16.gguf \
--ref-image sheep.png -p "a sheep in sunglasses" --cfg-scale 1 --steps 4 \
--sampling-method euler --diffusion-fa -o out.png
A reference image goes both ways: through the VAE to the DiT as reference
tokens (fibo2 preset: a single reference is scaled to cover the output and
center cropped, several each to their ~1 MP bucket) and, as the same crop, into
Qwen3-VL's prompt through the vision tower (--llm_vision is required for
editing; the mmproj's deepstack mergers and M-RoPE image positions are used,
like the reference). With several references the instruction can say
<image_1>, <image_2>. Dev does text-to-image as well (--cfg-scale 5 --steps 20, no reference).
--llm pig_clip-*.gguf --llm-adapter <adapter>.gguf needs an adapter trained
for this family: a 15-tap layerwise vision-ext Qwen3-VL-4B adapter. A
final-norm adapter such as the Mage-Flow pig_qwen3vl_4b_adapter cannot supply
the fifteen intermediate layers and is refused with that message;
SD_FIBO2_TILE_ADAPTER=1 tiles its single output into every slot regardless
(out of distribution, for experiments only).
Qwen3-TTS (text to speech)
Qwen3-TTS-12Hz (0.6B / 1.7B, Base and CustomVoice) in the GGUF layout of
qwen3-tts.cpp's converters: the talker GGUF (convert_tts_to_gguf.py:
28-layer Qwen3 talker, 5-layer code predictor, the Qwen2 text tokenizer
and the speaker map in its metadata) is the model, the tokenizer GGUF
(convert_tokenizer_to_gguf.py) is the 12 Hz speech codec whose decoder
turns the 16-codebook frames into 24 kHz audio. -t <text> is accepted
as in that CLI (the engine's -t <threads> still works with a number);
-p / --text say the same:
ggk qwen3-tts-0.6b-base-q8_0.gguf --codec-model qwen-tokenizer-12hz-q8_0.gguf \
-t "Welcome to GGUF! The selected TTS model is now running." -o out.wav
The output container follows the extension of -o: out.wav is 16-bit PCM,
out.mp3 is MP3 (the engine's own MPEG Layer III encoder, no ffmpeg or lame
involved; constant bitrate, 64 kbps for 24 kHz mono speech and 256 kbps for
44.1/48 kHz stereo music unless --mp3-bitrate <kbps> says otherwise). This
holds for every audio model (Qwen3-TTS, ACE-Step, YuE2, MiniMax Music).
--speaker picks a CustomVoice model's named voice (the load log lists them;
the first one is used when none is given), --language fixes the language
(auto by default), --audio-duration caps the length (60 s by default; the
model stops at its end-of-speech token long before that for a sentence). The
sampling defaults are the model's own (generation.*: temperature 0.9, top-k
50, top-p 1.0, repetition penalty 1.05, seeded like qwen3-tts.cpp), overridable
with SD_QWEN3_TTS_{TEMPERATURE,TOP_K,TOP_P,REP_PENALTY}.
Voice cloning works with the Base talkers, which carry the ECAPA speaker
encoder (spk_enc.*; CustomVoice fine-tunes without it are refused with that
message). --reference voice.wav (or -r voice.wav, as in qwen3-tts.cpp;
PCM WAV at any rate, resampled to 24 kHz) conditions the talker on the
recording's speaker embedding. Adding --reference-text "what the recording says" runs the full in-context clone: the codec GGUF's encoder (tok_enc.*)
tokenizes the recording, the prompt carries its transcript and speech codes
ahead of the target text, and the vocoder is seeded with the last 2 s of the
reference (SD_QWEN3_TTS_VOCODER_CONTEXT_SEC) so the output starts in the
cloned voice:
ggk -m qwen3-tts-0.6b-base-q8_0.gguf --codec-model qwen-tokenizer-12hz-q8_0.gguf \
-r voice.wav --reference-text "Hello from the cloned voice, this is a test." \
-t "The quick brown fox jumps over the lazy dog." -o cloned.wav
The voice can be saved once and reused, in qwen3-tts.cpp's file formats:
--extract-speaker-embedding voice.json (or .bin, raw f32) writes the
recording's speaker embedding and exits; --extract-icl-prompt voice_icl.json
(with --reference-text) writes the full in-context prompt (embedding,
reference codes, transcript tokens). Later runs take --speaker-embedding voice.json or --icl-prompt voice_icl.json instead of the recording;
--dump-speaker-embedding file saves the embedding while synthesizing. The
pieces can also come separately: --reference-text-file transcript.txt,
--reference-codes codes.json (qwen3-tts.cpp's --dump-generated-codes
JSON, an ICL prompt's reference_codes, or a plain int list; skips the codec
encoder) and --reference-token-ids ids.txt (the tokenized transcript).
Reference codes need the transcript and a voice (-r, --speaker-embedding
or --speaker). --dump-generated-codes gen.json writes a run's speech codes
in that same JSON (--dump-decoder-codes adds the reference context frames
the vocoder was seeded with), so a generated voice can serve as the next
reference.
VoiceDesign talkers describe the voice in words: --instruction "a warm, low female voice, speaking slowly" (also --instruct) is prepended to the prompt
as a user turn, like qwen3-tts.cpp. Base models are not trained for it and
get a warning; the 1.7B CustomVoice accepts it alongside --speaker:
ggk -m qwen3-tts-1.7b-voicedesign-q8_0.gguf --codec-model qwen-tokenizer-12hz-q8_0.gguf \
--instruction "A warm, low female voice, speaking slowly." -t "Hello, this is a voice design test." -o designed.wav
The Cantonese TTS talkers (GGUF metadata under cantonese.* instead of
qwen3-tts.*) run on the same path and are named Cantonese in the log.
They are trained for both VoiceDesign and CustomVoice, so --instruction
applies without the Base-model warning:
ggk -m cantonese-1.2-0.6b-q8_0.gguf --codec-model tts-tokenizer-12hz-q8_0.gguf \
--instruction "A warm, low female voice, speaking slowly." -t "今日天氣好好,我哋出去行下街啦。" -o out.mp3
--stream decodes the speech in chunks while the talker is still generating
and appends each chunk to the output .wav as it lands (the header is kept
valid, so a player can follow the file); with -o out.mp3 the chunks land as
MP3 frames instead. --stream-chunk-sec sets the chunk
length (1.0 s) and --stream-left-context-sec how much earlier speech is
re-decoded ahead of each chunk and dropped again for continuity (2.0 s, as in
qwen3-tts.cpp). The codec attends over 72 frames, so a context of 6 s makes
the streamed audio identical to the one-shot decode, at about seven times the
decode work per chunk; 2 s keeps the chunks cheap with small differences at
chunk starts. Library users get the chunks through
sd_vid_gen_params_t.stream_audio_cb.
Integer weight types (i8 / i16 / i32 / i64)
The plain integer tensor types carry no scale of their own, so a weight cast
straight to i8 would be all zeros. When the quantizer converts a tensor to an
integer type (--type i8, or a rule like embed_tokens.weight=i8) it stores a
symmetric per-row scale in the file's metadata,
int_scale.<tensor name> = [f32; rows] # value = int * scale[row]
and the diffusion engine folds the scale back in at load time (i8 computes as q8_0, i16 as f16, i32/i64 as f32 on every backend). The LLM server does the same conversion while it loads (which turns mmap off for that model, since the converted weights need their own buffers). Converting the tensor to any other type drops the key again. An integer tensor without the key is what it always was in GGUF: raw integers (token tables, indices).
The editor marks such tensors with a ×scale badge, and every tensor row has
a Values button that decodes a slice of one row through the quantizer
library (scales applied, with a "raw integers" toggle for scaled weights).
Renaming, deleting or merging a scaled tensor keeps its int_scale.* entry in
step on save.
Which hardware it picked
Every engine prints the device list to stderr before it does anything else:
gk: found 2 devices
CUDA0: NVIDIA GeForce RTX 4050 Laptop GPU, 6140 MiB | compute capability = 8.9 | SMs = 20 | shared memory = 99 KiB | built for = 89
CPU: gk CPU backend, 32014 MiB | SIMD = AVX2 | AVX2 = 1 | FMA = 1 | F16C = 1 | F16_VEC = 1
If a GPU you expected is missing, the install was a CPU-only one (the GPU
switches above are opt-in at install time) or its driver was not found — either
way the run works, on the CPU, at CPU speed, which is otherwise indistinguishable
from a slow GPU. GK_QUIET=1 suppresses the banner.
Layout
vendor/engine/ the unified ggk engine (one CMake build)
gk/ the gk compute kernels (CPU + optional GPU backends)
gk/compat/ the historical ggml C API, implemented on gk
src/ common/ mtmd/ GGUF LLM runtime
app/ the gguf-server HTTP server
diffusion/ diffusion runtime + CLI
quantizer/ quantizer shared library (its own quant kernels)
src/ggk/ the Python package
server/ diffuser/ editor/ the three panels (backend + web frontend each)
gui.py static/ the unified 3-panel GUI shell
Nothing above gk/compat/ knows gk exists: the runtimes include the same
ggml.h / ggml-backend.h / gguf.h headers and call the same functions
they always did, while graph building, allocation, scheduling and the kernels
themselves are gk's. See vendor/engine/README.md for the engine's own build
options.
The editor's quantizer stays independent — its qz_* codec is compiled both
into the quantizer library the editor drives and into gk itself, so the
encoder and the runtimes' decoder can never disagree about a GGUF block.
Metadata
Release files for ggk 1.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ggk-1.0.4.tar.gz | 36.5 MB | Without provenance | Details for ggk-1.0.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ggk-1.0.4-py3-none-win_amd64.whl | Python 3 | none | Windows x86-64 | Details for ggk-1.0.4-py3-none-win_amd64.whl |
Total release size: 103.7 MB
Release files / ggk-1.0.4.tar.gz
| Download URL | ggk-1.0.4.tar.gz |
|---|---|
| Size | 36.5 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8c521fb347602f8cb282a02100fc5ab7f969bcc7c6a1ba9ac0abb598ecda2d1b
|
|
BLAKE2b-256 checksum How to use checksums |
4595f0f7159d8c04c0a3ebff01711741500aac6ebbea5f7f8cb2ce04749b4683
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.9
|
Release files / ggk-1.0.4-py3-none-win_amd64.whl
| Download URL | ggk-1.0.4-py3-none-win_amd64.whl |
|---|---|
| Size | 67.2 MB |
| Tags | Python 3 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
341bcff28a1882012ecaa8451c171229c8261fd4ec2197b1780ac815786de995
|
|
BLAKE2b-256 checksum How to use checksums |
0008cc78456c8a5adf727b93d1a5401299ea50cccfae4eafe88a0465ef330575
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.9
|
Security for ggk 1.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.