Xema: Efficient Diffusion Serving through Fine-Grained Memory Management and Auto-Configuration

Xueze Kang, Guangyu Xiang, Suyi Li, Yuxin Wang, Shaohuai Shi, Lin Zhang, Xiaowen ChuarXiv 2026

TL;DR

Xema is a memory-efficient serving system for large-scale image and video diffusion models that eliminates GPU memory bottlenecks without sacrificing performance. By exploiting the predictable, template-static nature of diffusion inference, Xema applies fine-grained memory mitigation only during brief peak-pressure intervals and uses an offline static allocator to eliminate memory fragmentation. This approach boosts Service Level Objective (SLO) attainment by up to 3.7× while slashing configuration planning time from hours to under four minutes.

What Problem Does This Paper Address?

Deploying modern diffusion models (like Flux.2 or CogVideoX) for high-resolution image and long video generation introduces severe GPU memory pressure. Even at a batch size of one, these workloads can easily exceed the memory capacity of standard production GPUs.

The memory footprint stems from heterogeneous sources: large model weights, Diffusion Transformer (DiT) activations, and Variational Autoencoder (VAE) activation peaks. Existing memory-saving techniques—such as weight offloading, sharding, and VAE slicing—act as coarse, global switches. They reduce memory but introduce massive CPU-GPU transfer or cross-GPU communication overheads across the entire inference lifecycle, severely hurting throughput and violating latency constraints (SLOs). Furthermore, standard runtime memory allocators (like PyTorch's) suffer from severe fragmentation, wasting up to 40% of available GPU memory.

Methods

Xema introduces a trace-guided memory optimization layer and an auto-configuration planner designed specifically for the deterministic nature of diffusion pipelines:

  1. Fine-Grained Memory Mitigation: Instead of globally enabling conservative memory controls, Xema identifies specific short intervals where memory exceeds the budget. It applies techniques like selective block offloading, localized chunking/fusion, and temporary serialization (lowering batch size only during peak intervals) precisely where and when needed.
  2. Offline Static Memory Layout: Because a diffusion model's execution path depends entirely on its request template (model, resolution, frame count) and not the input content, tensor lifetimes are perfectly predictable. Xema runs a lightweight, shape-only pass to derive these lifetimes and applies a 2D rectangle-packing algorithm to pre-assign exact GPU memory addresses, completely bypassing runtime allocator fragmentation.
  3. Joint Offline Planner: Navigating the massive search space of parallelism (sequence and data parallelism), batch sizes, and fine-grained memory controls is challenging. Xema utilizes a multi-stage planner that uses the offline memory trace to prune infeasible configurations early, focusing the search strictly on memory-pressure intervals.
Figure 3. System architecture.

Datasets

The system was evaluated using production-grade diffusion pipelines across 21 distinct request templates (varying resolutions from $256 \times 256$ to $2048 \times 2048$, and video lengths up to 81 frames). The models evaluated include:

  • Flux.2 (32B parameter image generation model)
  • CogVideoX-5B (5B parameter video generation model)
  • LTX-2 (13B parameter video generation model)

Workloads were simulated using a Poisson arrival process to mimic realistic production traffic patterns.

Key Insights and Ideas

  • Memory pressure is highly localized: In models like CogVideoX, only about 2% of memory allocation events ever reach 90% of the peak phase memory. Global mitigation is overkill; targeting just these spiky intervals preserves performance.
Figure 2. Memory usage is highly uneven during CogVideoX inference. Most allocation events are far below the phase peak, while only a small fraction of events reach near-peak memory usage.
  • Deterministic execution enables static planning: Unlike Large Language Models (LLMs) where token generation lengths are dynamic and content-dependent, diffusion models have completely static execution graphs for a given resolution and frame count. This predictability allows for perfect offline memory layout planning.
  • Coarse controls create false trade-offs: Forcing full weight offloading can more than double per-step latency (e.g., jumping from 3.1s to 8.4s in Flux.2). Offloading just the minimum number of blocks needed to fit the GPU budget maintains high performance while staying within bounds.

Key Results

  • SLO Attainment: Xema improves SLO attainment by up to 3.7× under heavy workloads compared to state-of-the-art baselines like vLLM-Omni.
  • Extreme Workload Feasibility: On a single 48GB GPU, Xema successfully serves extreme workloads up to 4K resolution or 289 video frames, whereas traditional systems crash with Out-Of-Memory (OOM) errors on anything larger than 720p.
  • Memory Efficiency: Boosts effective memory utilization from ~58% to up to 99% by eliminating allocator fragmentation.
  • Planning Speed: The offline planner cuts configuration search time from 6.3 hours (via exhaustive grid search) to just 197 seconds.
Figure 1. Optimal execution configurations vary across LTX- 2 request templates. For each template, the first bar is selected by Xema, and the next two bars are the best and second-best configurations searched by vLLM-Omni. By expanding the search space with fine-grained memory controls, Xema finds higher-goodput configurations than vLLM-Omni.

Limitations and Future Work

  • Dynamic Memory Margin: While graph-visible tensors are statically allocated, a small fraction of memory (such as CUDA contexts and NCCL communication buffers) remains dynamic and unpredictable, requiring Xema to reserve a conservative 5% memory margin.
  • Lossy Optimizations: The current implementation focuses strictly on lossless system-level optimizations. Integrating lossy techniques like quantization or VAE tiling into Xema's planning framework remains an open direction for future work.

Summary updated

BibTeX
@misc{kang2026xema,
  author = {Xueze Kang and Guangyu Xiang and Suyi Li and Yuxin Wang and Shaohuai Shi and Lin Zhang and Xiaowen Chu},
  title = {{Xema: Efficient Diffusion Serving through Fine-Grained Memory Management and Auto-Configuration}},
  year = {2026},
  eprint = {2607.11136},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2607.11136},
}
Figure