flux2-klein-4b-webgpu-lowbit / flux2-config.json
ryanhlewis's picture
Upload FLUX.2 WebGPU low-bit bundle
ab4310c verified
Raw
History Blame Contribute Delete
17.8 kB
{
"model_name": "flux.2-klein-4b",
"model_variant": "klein-4b-distilled-onnx-webgpu-q4",
"runtime": "onnxruntime-webgpu",
"ort_python_version": "1.25.1",
"num_steps": 4,
"guidance": 1.0,
"context_clip": 0,
"text_seq_len": 512,
"context_dim": 7680,
"latent_channels": 128,
"latent_downsample": 16,
"default_width": 256,
"default_height": 256,
"target_shard_bytes": 2147483648,
"tokenizer_dir": "tokenizer",
"tokenizer_source_model": "black-forest-labs/FLUX.2-klein-4B",
"tokenizer_source_subfolder": "tokenizer",
"models": {
"text_encoder": {
"file": "flux2-klein-4b-text-encoder-q4.onnx",
"manifest": "text-encoder-q4-manifest.json",
"dtype": "float16-activations-int4-weights",
"source_model": "black-forest-labs/FLUX.2-klein-4B",
"source_subfolder": "text_encoder",
"inputs": [
"input_ids",
"attention_mask"
],
"outputs": [
"ctx"
],
"execution_provider": "webgpu",
"quantization": {
"format": "MatMulNBits",
"bits": 4,
"block_size": 16,
"is_symmetric": false,
"op_types_to_quantize": [
"MatMul"
],
"matmul_nbits_nodes": 189,
"remaining_matmul_nodes": 55,
"flattened_matmul_nbits_inputs": 189,
"flattened_matmul_nbits_zero_points": 189,
"accuracy_level": 0,
"streaming_source": true
},
"shards": {
"count": 2,
"total_bytes": 2566461440,
"largest_bytes": 2136381440
}
},
"transformer": {
"file": "flux2-klein-4b-transformer-q4.onnx",
"manifest": "transformer-q4-manifest.json",
"dtype": "float16-activations-selective-fp32-int4-weights",
"activation_dtype": "float16-selective-fp32",
"inputs": [
"x",
"x_ids",
"timesteps",
"ctx",
"ctx_ids"
],
"outputs": [
"pred"
],
"execution_provider": "webgpu",
"quantization": {
"format": "MatMulNBits",
"algorithm": "ORT",
"bits": 4,
"block_size": 16,
"is_symmetric": false,
"op_types_to_quantize": [
"MatMul"
],
"matmul_nbits_nodes": 89,
"remaining_matmul_nodes": 100,
"flattened_matmul_nbits_inputs": 89,
"flattened_matmul_nbits_zero_points": 89,
"rope_fp32_rewrites": {
"position_id_inputs": 0,
"position_id_casts": 0,
"rope_frequency_constants": 0
},
"accuracy_level": 4,
"streaming_source": true
},
"attention_scale_fix": {
"type": "fixed_split_scale",
"head_dim": 128,
"scale_name": "flux2_attention_split_scale_f32",
"scale_dtype": "float32",
"scale": 0.29730177875068026,
"patched_attention_matmuls": 50,
"patched_scale_mul_inputs": 100,
"matmul_names": [
"/model/MatMul",
"/model/MatMul_2",
"/model/MatMul_4",
"/model/MatMul_6",
"/model/MatMul_8",
"/model/MatMul_10",
"/model/MatMul_12",
"/model/MatMul_14",
"/model/MatMul_16",
"/model/MatMul_18",
"/model/MatMul_20",
"/model/MatMul_22",
"/model/MatMul_24",
"/model/MatMul_26",
"/model/MatMul_28",
"/model/MatMul_30",
"/model/MatMul_32",
"/model/MatMul_34",
"/model/MatMul_36",
"/model/MatMul_38",
"/model/MatMul_40",
"/model/MatMul_42",
"/model/MatMul_44",
"/model/MatMul_46",
"/model/MatMul_48",
"/model/MatMul_50",
"/model/MatMul_52",
"/model/MatMul_54",
"/model/MatMul_56",
"/model/MatMul_58",
"/model/MatMul_60",
"/model/MatMul_62",
"/model/MatMul_64",
"/model/MatMul_66",
"/model/MatMul_68",
"/model/MatMul_70",
"/model/MatMul_72",
"/model/MatMul_74",
"/model/MatMul_76",
"/model/MatMul_78",
"/model/MatMul_80",
"/model/MatMul_82",
"/model/MatMul_84",
"/model/MatMul_86",
"/model/MatMul_88",
"/model/MatMul_90",
"/model/MatMul_92",
"/model/MatMul_94",
"/model/MatMul_96",
"/model/MatMul_98"
],
"mul_names": [
"/model/Mul_8",
"/model/Mul_9",
"/model/Mul_10",
"/model/Mul_11",
"/model/Mul_26",
"/model/Mul_27",
"/model/Mul_28",
"/model/Mul_29",
"/model/Mul_44",
"/model/Mul_45",
"/model/Mul_46",
"/model/Mul_47",
"/model/Mul_62",
"/model/Mul_63",
"/model/Mul_64",
"/model/Mul_65",
"/model/Mul_80",
"/model/Mul_81",
"/model/Mul_82",
"/model/Mul_83",
"/model/Mul_97",
"/model/Mul_98",
"/model/Mul_99",
"/model/Mul_100",
"/model/Mul_109",
"/model/Mul_110",
"/model/Mul_111",
"/model/Mul_112",
"/model/Mul_121",
"/model/Mul_122",
"/model/Mul_123",
"/model/Mul_124",
"/model/Mul_133",
"/model/Mul_134",
"/model/Mul_135",
"/model/Mul_136",
"/model/Mul_145",
"/model/Mul_146",
"/model/Mul_147",
"/model/Mul_148",
"/model/Mul_157",
"/model/Mul_158",
"/model/Mul_159",
"/model/Mul_160",
"/model/Mul_169",
"/model/Mul_170",
"/model/Mul_171",
"/model/Mul_172",
"/model/Mul_181",
"/model/Mul_182",
"/model/Mul_183",
"/model/Mul_184",
"/model/Mul_193",
"/model/Mul_194",
"/model/Mul_195",
"/model/Mul_196",
"/model/Mul_205",
"/model/Mul_206",
"/model/Mul_207",
"/model/Mul_208",
"/model/Mul_217",
"/model/Mul_218",
"/model/Mul_219",
"/model/Mul_220",
"/model/Mul_229",
"/model/Mul_230",
"/model/Mul_231",
"/model/Mul_232",
"/model/Mul_241",
"/model/Mul_242",
"/model/Mul_243",
"/model/Mul_244",
"/model/Mul_253",
"/model/Mul_254",
"/model/Mul_255",
"/model/Mul_256",
"/model/Mul_265",
"/model/Mul_266",
"/model/Mul_267",
"/model/Mul_268",
"/model/Mul_277",
"/model/Mul_278",
"/model/Mul_279",
"/model/Mul_280",
"/model/Mul_289",
"/model/Mul_290",
"/model/Mul_291",
"/model/Mul_292",
"/model/Mul_301",
"/model/Mul_302",
"/model/Mul_303",
"/model/Mul_304",
"/model/Mul_313",
"/model/Mul_314",
"/model/Mul_315",
"/model/Mul_316",
"/model/Mul_325",
"/model/Mul_326",
"/model/Mul_327",
"/model/Mul_328"
]
},
"attention_score_fp32": {
"score_matmuls": 50,
"scale_muls": 100,
"input_casts": 100,
"softmax_casts": 50
},
"export_image_seq_len": 256,
"shards": {
"count": 2,
"total_bytes": 2543824896,
"largest_bytes": 2128121856
}
},
"vae_decoder_pre": {
"file": "flux2-klein-4b-vae-decoder-pre-attn-fp16.onnx",
"dtype": "float16",
"inputs": [
"z"
],
"outputs": [
"/decoder/block_1/Add_output_0",
"/decoder/attn_1/Mul_6_output_0",
"/decoder/attn_1/Mul_7_output_0",
"/decoder/attn_1/Reshape_2_output_0"
],
"execution_provider": "webgpu",
"shards": {
"count": 0,
"total_bytes": 0,
"onnx_bytes": 11352251
}
},
"vae_decoder_attn_chunk": {
"file": "flux2-klein-4b-vae-decoder-attn-chunk-fp16.onnx",
"dtype": "float16",
"chunk_size": 1024,
"head_dim": 512,
"inputs": [
"q_chunk",
"kt",
"v"
],
"outputs": [
"attn_chunk"
],
"execution_provider": "webgpu",
"shards": {
"count": 0,
"total_bytes": 0,
"onnx_bytes": 480
}
},
"vae_decoder_post_stage_0": {
"file": "flux2-klein-4b-vae-decoder-post-stage0-fp16.onnx",
"dtype": "float16",
"inputs": [
"/decoder/block_1/Add_output_0",
"/decoder/attn_1/MatMul_1_output_0"
],
"outputs": [
"/decoder/block.2_2/Add_output_0"
],
"execution_provider": "webgpu",
"shards": {
"count": 0,
"total_bytes": 0,
"onnx_bytes": 85202062
}
},
"vae_decoder_post_stage_1": {
"file": "flux2-klein-4b-vae-decoder-post-stage1-fp16.onnx",
"dtype": "float16",
"inputs": [
"/decoder/block.2_2/Add_output_0"
],
"outputs": [
"/decoder/block.0_3/Add_output_0"
],
"execution_provider": "webgpu",
"shards": {
"count": 0,
"total_bytes": 0,
"onnx_bytes": 2141312
}
},
"vae_decoder_post_stage_2": {
"file": "flux2-klein-4b-vae-decoder-post-stage2-fp16.onnx",
"dtype": "float16",
"inputs": [
"/decoder/block.0_3/Add_output_0"
],
"outputs": [
"/decoder/block.2_3/Add_output_0"
],
"execution_provider": "webgpu",
"shards": {
"count": 0,
"total_bytes": 0,
"onnx_bytes": 1196419
}
},
"vae_decoder_post_stage_3": {
"file": "flux2-klein-4b-vae-decoder-post-stage3-fp16.onnx",
"dtype": "float16",
"inputs": [
"/decoder/block.2_3/Add_output_0"
],
"outputs": [
"image"
],
"execution_provider": "webgpu",
"shards": {
"count": 0,
"total_bytes": 0,
"onnx_bytes": 10460
}
},
"transformer_fused_4step": {
"file": "flux2-klein-4b-transformer-q4-fused-4step.onnx",
"manifest": "transformer-q4-manifest.json",
"dtype": "float16-activations-selective-fp32-int4-weights",
"activation_dtype": "float16-selective-fp32",
"inputs": [
"x",
"x_ids",
"timesteps",
"ctx",
"ctx_ids"
],
"outputs": [
"latent"
],
"execution_provider": "webgpu",
"quantization": {
"format": "MatMulNBits",
"algorithm": "ORT",
"bits": 4,
"block_size": 16,
"is_symmetric": false,
"op_types_to_quantize": [
"MatMul"
],
"matmul_nbits_nodes": 89,
"remaining_matmul_nodes": 100,
"flattened_matmul_nbits_inputs": 89,
"flattened_matmul_nbits_zero_points": 89,
"rope_fp32_rewrites": {
"position_id_inputs": 0,
"position_id_casts": 0,
"rope_frequency_constants": 0
},
"accuracy_level": 4,
"streaming_source": true
},
"attention_scale_fix": {
"type": "fixed_split_scale",
"head_dim": 128,
"scale_name": "flux2_attention_split_scale_f32",
"scale_dtype": "float32",
"scale": 0.29730177875068026,
"patched_attention_matmuls": 50,
"patched_scale_mul_inputs": 100,
"matmul_names": [
"/model/MatMul",
"/model/MatMul_2",
"/model/MatMul_4",
"/model/MatMul_6",
"/model/MatMul_8",
"/model/MatMul_10",
"/model/MatMul_12",
"/model/MatMul_14",
"/model/MatMul_16",
"/model/MatMul_18",
"/model/MatMul_20",
"/model/MatMul_22",
"/model/MatMul_24",
"/model/MatMul_26",
"/model/MatMul_28",
"/model/MatMul_30",
"/model/MatMul_32",
"/model/MatMul_34",
"/model/MatMul_36",
"/model/MatMul_38",
"/model/MatMul_40",
"/model/MatMul_42",
"/model/MatMul_44",
"/model/MatMul_46",
"/model/MatMul_48",
"/model/MatMul_50",
"/model/MatMul_52",
"/model/MatMul_54",
"/model/MatMul_56",
"/model/MatMul_58",
"/model/MatMul_60",
"/model/MatMul_62",
"/model/MatMul_64",
"/model/MatMul_66",
"/model/MatMul_68",
"/model/MatMul_70",
"/model/MatMul_72",
"/model/MatMul_74",
"/model/MatMul_76",
"/model/MatMul_78",
"/model/MatMul_80",
"/model/MatMul_82",
"/model/MatMul_84",
"/model/MatMul_86",
"/model/MatMul_88",
"/model/MatMul_90",
"/model/MatMul_92",
"/model/MatMul_94",
"/model/MatMul_96",
"/model/MatMul_98"
],
"mul_names": [
"/model/Mul_8",
"/model/Mul_9",
"/model/Mul_10",
"/model/Mul_11",
"/model/Mul_26",
"/model/Mul_27",
"/model/Mul_28",
"/model/Mul_29",
"/model/Mul_44",
"/model/Mul_45",
"/model/Mul_46",
"/model/Mul_47",
"/model/Mul_62",
"/model/Mul_63",
"/model/Mul_64",
"/model/Mul_65",
"/model/Mul_80",
"/model/Mul_81",
"/model/Mul_82",
"/model/Mul_83",
"/model/Mul_97",
"/model/Mul_98",
"/model/Mul_99",
"/model/Mul_100",
"/model/Mul_109",
"/model/Mul_110",
"/model/Mul_111",
"/model/Mul_112",
"/model/Mul_121",
"/model/Mul_122",
"/model/Mul_123",
"/model/Mul_124",
"/model/Mul_133",
"/model/Mul_134",
"/model/Mul_135",
"/model/Mul_136",
"/model/Mul_145",
"/model/Mul_146",
"/model/Mul_147",
"/model/Mul_148",
"/model/Mul_157",
"/model/Mul_158",
"/model/Mul_159",
"/model/Mul_160",
"/model/Mul_169",
"/model/Mul_170",
"/model/Mul_171",
"/model/Mul_172",
"/model/Mul_181",
"/model/Mul_182",
"/model/Mul_183",
"/model/Mul_184",
"/model/Mul_193",
"/model/Mul_194",
"/model/Mul_195",
"/model/Mul_196",
"/model/Mul_205",
"/model/Mul_206",
"/model/Mul_207",
"/model/Mul_208",
"/model/Mul_217",
"/model/Mul_218",
"/model/Mul_219",
"/model/Mul_220",
"/model/Mul_229",
"/model/Mul_230",
"/model/Mul_231",
"/model/Mul_232",
"/model/Mul_241",
"/model/Mul_242",
"/model/Mul_243",
"/model/Mul_244",
"/model/Mul_253",
"/model/Mul_254",
"/model/Mul_255",
"/model/Mul_256",
"/model/Mul_265",
"/model/Mul_266",
"/model/Mul_267",
"/model/Mul_268",
"/model/Mul_277",
"/model/Mul_278",
"/model/Mul_279",
"/model/Mul_280",
"/model/Mul_289",
"/model/Mul_290",
"/model/Mul_291",
"/model/Mul_292",
"/model/Mul_301",
"/model/Mul_302",
"/model/Mul_303",
"/model/Mul_304",
"/model/Mul_313",
"/model/Mul_314",
"/model/Mul_315",
"/model/Mul_316",
"/model/Mul_325",
"/model/Mul_326",
"/model/Mul_327",
"/model/Mul_328"
]
},
"attention_score_fp32": {
"score_matmuls": 50,
"scale_muls": 100,
"input_casts": 100,
"softmax_casts": 50
},
"export_image_seq_len": 256,
"shards": {
"count": 2,
"total_bytes": 2543824896,
"largest_bytes": 2128121856
},
"fused_steps": 4
},
"vae_encoder": {
"file": "flux2-klein-4b-vae-encoder-fp16.onnx",
"dtype": "float16",
"source_model": "black-forest-labs/FLUX.2-klein-4B",
"source_subfolder": "vae",
"inputs": [
"image"
],
"outputs": [
"z"
],
"execution_provider": "webgpu",
"shards": {
"count": 0,
"total_bytes": 0,
"onnx_bytes": 68964001
}
}
},
"notes": "WebGPU bundle: q4 text encoder, q4 transformer with fp16 activations, fp32 attention score/softmax math, fixed attention split-scale constants, and fp16 VAE decoder split into pre-attention, attention-chunk, and post-attention stages so each session can be created and released independently.",
"vae_decoder_post_stage_keys": [
"vae_decoder_post_stage_0",
"vae_decoder_post_stage_1",
"vae_decoder_post_stage_2",
"vae_decoder_post_stage_3"
],
"supports_img2img": true
}