Accelerating Diffusers and xDiT Image Generation with MXFP4 using AMD Quark on AMD Instinct™ MI350 GPUs AMD Quark, a quantization library optimized for AMD Instinct MI350 GPUs, enables MXFP4 quantization for Diffusers and xDiT FLUX.1-dev image generation, achieving up to 1.92× speedup over BF16 eager and 1.41× over BF16 torch.compile while preserving CLIP quality. The integration reduces inference cost without sacrificing image quality. Accelerating Diffusers and xDiT Image Generation with MXFP4 using AMD Quark on AMD Instinct™ MI350 GPUs accelerating-diffusers-and-xdit-image-generation-with-mxfp4-using-amd-quark-on-amd-instinct-mi350-gpus Diffusion models such as Black Forest Labs’ FLUX.1-dev 1 references deliver stunning image quality but demand significant compute and memory bandwidth at inference time. To reduce inference cost without sacrificing image quality, precision-aware quantization techniques have become a critical optimization strategy. In this blog, we demonstrate how AMD Quark 2 references , a high-performance quantization library optimized for AMD Instinct™ MI350 GPUs, enables MXFP4 quantization for Diffusers 5 references and xDiT 3 references FLUX.1-dev image generation. Starting from BF16 eager and torch.compile baselines, we apply Quark native inference with AITER 4 references GEMM kernels and show that MXFP4 ASM with torch.compile reaches 1.92× speedup over BF16 eager and 1.41× speedup over BF16 torch.compile , while preserving CLIP quality. Quantization with Quark quantization-with-quark AMD Quark is a comprehensive cross-platform deep learning toolkit designed to simplify and enhance the quantization of deep learning models. For diffusion model quantization, Quark is tightly integrated with ROCm™ and optimized for matrix-core acceleration. It provides: Multiple numeric formats — MXFP4, MXFP6, FP8, INT8, INT4, and more Modular quantization flows — Post-Training Quantization PTQ , Quantization-Aware Training QAT , and others Support for diffusion models — FLUX, Stable Diffusion, and large decoder-only LLMs Native inference acceleration — via AMD AITER GEMM kernels on MI300/MI350 GPUs Seamless integration — with inference pipelines such as Diffusers 5 references , vLLM, and SGLang With Quark, users can configure per-layer quantization schemes based on layer sensitivity, enabling both uniform and mixed-precision flows. By combining this flexibility with the native FP4/FP8 matrix-core capabilities of MI350 GPUs, Quark achieves near-lossless image quality while significantly improving inference efficiency. Quark provides online quantization for xDiT to make inference more efficient. xDiT is a parallel inference engine for diffusion transformers — it shards and executes a model like FLUX.1-dev across one or more GPUs. Quark plugs into that pipeline at load time: it converts the BF16 transformer’s linear layers into FP8 or MXFP4 in-memory and routes the resulting GEMMs to native AITER matrix-core kernels on MI300 / MI350 GPUs — with no offline checkpoint conversion required. How Quark Fits into the xDiT Stack how-quark-fits-into-the-xdit-stack The diagram below shows where Quark sits inside the xDiT inference stack: Diffusers exposes the standard FluxPipeline API, xDiT parallelizes the transformer across GPUs, and Quark online-quantizes each replica’s linear layers to FP8 / MXFP4 so they execute on AITER’s matrix-core GEMM kernels. The benchmarks in the rest of this blog measure the impact of this innermost swap — Quark-quantized linear layers — with the xDiT and Diffusers layers unchanged. Preparation preparation Environment environment Component | Version / Image | |---|---| Hardware | AMD Instinct™ MI350 gfx950 | Docker | | Quark Release | 0.12 | PyTorch | | AITER | | Model | | Resolution | 1024 × 768, 20 inference steps, | Docker Setup docker-setup docker run -it \ --cap-add=SYS PTRACE \ --security-opt seccomp=unconfined \ --user root \ --device=/dev/kfd --device=/dev/dri --device=/dev/mem \ --group-add video \ --ipc=host --network host --privileged \ --shm-size 128G \ --name flux benchmark \ -e HSA NO SCRATCH RECLAIM=1 \ -e CUDA VISIBLE DEVICES=0 \ -v /shareddata/:/data \ -v /home/$USER:/workspace \ -w /workspace \ rocm/pytorch-xdit:v26.5 Install Dependencies inside container install-dependencies-inside-container apt-get update && apt-get install -y nano python3-tk pip install torchmetrics transformers hpsv2 open clip torch pycocotools Install Quark from source main branch cd /workspace git clone https://github.com/amd/quark.git Quark && cd Quark pip install -e . Verify GPU & AITER rocm-smi --showproductname python3 -c "import torch; print torch.cuda.get device name 0 " python3 -c "import aiter; print 'AITER OK' " BF16 Baseline bf16-baseline BF16 bfloat16 serves as the unquantized baseline configuration. It loads and runs the FLUX.1-dev model as-is in 16-bit floating point. No quantization is applied. Benchmark Script benchmark-script python import torch from diffusers import FluxPipeline pipe = FluxPipeline.from pretrained "/data/black-forest-labs/FLUX.1-dev", torch dtype=torch.bfloat16, .to "cuda" prompt = "A photo of a cat sitting on a windowsill at sunset" for in range 3 : warmup pipe prompt, height=768, width=1024, num inference steps=20, guidance scale=3.5 import time latencies = for in range 10 : t0 = time.time pipe prompt, height=768, width=1024, num inference steps=20, guidance scale=3.5 latencies.append time.time - t0 print f"BF16 Mean latency: {sum latencies /len latencies :.3f} s/img" MXFP4 Quantization mxfp4-quantization MXFP4, defined as part of the OCP Microscaling MX specification 6 references , groups 32 elements of 4-bit floating-point values to share a common E8M0 scaling exponent. Because it uses block-level scaling with FP4 elements, MXFP4 enables substantial model compression while retaining sufficient dynamic range for diffusion-model inference. Supported natively on AMD Instinct™ MI350 and newer GPUs, MXFP4 delivers the strongest efficiency gains among all supported formats tested in this blog, achieving up to 1.92× speedup over the BF16 eager baseline and 1.41× speedup over BF16 torch.compile when combined with the in-tree torch.compile fix that landed on Quark main . MXFP4 Quantization & Benchmark Script mxfp4-quantization-benchmark-script python import torch from diffusers import FluxPipeline from quark.torch.quantization.api import ModelQuantizer, RuntimeOptions from quark.torch.quantization.config.config import QConfig, QLayerConfig, OCP MXFP4Spec, pipe = FluxPipeline.from pretrained "/data/black-forest-labs/FLUX.1-dev", torch dtype=torch.bfloat16, .to "cuda" Configure MXFP4 quantization with 32-element block scaling weight spec = OCP MXFP4Spec ch axis=-1, is dynamic=False .to quantization spec input spec = OCP MXFP4Spec ch axis=-1, is dynamic=True .to quantization spec layer config = QLayerConfig weight=weight spec, input tensors=input spec quantizer = ModelQuantizer QConfig global quant config=layer config pipe.transformer = quantizer.quantize model pipe.transformer Freeze model with MXFP4 native inference AITER FP4 GEMM kernels runtime opts = RuntimeOptions native linear mode="mxfp4" pipe.transformer = ModelQuantizer.freeze pipe.transformer, runtime options=runtime opts, Benchmark prompt = "A photo of a cat sitting on a windowsill at sunset" for in range 3 : pipe prompt, height=768, width=1024, num inference steps=20, guidance scale=3.5 import time latencies = for in range 10 : t0 = time.time pipe prompt, height=768, width=1024, num inference steps=20, guidance scale=3.5 latencies.append time.time - t0 print f"MXFP4 Mean latency: {sum latencies /len latencies :.3f} s/img" MXFP4 Kernel mxfp4-kernel On Quark main , the MXFP4 native linear uses AITER’s ASM GEMM path by default : per 1x32 f4 quant hip for activation quantization plus gemm a4w4 with bpreshuffle=True , with a dequantization and matrix-multiply fallback for small-K layers. No user flag is needed. Instantiating RuntimeOptions native linear mode="mxfp4" selects ASM automatically. Path | Activation Quantization | GEMM Kernel | Eager Latency | | |---|---|---|---|---| | | | | | Quality Evaluation quality-evaluation Image quality is evaluated with CLIP Score 7 references , a text-image alignment metric where higher is better, on 100 COCO 2017 8 references caption prompts. We report results with openai/clip-vit-base-patch16 , where FLUX scores land in the 30-32 range typical of FLUX papers. Evaluation Script evaluation-script The CLIP evaluation helper is available as eval clip.py ../../ downloads/55562cf2c53c5b6cd65bb0bd6ae2d5ff/eval clip.py . python3 eval clip.py \ --image dir