-
Notifications
You must be signed in to change notification settings - Fork 187
docs: explain FP8 format suffixes (e4m3fn, e5m2, e8m0fnu) in startup flags page #1313
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
lin-bot23
wants to merge
1
commit into
Comfy-Org:main
Choose a base branch
from
lin-bot23:analytics-fix/2026-07-22-fp8-format-explanation
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: Comfy-Org/docs
Length of output: 427
🏁 Script executed:
Repository: Comfy-Org/docs
Length of output: 50371
🌐 Web query:
NVIDIA FP8 formats e4m3fn e5m2 sign exponent mantissa bits💡 Result:
NVIDIA FP8 formats consist of two distinct 8-bit floating-point encodings, E4M3 and E5M2, both designed for efficient deep learning workloads [1][2]. Each format is comprised of a single sign bit, a specific number of exponent bits, and a set number of mantissa bits [1][3]. The bit breakdown for these formats is as follows: E4M3 (E4M3FN) 1 sign bit, 4 exponent bits, and 3 mantissa bits [1][4]. This format prioritizes precision and is typically used for weights and activations in the forward pass [1][5]. It does not support infinities and has a limited set of NaN patterns to extend its dynamic range [1]. E5M2 1 sign bit, 5 exponent bits, and 2 mantissa bits [1][4][3]. This format provides a wider dynamic range at the cost of lower precision [5][2]. It is often used for gradients in the backward pass, where magnitude variations are more significant [1][5]. It follows IEEE 754 conventions for special values, including infinities [1][2]. Summary Table Format | Sign Bits | Exponent Bits | Mantissa Bits | Total Bits --- | --- | --- | --- | --- E4M3 | 1 | 4 | 3 | 8 E5M2 | 1 | 5 | 2 | 8 Note: In technical documentation, the "mantissa" bits refer to the explicit significand bits, excluding the implicit leading bit common in IEEE 754-style floating-point numbers [6][3].
Citations:
🌐 Web query:
"e8m0fnu" FP8 PyTorch sign bits E8M0fn2 "0-8-0"💡 Result:
The term E8M0 refers to a specialized 8-bit format primarily used for block-scaling factors in low-precision matrix multiplication, rather than as a general-purpose floating-point data type for activations or weights [1][2]. Key technical characteristics of E8M0/E8M0fnu include: Format Definition: The E8M0 format consists of 8 exponent bits and 0 mantissa bits (an unsigned 8-bit floating-point representation) [3][2]. It is interpreted as powers of two with a biased exponent [4]. Technical Specifications: - Exponent: 8 bits [3]. - Mantissa: 0 bits [3]. - Exponent Bias: 127 [4][3]. - NaN (Not a Number): Represented by the bit pattern 0xFF (255) [4][3]. - "FNU": The suffix "fnu" stands for "finite," "no sign," and "unsigned" (or "no-sign"), indicating that the format does not support negative values, infinities, or specialized sign-bit encodings [3][2]. - Use Case: It is frequently utilized as a scale factor type in micro-scaling (MXFP) operations, where it encodes the scaling factors for underlying FP8 or FP4 tensor data (e.g., E4M3FN weights) [1][5][2]. In software implementations such as vLLM and various CUDA math APIs, this format is often referred to as float8_e8m0fnu [1][6][4]. Because it lacks a sign bit and mantissa, it acts strictly as an exponent-based scale, allowing for efficient range adjustment in block-quantized kernels [7][2].
Citations:
🌐 Web query:
ComfyUI --fp8_e8m0fnu-unet fp8_e8m0fnu unet💡 Result:
In ComfyUI,
--fp8_e8m0fnu-unetis a command-line argument used to store UNET model weights in thefp8_e8m0fnudata format [1][2]. Thefp8_e8m0fnuformat (8-bit floating-point with 8 exponent bits, no mantissa, and no sign bit) is a technical data type often utilized as a scale factor for quantization, such as in MXFP (Microscaling Formats) [3]. Key technical context regarding this flag and FP8 in ComfyUI: 1. Purpose: Like other--fp8-unetflags (e.g.,e4m3fnore5m2), this argument is designed to reduce the VRAM footprint of the model during inference [4][1]. 2. Implementation: ComfyUI supports multiple FP8 variants [4]. When using these flags, the application typically converts model weights to the specified FP8 format upon loading, eliminating the need to download separate, pre-quantized FP8 checkpoints [4]. 3. Status: The--fp8_e8m0fnu-unetoption was merged into ComfyUI to provide additional flexibility in weight storage [5][2]. However, users should be aware that different FP8 formats may have varying impacts on model output quality or compatibility depending on the specific model architecture being used [4][5]. If you encounter errors or performance issues, standard formats likee4m3fnare often the recommended default [4].Citations:
🌐 Web query:
Python pytorch fp8_e8m0fnu dtype PyTorch💡 Result:
In PyTorch,
at::kFloat8_e8m0fnu(ortorch.float8_e8m0fnu) exists primarily as a specialized internal data type used in low-level CUDA operations for scaling factors [1][2]. It is not typically exposed as a standard, high-level tensor data type for general model weights or arithmetic in the same way asfloat32orbfloat16[3][4]. TheE8M0FNUformat is an 8-bit floating-point representation with an 8-bit exponent, no mantissa, and no sign bit [5][6]. It is specifically designed for use as a scaling factor in microscaling (MX) formats, such as those used in scaled matrix multiplication (scaled_mm) operations [1][7][5][8]. Key points regarding its presence and use: - Internal Usage: It appears in PyTorch's internal C++ implementation, specifically withinScaledBlas.cpp, to support block-wise scaling in specialized matrix multiplication kernels [1][2]. - Functionality: It is used to define the format of scale tensors when performing operations with other low-precision types (like FP8 or FP4) [1]. - Documentation: While it is referenced in technical implementations and internal ATen headers, it is generally not listed in the standard public-facing documentation for tensor attributes (e.g., intorch.dtypeenumerations available for end-user code) [1][9][3]. If you encounter this type, it is likely within the context of hardware-specific optimizations or advanced quantization research (such as MXFP) where explicit control over scale tensor formats is required [7][5][8].Citations:
Correct the FP8 definitions and remove em dashes.
e4m3fnande5m2are 1-sign-bit NVIDIA FP8 encodings, note4+m3ore5+m2.e8m0fnuhas no sign bit and is an unsigned scale-like FP8 encoding, so describing it as “IEEE-compatible” misses the key distinction. Keep the MDX short and dash-free.🤖 Prompt for AI Agents
Source: Coding guidelines