Manuscript Offprint

arXiv:2610.23047

DIFFLET: A Fast Inference Engine for Diffusion Transformer Models on AWS Trainium

Bin Ma, Min Yu, Vijay Kodamalla, Jialin Liu, Dong Li

ABSTRACT

On AWS Trainium2, every component of a diffusion model runs as a program compiled ahead of time for fixed shapes, while pipelines differ across models, prompt lengths across requests, and caching decisions across denoising steps. We present Difflet, a serving engine in which five model pipelines share one compilation backend, joint attention is split across cores by attention head, and a host controller decides at each denoising step whether to run the denoiser or reuse its earlier output. A small probe program computes the caching signal on the device and returns one number per step, and a resident model process keeps every program loaded across requests. Across five image and video model families, fused attention accelerates denoiser steps by 1.2–4.3×1.2–4.3\times over the same framework using PyTorch/XLA attention, and at 32.8k visual tokens it is the only attention that compiles. On four of the five models, resident serving is 1.5–3.4×1.5–3.4\times faster than standalone runs that reload weights from a warm file cache for each generation.

1 INTRODUCTION

Diffusion transformers generate images and videos through repeated denoising steps. Each step applies a transformer to a noisy latent representation, using the timestep and conditioning inputs to predict the noise, or for flow-matching models the velocity, from which the sampler computes a less noisy latent (Peebles & Xie, 2023). Higher image resolutions and longer videos increase the number of visual tokens processed at each step. Repeating this computation raises both generation latency and the accelerator time consumed by each request. Efficient serving therefore requires shortening the user's wait while controlling the cost per generated image or video.

Most diffusion serving today runs on NVIDIA GPUs, whose high price and limited supply make the production cost hard to manage. Cloud providers have therefore built cost-efficient, customized accelerators. AWS Trainium (Fan et al., 2024) is one of those examples: it has been reported that Trainium2 instances provide 30–40% better price-performance than GPU-based EC2 P5e and P5en instances (Amazon Web Services, 2026i), and distributed LLM training on first-generation Trainium cost up to 46.3% less than on A100-based instances in selected workloads, at comparable or higher training throughput (Fu et al., 2024). Each Trainium chip contains several NeuronCores (cores for short), and the Neuron Kernel Interface (NKI) lets programmers write kernels that choose which of a core's tensor, vector, scalar, and general-purpose engines runs each operation and when data moves (Amazon Web Services, 2026j;b;c). With Trainium's production software stack, serving a diffusion model means running programs that are compiled ahead of time for fixed shapes and called by a host process at every denoising step. Serving diffusion models under this execution model requires deciding what must be fixed in compiled programs and what must remain flexible across models, requests, and denoising steps. This creates challenges at three levels: accommodating different model pipelines, distributing each denoiser evaluation across cores, and reusing results across denoising steps.

First, diffusion models differ in their encoders, denoiser, and decoder and in the order they call them, yet on Trainium every one of these components must be compiled before serving. Ahead-of-time (AOT) compilation specializes each component for the selected tensor shapes, data type, and parallel configuration (Amazon Web Services, 2026d). When compilation, loading, and invocation are embedded in each model's pipeline, supporting another model requires assembling another execution path around these constraints. The challenge is to add a model without writing another compilation and loading path for it.

Second, distributing a denoiser across Trainium cores requires finding a parallel configuration that both the model and the compiled kernels support. Tensor parallelism (TP) partitions weights (Shoeybi et al., 2019); sequence and context parallelism (SP, CP) partition tokens (Korthikanti et al.,

1^{1}Yotta Labs, USA 2^{2}University of California, Merced, Merced, California, USA.

Bin Ma bin@yottalabs.ai, Min Yu minyu@yottalabs.ai, Vijay Kodamalla vijayk@yottalabs.ai, Jialin Liu liu@yottalabs.ai, Dong Li dli35@ucmerced.edu.

2022; Jacobs et al., 2023; Liu et al., 2023); and classifier-free guidance (CFG) parallelism executes conditional and unconditional denoiser passes concurrently (Ho & Salimans, 2022). Each choice changes tensor shapes, data layouts, and communication requirements, so these choices cannot be combined freely. For example, joint attention over visual and text tokens must exclude padded text keys from its softmax. The masked attention path used here requires valid keys to be contiguous and query and key lengths to match (Amazon Web Services, 2026e). A direct partition that keeps queries local while gathering all keys violates the second requirement. Such incompatibilities make parallel configuration a question of execution feasibility as well as performance, and discovering them only after compilation is costly.

