翻篇收录说明
翻篇网页快照

FLUX.3 - SGLang Documentation

https://docs.sglang.io/cookbook/diffusion/FLUX/FLUX.3

最近抓取:2026-12-03 04:40:26(北京时间)

最近内容变化:2026-12-01 00:37:28(北京时间)

这是最近一次有效抓取的文本快照,不含网页脚本、图片和动态交互内容。实际网页可能已更新。

访问原网页

页面简介

Serve FLUX.3 Image Klein text-to-image generation and image editing with SGLang Diffusion.

正文摘录

1. Quick start Use a SGLang Diffusion Docker environment. Until a released image contains this integration, install SGLang from main inside it: pip install 'sglang[diffusion] @ git+https://github.com/sgl-project/sglang.git#subdirectory=python' The picker selects black-forest-labs/flux-3-image-klein-base or black-forest-labs/flux-3-image-klein, each a self-contained repository. Access to the selected checkpoint is required. Keep --model-path at its repository root; --model-variant selects only the quantized DiT. Both release BF16 checkpoints have single-GPU generation checks; see the validation boundaries below. Unverified hardware or resource shapes remain selectable but are not measured recommendations. The picker defaults to resident weights for its 1 MP, batch-1 workload. Its recommended execution uses BCG only where a matched E2E comparison showed a material gain: currently single-GB300 distilled NVFP4 T2I. Other combinations start eager; this graph recipe covers the 80-token text bucket. Changing precision never happens automatically. Recommendations are best among the tested settings, not an exhaustive optimum. FLUX.3 Image Klein is released under the FLUX Kommunity License v1.0: non-commercial use, plus commercial output generation for Qualifying Users with less than US$5M in gross annualized revenue, subject to its terms. The Qwen3-VL-4B-Instruct text encoder is Apache-2.0. Review the license before production or commercial use. For platform-specific installation, see the SGLang Diffusion installation guide. 2. Model capabilities FLUX.3 Image Klein is Black Forest Labs’ 5.6B open-weights model for text-to-image generation and image editing. It takes a prompt and up to 10 reference images and returns one image; text-to-image, single-reference edits and multi-reference compositions run through the same DiT, with Qwen3-VL-4B-Instruct as the text encoder. The 5.6B count covers the image transformer only. Prompts can place elements with bounding boxes on a 0 to 1000 grid, then recolor, move, replace or remove them; boxes guide placement and scale rather than masking pixels. The model also renders text inside images. One SGLang server serves text-to-image and editing, chosen per request. This image pipeline does not serve the separate FLUX.3 Action robot policy. CheckpointTrainingStepsGuidanceBuilt forKleinstep-distilled flow map16nonegeneration and editing, self-hosting; the checkpoint behind the BFL APIKlein Baseundistilled503.5fine-tuning, LoRA training, research Each repository ships its BF16 DiT with FP8 (fp8r) and NVFP4 variants, together with the text encoder and image autoencoder. The default conditioning cache reuses prompt encodings, including the Base model’s negative prompt. It does not skip denoising steps or change the checkpoint. Cache-DiT, described below, is a separate approximation. TaskEndpointConditioningText to imagePOST /v1/images/generationsText promptImage to imagePOST /v1/images/editsText prompt and 1 to 10 image uploads Start the server: sglang serve \ --model-path black-forest-labs/flux-3-image-klein-base \ --host 0.0.0.0 \ --port 30010 Sampling is set per request (num_inference_steps, guidance_scale, size, seed, n); unset fields take the checkpoint’s defaults from its config.json. SGLang expands n into independently seeded requests and can pack compatible requests into one DiT forward. References are prepared as in the BFL reference pipeline. A single reference is fitted under 4 MP, reflect-padded to the 16-pixel grid and, when you set no output size, sets the output size; the padding is cropped from the result. With several references each is fitted under 1 MP and centre-cropped, and the output takes the first one’s size. Prompting The caption controls composition; reference images anchor content but do not lock structure. Write full scene captions covering framing, subject, background and lighting. A short prompt gives generic output, and a one-line edit instruction (“make it blue”) reframes the shot. The prompt upsampler expands a short request into a full caption. For edits, describe the target image as a complete caption of the reference with the edit folded in. For layout, append a JSON list of elements to the caption. Each box is [top, left, bottom, right] on a 0 to 1000 grid, and the caption tags each element as <id>. To edit by box, refer to the n-th reference as <ref_image_n> and give each element from, src_bbox and tgt_bbox; a null target removes it. See BFL’s bounding box guide for the full format. 3. Checkpoints and precision Repository--model-variantSamplingblack-forest-labs/flux-3-image-klein-baseOmit / fp8r / nvfp4Base CFG; defaults from the selected configurationblack-forest-labs/flux-3-image-kleinOmit / fp8r / nvfp4Step-distilled flow map; no CFG Both repositories use flux-3-image-klein in configuration and safetensors metadata. This shared identifier does not determine the sampling mode. The release repositories do not need the pre-release sd-* variant names. The distilled model is a step-distilled flow-map DiT: each step jumps straight to the next time of the schedule, so it samples without CFG. SGLang tells a flow map from its weights. It rejects --enable-cfg-parallel, a request guidance_scale other than 1, and a non-empty negative_prompt. Tensor parallelism, Ulysses SP and breakable CUDA graphs work as for the base model. The Base model defaults to CFG 3.5 against an empty negative prompt. Both variants reuse the package’s text encoder and VAE. Keep the checkpoint revision, precision, attention backend, guidance and sampling parameters fixed when comparing outputs. Explicit guidance_scale=1 uses scale 1, not the package default; true_cfg_scale, when provided, takes precedence over guidance_scale. Quantized checkpoints Each repo ships quantized DiTs under variants/: select one with --model-variant fp8r or --model-variant nvfp4 and keep --model-path pointing at the repo root. Text encoder and VAE precision follow their own package settings; quantizing the DiT does not quantize them. An explicit --component-precisions.vae bf16 overrides the package dtype for both reference-image encoding and output decoding. The quantization comes from the variant’s hf_quant_config.json, so do not also pass --quantization. sglang serve \ --model-path black-forest-labs/flux-3-image-klein-base \ --model-variant fp8r \ --host 0.0.0.0 \ --port 30010 FP8R stores rowwise-FP8 weights. On Blackwell (SM10x) the FP8 projections run FlashInfer PrimsTS GEMMs with fused QK-norm/RoPE and SwiGLU epilogues (FlashInfer >= 0.7.1); set SGLANG_ENABLE_FLUX3_PRIMS_TS_AUTOTUNE=1 to autotune them during warmup. Other GPUs use the generic rowwise-FP8 GEMM. NVFP4 stores FP4 (E2M1) weights with FP8 block scales and needs a Blackwell GPU and a compatible GEMM implementation. SM10x and consumer SM120 use different kernel paths; a B200 recipe does not establish RTX 5090 performance. Both quantization modes can change output quality and need workload-specific comparison against BF16. These flags remain separately configurable; see the validation boundaries below before combining quantization with other optimizations. Breakable CUDA graphs BCG reserves additional device memory and captures specific request shapes. The picker generates --warmup-resolutions 1024x1024 and matching --warmup-sampling-params for the selected quality. For editing it also sets flux3_mode="i2i" and a server-local reference path: mount a 1024x1024 image there before starting the server. This path can differ from the client’s upload path. Longer prompt token buckets, other reference dimensions/counts, batches or quality settings may run eager instead; check for a serving-signature miss in the server log. Changing the picker workload also changes its graph warmup command. Restart with that command to capture the new workload. Keep eager for variable-shape traffic, or explicitly validate every shape you intend to capture. LoRA adapters Use the standard LoRA API with native DiT keys, optionally prefixed by dit. or transformer.. BF16 dynamic and merged adapters have a synthetic rank-4 generation check, including repeatability and exact restoration after unloading; this does not validate every community adapter. For quantized deployments requiring LoRA, pass --lora-path at startup to select the generic quantized layout. Attaching LoRA after PrimsTS weight preparation is rejected before replacing any layers. FP8R and NVFP4 startup adapters also have synthetic rank-4 generation checks on GB300, including repeatability and exact restoration after unloading. These do not establish compatibility with arbitrary quantized community adapters. 4. Multi-GPU and memory FLUX.3 shares its DiT with FLUX.3 Action, so the image pipeline supports tensor parallelism, Ulysses sequence parallelism, CFG parallelism, layerwise offload and breakable CUDA graphs. The picker covers RTX 5090, RTX PRO 6000, H100/H200, and B200/B300/GB200/GB300 with one to eight GPUs on one node. TP times Ulysses degree must equal the GPU count and evenly partition the 24 attention heads. Ring is not admitted by this image recipe. For example, two-GPU TP uses --num-gpus 2 --tp-size 2; two-GPU Ulysses uses --num-gpus 2 --tp-size 1 --ulysses-degree 2. Base also permits CFG parallelism; distilled checkpoints have no CFG branch to parallelize. More GPUs do not guarantee lower latency, particularly over PCIe. Ulysses inherits all-to-all streaming through the shared attention layer. Leave its pipeline-group policy automatic; short sequences need not benefit. TP-only deployments do not use this path. Encoding-while-decoding overlaps video-frame decoding with video-file encoding, so it does not apply to this still-image pipeline. Under sequence parallelism every rank holds the full DiT, so combining it with layerwise offload streams the whole model to each GPU every step. TP also partitions weights, so it is the lower-memory starting point when offloading on several GPUs. Preserve headroom for