Repository navigation
Conversation
Add a grouped BF16-to-FP8 kernel for compatible matrices with a common K and variable M, producing both rowwise and columnwise GEMM-ready outputs. Specialize output modes and use packed BF16x2 amax operations. Select the optimized path automatically through existing quantization APIs, preserving fallback behavior for unsupported configurations. Document the dispatch control and add coverage for boundary shapes, empty tensors, fallbacks, and CUDA Graph replay.
Compile the grouped kernel body for lower PTX targets while retaining runtime dispatch on Hopper. Clarify that CUDA Graph replay uses captured shapes and buffer addresses. Add special-value equivalence tests for packed BF16 amax and vary matrix width independently of power-of-two scaling.
[Medium impact] The PR appears safe to merge; no actionable issues were found. SummaryAdds automatic grouped BF16-to-FP8 blockwise quantization on Hopper for compatible split and multi-tensor calls.
No actionable issues found. GPU tests were not run during this review. Reviews (1) · Last reviewed commit: "Fix grouped FP8 quantization PTX compati..." · Reviewed by Greptile |
|
Hi @anaruse — appreciate the contribution but we've already enabled this feature with the following set of PRs: #3135 — Grouped-quantize kernels for 1D and 2D FP8 block-scaling (Hopper-only) We also have #3866 currently being reviewed for across-the-board performance optimizations for FP8 block-scaling on Blackwell for both non-grouped and grouped use cases. I believe these should be providing full coverage of the functionality you need for grouped FP8BS on Hopper right now, but please let me know if there is anything missing that we may have overlooked. I am closing this PR for now as duplicate functionality. |
Description
Optimize BF16-to-FP8 1D blockwise quantization on Hopper by processing multiple matrices in a single kernel launch. Eligible calls through the existing split and multi-tensor APIs use this path automatically, without public API changes.
Type of change
Changes
Batch matrices with a common K and variable M into grouped launches.
Specialize output modes at compile time and use packed BF16x2 operations for local amax.
Support E4M3/E5M2, empty tensors, partial tiles, and separate or bulk allocations.
The optimization requires both row-wise and column-wise GEMM-ready outputs. Other configurations retain their existing paths. Set
NVTE_FP8_BLOCK_QUANTIZATION_GROUPED=0to disable it.CUDA Graph replay requires fixed shapes and buffer addresses; input values may change in place.
Validation
Tested on H100:
Tests cover exact FP8 payload and valid inverse-scale comparisons, special values, scaling boundaries, fallback behavior, and CUDA Graph replay.
Lower-target PTX JIT execution on Hopper has not yet been validated. Test runs report an existing FlashAttention 4 version warning.
Performance
Measured on a H100 80GB HBM3 with CUDA Graph enabled. Inputs are BF16, outputs are FP8(E4M3), and each call produces both row-wise and column-wise outputs with a quantization block size of 128.
Times are mean GPU elapsed times for all 16 experts, from the start of the first quantization kernel to completion of the last.
Checklist: