flux_quantize

Quantize a FLUX transformer to NF4 or fp8 shards

Description

Streams the bf16 diffusers checkpoint tensor by tensor. Cast-set weights (see flux_is_quant_key) are stored as NF4 (packed uint8 + <key>_absmax float32 blocks) or as float8_e4m3fn with an absmax/448 per-tensor <key>_scale; everything else is copied through unchanged. The manifest embeds the transformer config, so the source checkpoint is not needed again after quantization.

Usage

flux_quantize(transformer_dir, output_dir = NULL, format = c("nf4", "fp8"),
              shard_bytes = 4e+09, force = FALSE, verbose = TRUE)

Arguments

  • transformer_dir: Source diffusers transformer directory.
  • output_dir: Output directory for shards + manifest (default: the per-format location under tools::R_user_dir).
  • format: “nf4” or “fp8”.
  • shard_bytes: Numeric. Approximate shard size.
  • force: Logical. Re-quantize even if a valid manifest exists.
  • verbose: Logical.

Value

Invisibly, the manifest list.