{"slug": "optimizing-video-diffusion-models-by-utilizing-end-to-end-nvfp4-inference", "title": "Optimizing Video Diffusion Models by Utilizing End-to-End NVFP4 Inference", "summary": "A new end-to-end NVFP4 inference recipe for video diffusion models, built with NVIDIA Model Optimizer to selectively quantize linear layers to NVFP4 and SageAttention3 augmented with Hadamard rotation, runs 1.36x faster than FP8 linear layers and attention, with the FP4 attention kernel reaching 1.05 peta-ops. The Hadamard rotation addresses outliers along the channel dimension that mean smoothing alone cannot absorb when a channel's value and sign change from token to token, removing background drift and temporal artifacts from generated video.", "body_md": "[Blog](https://www.synthesia.io/blog)\n\n# Optimizing Video Diffusion Models by Utilizing End-to-End NVFP4 Inference\n\nCreate AI videos with 240+ avatars in 140+ languages\n\n### Key Takeaways\n\nIn this work, we present and end to end recipe for NVFP4 inference of video diffusion model, by using NVIDIA Model Optimizer to selectively quantise linear layers to NVFP4, and by augmenting the SageAttention3 algorithm with Hadamard rotation to outlier along the channel dimension to remove the background drift and temporal artefacts from the generated video. The FP4 attention kernel achieves a performance of 1.05 peta-ops, and the end to end speed up of the FP4 inference recipe is 1.36x faster than the FP8 linear layer and attention.\n\nVideo diffusion models generate data by learning how to undo noise given conditioning signals such as a prompt, audio and reference images that steer the video generation. They typically work by denoising one chunk at a time, which consists of multiple frames. The noise generated is first run through an encoder which compresses it into a latent space, passing that output to the denoising transformer, followed by a decoder.\n\nEven with the compression, because of large sequence lengths, a significant amount of time is spent in self-attention and linear layers of the model. It is thus of interest to minimize the latency to reduce the serving cost and obtain a better user experience.\n\n## The NVFP4 data type\n\nThe NVFP4 datatype has only 4 bits: 1 for the sign, 2 for the exponent and 1 mantissa bit, and can only represent 15 values. To mitigate the issues with this low dynamic range, the input is quantized such that every 16 elements share one 8-bit scale of the format e4m3. An additional FP32 scale is shared across the entire tensor to extend the range of the e4m3 block scales. Together, these scales are chosen such that the largest value maps to the largest value e2m1 can represent, i.e. 6. This works well when the numbers are in a similar range, but can lead to loss of information when there’s a lot of variance in the magnitude within a block.\n\n## **Combining Hadamard Rotation with SageAttention3** \n\nSageAttention3 (SA3) is a well known technique for using the NVFP4 datatype for video diffusion models. It quantises both matrix multiplications, QKᵀ and PV, so Q, K, V and the softmax probabilities P are all stored in NVFP4. It limits the errors from outliers in two ways. First, NVFP4's small 1×16 block quantisation granularity confines an outlier to the 16 values that share its scale. Second, it inherits mean smoothing from SageAttention 1 and 2. For tensors of shape [B, N, H, D] where the symbols have their usual meaning, it subtracts from K its mean over all L tokens, one value per channel and head. It subtracts from Q its mean over each block of consecutive tokens, of a certain block size b. The contribution of the subtracted Q mean is then added back to the attention scores; K smoothing needs no correction because softmax is invariant to a constant shift within each row.\n\nHowever, even with the small granularity of 1x16 it is possible that this window covers where the values have high variance which can lead to information loss. For example, consider the following values in the window, with the converted NVFP4 values, we use just 8 values for this demonstration, where 8 values share one scale. In this example we have 4 keys and 1 query token.\n\nWith SageAttention3, key 2 would be quantised as follows:\n\nHowever, this only works if the outlier is shared across the tokens. That however may not always be the case and the massive channel can change value and sign from token to token and mean smoothing no longer eliminates the same.\n\nConsider an example with a head dimension of 16, where the keys 0,1, 2 and 3 are abbreviated as K0, K1, K2 and K3 respectively, and query is abbreviated as Q.\n\nWith this distribution, because of the negative sign, mean smoothing is not enough to absorb the outliers, and the quantisation key 2 becomes as follows:\n\nAs it can be seen, quite a few of the values have been flushed to zero, leading to information loss. Moreover, running attention with such quantisation errors can also lead to the attention weight landing on the wrong key, as it can be seen below:\n\nWe solve this problem by adding a head-wise (i.e. along the D dimension) Hadamard rotation, which spreads this energy across these 1x16 blocks, prior to the quantisation of the Q, K and V tensors, and keep each key’s content in the quantised block. A Hadamard matrix is a square matrix made up of ±1 entries, who’s rows are mutually orthogonal.\n\nAnd hence we need not undo the rotation after the *QK<sup>T</sup>* before computing the softmax scores. The rotation of Q, K and V can be fused into the quantisation step, and the final rotation can be fused into the attention kernel, to keep the overhead at the minimum. The fusion of rotation into quantisation is not done as a part of this work. \n\nIt’s worth noting that Hadamard rotation does not substitute mean smoothing, but rather they act along different axes to enable FP4 quantisation of attention.\n\nMean smoothing subtracts each channel's average over the sequence. If an outlier is present in every token across the D dimension per head, that average is as large as the outlier itself, and subtracting it brings every token back to ordinary values before quantisation. If the outlier changes from token to token, for example in sign, its average is close to zero and smoothing removes nothing. The Hadamard rotation does not need the outlier to be shared: it works within each token, spreading the large value across all 128 channels so that no 1×16 block is dominated by it.\n\nGoing back to the 16 channel example above, the quantisation of the second key would look as follows, where the input is rotated and then mean smoothed prior to quantisation\n\nAnd the attention weights look as follows:\n\nAs it can be seen, the attention weight lands on the correct key with this method.\n\n## Results\n\nLooking at an attention output from the first layer, from the first denoising step from a real world use case, compared against BF16 attention, the Peak signal-to-noise ratio (PSNR) numbers are as follows, where the Hadamard rotation shows a 2.5 increase in the PSNR.\n\nTaking an example from a real world use case, the below diagram shows that Hadamard rotation reduces the drift in the static background and temporal flicker in videos as well. The first row shows a still from the video for context, and the image below, is a heatmap of the pixel level changes, which is obtained by averaging the absolute pixel difference across time.\n\nAs one expects, there is a lot of motion around the face and the body of the avatar, and the Hadamard rotation prevents drift from the static background, which is very evident in the base SA3 case evidenced by the vertical banding in the background.\n\nHadamard rotation also prevents a temporal flicker in the high frequency regions, as evidenced by the GIF below. It can be seen in the GIF, there is a tear in the high frequency regions of the Avatar. Here FP4(base) refers to using just the SageAttention3 algorithm.\n\n## **FP4 Attention Kernel** \n\nWe target the NVIDIA RTX PRO™ 6000 Blackwell Server Edition which has a compute capability of 12.0. We adapt the standard producer consumer model introduced by flash attention 3, where we have 2 warp-groups acting as the consumer. Each warp-group handles an output tile of 64 along the query / output length dimension.\n\nThe first 3 warps of the producer warp-group are responsible for bringing in the query and the KV Tiles of shape 128 along the KV length dimension. We use a 3 stage circular buffer of the KV tiles in shared memory, and a separate output staging buffer. The 3rd warp of the producer warp-group is the one responsible for storing the data back to global memory.\n\nThis ensures that the consumer warp-groups can immediately move onto the computation of the next tile, overlapping with the stores of the current one, after writing their output in shared memory. And as the layout allows for it, the result of the attention tile O can be un-rotated directly in registers by multiplying it with the H<sub>D</sub> as described above. The H<sub>D</sub> is materialised into registers on the fly, rather than statically allocating registers or carving out shared memory space for the same. \n\nWe feed both these matrices O and H<sub>D</sub> into the TF32 tensor core operation, and convert the result into BF16 before staging it in shared memory. The diagram below succinctly captures this pipeline. \n\nWe reach up to 1.05 Peta-OPs in attention performance on an RTX PRO 6000 Blackwell including the fused Hadamard un-rotation, with end-to-end (including quantisation and rotation), reaching around 910 TOPS, as summarised in the table below, for a head dimension of 128, and number of heads as 40.\n\n## **Guided Quantisation of Linear Layers using NVIDIA Model Optimizer** \n\nSecond to the self attention cost, Q, K and V projections and the feed forward neural networks occupy the most amount of time. It is thus also of interest to quantise this to NVFP4 (FP4 in short). However, not every layer can be quantised, different linear layers have different sensitivities, and treating every one the same can lead to catastrophic loss in quality, rendering the model unusable.\n\nTo quantify the error contribution of each layer, we use the NVIDIA Model-Optimizer tool (https:// github.com/NVIDIA/Model-Optimizer), which analyses the sensitivity of each layer in the model, and guides which can be quantised to NVFP4.\n\nBased on the sensitivity score threshold, we quantised **55%** of the linear layers into FP4, which represented 80% of the total linear layer FLOPs; the remaining linear layers are kept in FP8 precision. Also not all self-attention steps were run in NVFP4. We selected the ones which could be run in NVFP4 precision by only quantising one at a time, and measuring the impact on the error because of the same. \n\nFrom the diagram below, the initial and the latter parts of the model seem to be more sensitive to quantisation.\n\nWith this setup alongside NVFP4 attention, it de-noises 1.36x faster than FP8 inference mode and 2.39x faster than BF16 inference, while maintaining quality, which is summarised in the table below.\n\nIn the below diagram, one can notice the reduced background drift by selectively choosing the FP4 linear layers,\n\n## **Conclusion** \n\nIn this work, we present and end to end recipe for NVFP4 inference of video diffusion model, by using NVIDIA Model Optimizer to selectively quantise linear layers to NVFP4, and by augmenting the SageAttention3 algorithm with Hadamard rotation to outlier along the channel dimension to remove the background drift and temporal artefacts from the generated video. The FP4 attention kernel achieves a performance of 1.05 peta-ops, and the end to end speed up of the FP4 inference recipe is 1.36x faster than the FP8 linear layer and attention.\n\nAs a further extension of this work, this can be coupled with the work done in [Four Over Six (Cook et al., 2025)](<https:// arxiv.org/abs/2512.02010>). Four Over Six reduces NVFP4’s rounding error on values near the block maximum by choosing, per block, between scaling the maximum to either 6 or 4. The Hadamard rotation prevents small values next to an outlier from being erased, bringing the block to having values of similar magnitude, which is what Four Over Six targets. Integrating this is left to future work. \n\n*This article has been co-authored by research engineers James Briggs and Atharva Dubey.*", "url": "https://wpnews.pro/news/optimizing-video-diffusion-models-by-utilizing-end-to-end-nvfp4-inference", "canonical_source": "https://www.synthesia.io/post/optimising-video-diffusion-models-by-utilizing-end-to-end-nvfp4-inference", "published_at": "2026-12-01 10:09:59+00:00", "updated_at": "2026-12-01 10:47:08.636183+00:00", "lang": "en", "topics": ["artificial-intelligence", "machine-learning", "generative-ai", "ai-infrastructure", "computer-vision"], "entities": ["NVIDIA", "NVIDIA Model Optimizer", "SageAttention3", "NVFP4", "SageAttention"], "also_reported_by": [], "takeaway": "Quantize linear layers to NVFP4 with NVIDIA Model Optimizer and add Hadamard rotation to SageAttention3's mean smoothing to handle per-token channel outliers, yielding a 1.36x end-to-end speedup over FP8 and a 1.05 peta-ops FP4 attention kernel.", "recommendation": {"advice": "For video diffusion serving, quantize linear layers to NVFP4 and add Hadamard rotation to SageAttention3 before FP4 attention; the source measured 1.36x speedup over FP8 with background drift and temporal artifacts removed.", "playbook": "inference-serving", "playbook_url": "https://wpnews.pro/playbooks/inference-serving"}, "alternates": {"html": "https://wpnews.pro/news/optimizing-video-diffusion-models-by-utilizing-end-to-end-nvfp4-inference", "markdown": "https://wpnews.pro/news/optimizing-video-diffusion-models-by-utilizing-end-to-end-nvfp4-inference.md", "text": "https://wpnews.pro/news/optimizing-video-diffusion-models-by-utilizing-end-to-end-nvfp4-inference.txt", "jsonld": "https://wpnews.pro/news/optimizing-video-diffusion-models-by-utilizing-end-to-end-nvfp4-inference.jsonld"}}