FLUX.2 klein 4B on the Snapdragon NPU (SM8450)
FLUX.2 klein 4B reference-picture editing, compiled for the Hexagon NPU of the Snapdragon 8 Gen 1 (SM8450, Hexagon v69). One picture in, one instruction, one edited picture out: a turned view, a new pose, a change of clothes, a new place. Since 2026-12-01 also text-to-image: a second set of the transformer graphs, compiled without the reference picture, draws a new picture from words alone.
Use it in AutoDroid Studio: the app downloads these files and runs them on the phone. In the avatar preset, choosing FLUX.2 klein 4B under Settings → Drawing → Image model draws the character's looks, outfits and poses with this model.
Speed and quality (Galaxy S22 Ultra, SM8450)
| Stage | Where | Time |
|---|---|---|
| Qwen3-4B text encoder (+ loading) | GPU (OpenCL, llama-style GGUF via a patched stable-diffusion.cpp) | ~17 s |
| Reference picture → latents (VAE encoder) | NPU | 0.2 s |
| 4 denoising steps (30 transformer graphs) | NPU | ~61 s |
| Latents → picture (VAE decoder) | NPU | 0.5 s |
| Whole edit, 512 × 512 | ~81 s | |
Text-to-image: 4 denoising steps (npu_t2i/, no reference picture) | NPU | 36-46 s |
| Whole text-to-image picture, 512 × 512 | 75-86 s |
For comparison, the same edit takes about 17 minutes with stable-diffusion.cpp on the phone's GPU and 31 minutes on its CPU.
Against the float model (PyTorch, diffusers) on the same inputs: the denoiser's noise predictions keep a cosine of 0.98 → 0.945 over the 4 steps and the final picture is visually the same (PSNR 23.5 dB, mean difference 7/255); the VAE decoder matches at PSNR 53.9 dB and the encoder's latents at cosine 0.9998. Text-to-image against the float model with the same prompt and noise: PSNR 18.5-21.8 dB, the same picture to the eye.
Files
| Path | What |
|---|---|
klein.json | Manifest: every file with its size and SHA-256, the target chip and the fixed shapes |
npu/dbla0-4.bin, npu/dblf0-4.bin | The 5 double-stream blocks, each as an attention half and a feed-forward half |
npu/sgl0-19.bin | The 20 single-stream blocks |
npu/vaeenc.bin, npu/vaedec.bin | VAE encoder and decoder, BatchNorm and the 2×2 patching folded in |
npu_t2i/*.bin | The same 30 transformer graphs for text-to-image: 512 text + 1024 picture tokens, no reference tokens |
data/*.raw | Float32 tables the CPU side uses: picture and text embedders, final projection, the 4 steps' modulation and sigmas |
te/Qwen3-4B-Q4_0.gguf | The text encoder (from unsloth/Qwen3-4B-GGUF) |
te/flux2_vae_klein.safetensors | The FLUX.2 VAE as a single file (loaded by the text-encoder step, not used for encoding) |
te/flux-2-klein-4b-Q4_0.gguf.head | Only the header of leejet/FLUX.2-klein-4B-GGUF's Q4_0 file: the text-encoder step reads it to recognise the model family; the weights it would point at are never read, so the app extends it to its original length as a sparse file |
About 9.8 GB in all (3.6 GB of it the text-to-image graphs).
How it was made
- Every block was rewritten for the HTP (hidden states as
[1, C, 1, tokens], linear layers as 1×1 convolutions, rotary pairs permuted into the q/k weights), checked against the diffusers block, exported to ONNX and compiled with QAIRT 2.32 as w8a16 context binaries for v69 with 8 MB of VTCM, calibrated on the real inputs of two float edits (the text-to-image set on three float text-to-image runs; its step schedule and modulation tables are the edit's, sodata/serves both). - The residual stream stays on the CPU in float32: a few text tokens carry hidden values above 50,000 that no 16-bit tensor encoding can hold beside the rest. The CPU does each block's LayerNorm and modulation and adds the block's update; the NPU graphs return the gated updates.
- On v69 the second operand of
softmax(qkᵀ)·vis converted to 8 bits. A few prompt-dependent text tokens have |v| near 90 against ~0.5 elsewhere, which zeroed most of v; each graph splits v into a clipped part and the rest, each with its own 8-bit scale. - One process can hold only about four of these graphs on this chip, and freeing a context restarts the DSP, so each step runs as a chain of short-lived worker processes, the next one loading while the current one computes.
Limits
- 512 × 512 output, one reference picture (or none, with
npu_t2i/), 4 steps. Positions, modulation tables and graph shapes are fixed at compile time. - Built and tested on the Snapdragon 8 Gen 1 (SM8450). The graphs need 8 MB of VTCM, so the Snapdragon 888 and older cannot load them. Newer chips should load v69 binaries but are untested.
- These are QNN context binaries plus raw tables, not a general-purpose checkpoint: they need the runner in AutoDroid Studio (the CPU side, the worker chain and the text-encoder step).
- Picture quality follows FLUX.2 klein 4B at 4 steps; poses are described in words (no pose skeletons).
Licences
- FLUX.2 klein 4B and its VAE: Apache-2.0, © Black Forest Labs.
- Qwen3-4B: Apache-2.0, © Alibaba Cloud (GGUF conversion by Unsloth).
- These compiled files are released under Apache-2.0 (see
LICENSE).