Third, step caching, a common optimization for diffusion transformers, must obtain a cheap reuse signal despite Trainium's compilation and memory constraints. Methods such as TeaCache use early denoiser features to decide when to reuse prior results (Liu et al., 2025a). In our AOT execution path, these features remain inside the compiled denoiser, while the host controls whether to invoke it. Computing the signal separately on the host adds latency; a device implementation instead needs additional memory for weights and saved features alongside the partitioned denoiser. This placement tradeoff can undermine caching: our host path makes Wan's denoising loop 11% longer than without caching, while HunyuanVideo already occupies 22 of 24 GiB per logical core before adding a probe.

We present Difflet, a serving engine for diffusion transformers on AWS Trainium2 built around one boundary: what is the same for every request is compiled, and what changes per request or per step stays on the host. Each component's program fixes its shapes, data type, parallel configuration, and kernels; the model's control flow, the prompt length, the decision to skip a step, and each request's sampling state are left to the host. When such a value must reach or leave the device, Difflet passes it as a small runtime value instead of building a new program: the number of valid text keys going into attention, and one change score per step coming out of the caching probe.

To support different models, Difflet exploits what diffusion pipelines have in common. Their control flow differs, but all of them are built from conditioning encoders, a denoiser, and a decoder. Each of these components compiles to a program that depends only on its shape, data type, parallel configuration, and compiler version, and, where a device probe is fused into the denoiser, on whether the probe is present; runtime settings such as the caching cadence or threshold do not enter it. Difflet therefore keeps each model's control flow in its own pipeline on the host and moves everything AOT compilation needs into a shared backend, driven by a short description of each model. The backend caches each compiled program under exactly these inputs, so a server restart or a new caching threshold reuses the program instead of recompiling it.

For parallel execution, Difflet chooses each split by what Trainium's attention kernels accept. For attention, it uses Ulysses-style context parallelism (Jacobs et al., 2023), which regroups the tokens by attention head, so each core holds every query and key for its heads and thus the same number of queries as keys. Difflet places the text padding after all valid keys, so the valid keys sit next to each other, and each request passes only the number of valid keys. One compiled program thus serves every prompt length, and the split result matches unsplit attention to within BF16 rounding. Difflet also rejects unsupported combinations before compiling rather than after a long compilation fails.

To skip denoising steps, Difflet estimates the output change outside the denoiser in one of two ways. A small compiled probe computes an early denoiser feature on the device, keeps the previous step's feature there, and returns a single number to the host; because it loads only the weights of the layers it runs, it fits beside the denoiser even on HunyuanVideo. Alternatively, Difflet estimates the change from the outputs of earlier steps, which needs no additional program. In both cases, a host controller decides at each step whether to call the denoiser or reuse an earlier output.

These three parts meet in Difflet’s resident model process, which keeps a model’s programs loaded across requests. At startup, the process loads the programs compiled for the deployment’s shapes, data type, and parallel configuration, checks that they match, and runs a test generation before accepting requests. For every request, it resets the sampling and caching state, so reuse never crosses requests. Difflet serves FLUX (Black Forest Labs, 2024), QwenImage (Wu et al., 2025), Wan (Wan Team et al., 2025), HunyuanVideo (Kong et al., 2024), and LTX-2 (HaCohen et al., 2026) through this process.

We summarize our contributions as follows:

• A shared Trainium backend through which one kernel or parallel mode serves different diffusion pipelines.

• Parallel execution planned as a serving decision, with split joint attention that matches unsplit attention.

• Step caching around compiled denoisers, with or without a device probe.

• A resident model process that serves five image and video models.

Figure

Figure 1. Model abstraction and Trainium adaptation in Difflet. (a) Pipelines specify component dataflow and configurations. (b) Component, operator, and parallelism interfaces connect models to (c) Trainium compilation and execution. Solid arrows denote dataflow; dashed arrows denote configuration and adaptation. NeuronCore icons are schematic.

References (29)