[Codegen][LLVMGPU] Lower FP8 elementwise extensions to NVVM - #24801
Open
weimin023 wants to merge 4 commits into
Open
[Codegen][LLVMGPU] Lower FP8 elementwise extensions to NVVM#24801weimin023 wants to merge 4 commits into
weimin023 wants to merge 4 commits into
Conversation
Signed-off-by: weimin023 <tnwilly@gmail.com>
Signed-off-by: weimin023 <tnwilly@gmail.com>
weimin023
marked this pull request as ready for review
August 13, 2026 10:30
weimin023
requested review from
Groverkss,
Max191,
krzysz00,
kuhar,
nirvedhmeshram and
qedawkins
as code owners
August 13, 2026 10:30
Signed-off-by: weimin023 <tnwilly@gmail.com>
krzysz00
reviewed
Aug 21, 2026
| bool hasInfinity; | ||
| }; | ||
|
|
||
| static Type getTypeWithElementType(Type type, Type elementType) { |
Contributor
There was a problem hiding this comment.
This already exists - it's one of the clone() methods. Or setElementType or the like, I'm pretty sure
Contributor
Author
There was a problem hiding this comment.
@krzysz00
Oh thanks! I inlined the scalar/vector type handling at the only use site and use VectorType::cloneWith for vectors, so the local helper is no longer needed.
Signed-off-by: weimin023 <tnwilly@gmail.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds a CUDA/NVVM lowering for general FP8-to-FP32 elementwise conversion.
This complements the existing FP8 Tensor Core MMA path.
The earlier work lowers supported FP8 matrix contractions through
nvgpu.mma.sync/nvvm.mma.sync;this change handles non-MMA conversion operations by decoding FP8 storage bits with regular LLVM integer operations and bitcasting the reconstructed IEEE-754 FP32 bits.
Fixes #24625.
Implementation
The failing tensor-level
stablehlo.convertis lowered to scalar/vectorarith.extfbefore the CUDA LLVM/NVVM conversion boundary. The custom pattern therefore matches only:At this boundary, LLVMTypeConverter represents the FP8 source operand as i8 storage (or vector). The lowering:
The specialized pattern has
PatternBenefit(2)and is registered before the generic Arith-to-LLVM patterns so that FP8 extensions use this software decode path. The implementation supports both scalar and vector operands.This does not add
arith.truncf(f32 -> f8) lowering or general FP8 arithmetic.mma.synclowering patharith.truncflowering with defined rounding, overflow, subnormal, and NaN semanticscreateFP8ToF32BitsThe decode rules below reflect the two formats handled by this PR.
In particular, E4M3FN is finite-number-only and does not encode infinity.
Previous failure
A StableHLO conversion (from #24625):
eventually reached CUDA final lowering as:
and failed during LLVM translation:
Testing