FLUX.2 Klein 4B — browser weights

The weights behind radames/flux-klein-web, a demo that runs the full FLUX.2 Klein 4B pipeline inside a browser tab: the transformer in hand-written WGSL (WebGPU), the distilled text encoder and BFL's distilled VAE through onnxruntime-web. The page streams these files straight into the browser and keeps them in the origin private file system, so a second visit starts in seconds.

This repo holds weights only. The engine is the flux-klein.js npm package (the WGSL transformer, the ONNX text encoder and VAE, the OPFS cache); the demo page lives in the Space. The package fetches from this repo by default:

import { createFluxKlein } from "flux-klein.js";
const klein = await createFluxKlein(); // base: https://huggingface.co/radames/flux2-klein-edge-web/resolve/main
const { rgba, width, height } = await klein.generate({ prompt: "a red bicycle", width: 256, height: 256 });

Layout

path what size
web_weights/ int8 transformer, 9 shards + manifest.json: q [N, K] int8 with f32 per-row scales. The desktop build keeps it resident on the GPU. 3.8 GB
web_weights_mobile/ int4 (group 64, asymmetric) block matmuls + the same small tensors, 6 shards. Streamed through a small GPU ring; the phone build. 2.3 GB
web_weights_lora_2step/ the 2-step distillation LoRA as a separate rank-64 int8 set, applied at run time on either transformer set 96 MB
te_onnx/ distilled 0.6B text encoder, ONNX with MatMulNBits q8 (desktop) 0.96 GB
te_onnx_slim/ the same graph minus its embedding table, plus embed_tokens.f16.bin looked up client-side (mobile) 0.66 GB
vae_onnx/ FLUX.2 small decoder as fixed-shape graphs r128 / r256 / r320 (tiles), reference encoders enc128 / enc256 / enc512, bn_stats.json. model.ort where present is the ORT-format twin of model.onnx + .data. 1.2 GB
tokenizer/ Qwen3 tokenizer; the chat template is applied client-side 15 MB

Every web_weights*/ set is one manifest.json describing tensors as byte ranges into w0.bin … w<n-1>.bin (raw little-endian bytes, 16-byte aligned). Loaders validate each shard's length against the manifest and each cached file against the Hub's ETag, so a re-upload here invalidates browser caches on its own.

What a page downloads on first run: desktop ≈ 5 GB (web_weights, te_onnx, vae_onnx); phone ≈ 3.2 GB (web_weights_mobile, te_onnx_slim, vae_onnx); 2 steps add the LoRA.

Provenance

Quantized from black-forest-labs/FLUX.2-klein-4B. int8 is per-row absmax; int4 is asymmetric group-wise along K. End-to-end parity against the f32-dequantized reference is rel-L2 ≈ 1e-2 (bf16-scale rounding noise).

The weights are released under the FLUX.2 Klein license linked above; using them means accepting it.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for radames/flux2-klein-edge-web

Quantized
(39)
this model