Support SaturatedToLargestFloat8NormalConversionEXT decoration#3767
Conversation
Add round-trip handling for `SPV_EXT_float8`'s saturating FP-to-FP8 conversion. At the LLVM IR level it is represented via `_sat` suffix on the existing `__builtin_spirv_Convert<Src>To<E4M3|E5M2>EXT` interface. When `_sat` is present, the resulting OpFConvert is decorated with `SaturatedToLargestFloat8NormalConversionEXT`. AI-assisted: Claude Opus 4.7 (commercial SaaS)
Shouldn't it be |
I believe it can be both, wanted to publish this for discussion to choose the preferrable one. |
|
I'd not create instances without necessity :) |
Address review feedback on the previous commit: instead of introducing a `_sat` suffix on `__builtin_spirv_Convert<Src>To<E4M3|E5M2>EXT`, reuse the existing `__builtin_spirv_ClampConvert<Src>To<E4M3|E5M2>INTEL` interface from `SPV_INTEL_fp_conversions`. When `SPV_EXT_float8` is enabled, those four FP8-result entries are now emitted as `OpFConvert` decorated with `SaturatedToLargestFloat8NormalConversionEXT` instead of `OpClampConvertFToFINTEL`, and round-trip back to the same builtin names. The reverse translator also rejects modules where this decoration targets a non-FP8 conversion: per spec it may only decorate `OpFConvert`/`OpConvertSToF`/`OpConvertUToF` with an `Float8E4M3EXT` or `Float8E5M2EXT` Result Type, and `spirv-val` does not enforce this yet. AI-assisted: Claude Opus 4.7 (commercial SaaS)
|
CI failures are caused by |
MrSidims
left a comment
There was a problem hiding this comment.
Fine with me, but if I were you - I'd get someone from Intel to approve :)
| bool IsSaturatedFP8 = | ||
| FPDesc.ConvOpCode == internal::OpClampConvertFToFINTEL && | ||
| (FPDesc.DstEncoding == FPEncodingWrap::E4M3 || | ||
| FPDesc.DstEncoding == FPEncodingWrap::E5M2) && | ||
| BM->isAllowedToUseExtension(ExtensionID::SPV_EXT_float8); |
There was a problem hiding this comment.
When SPV_INTEL_fp_conversions is enabled, the writer used to emit OpClampConvertFToFINTEL for __builtin_spirv_ClampConvert<...>To<E4M3|E5M2>INTEL. With this PR the writer always rewrites to OpFConvert + SaturatedToLargestFloat8NormalConversionEXT. There's no longer a way to ask the translator to emit OpClampConvertFToFINTEL with an FP8 result type.
Is that intended?
If SPV_EXT_float8 is meant to supersede SPV_INTEL_fp_conversions for FP8 destinations, please call that out in PR description.
There was a problem hiding this comment.
Nice catch, I was a bit rush to change the behavior. Restored the behavior for SPV_INTEL_fp_conversions in a577c55 so SPV_EXT_float8 does not supersede
There was a problem hiding this comment.
With this PR the writer always rewrites to OpFConvert + SaturatedToLargestFloat8NormalConversionEXT. There's no longer a way to ask the translator to emit OpClampConvertFToFINTEL with an FP8 result type.
Is it bad?
There was a problem hiding this comment.
My intent is to simplify this very change to have the decoration support from the multi-vendor extension.
I'd prefer to resolve any collisions with the INTEL extension in a separate PR when we clarify our spec changes
There was a problem hiding this comment.
If
SPV_EXT_float8is meant to supersedeSPV_INTEL_fp_conversionsfor FP8 destinations, please call that out in PR description.
I think we do want SPV_EXT_float8 to supersede SPV_INTEL_fp_conversions. Before @bashbaug went on vacation, he updated the draft SPV_INTEL_fp_conversions to remove the overlapping parts like OpClampConvertFToFINTEL. Therefore, we shouldn't be emitting those instructions.
It would be nice to get this change into the SPRIV Translator before merging intel/llvm#21568, so that we don't have compiled SYCL applications using the outdated OpClampConvertFToFINTEL, etc. instructions.
There was a problem hiding this comment.
I talked to @YuriPlyakhin offline. If you want to make the change that causes SPV_EXT_float8 to supersede SPV_INTEL_fp_conversions in a separate PR, that's OK with me. I only wanted to say that we should have this as a goal. I don't mind if it happens in a separate PR.
- Preserve SPV_INTEL_fp_conversions encoding when both extensions are
enabled: keep emitting OpClampConvertFToFINTEL for the
ClampConvert<Src>To<E4M3|E5M2>INTEL builtins. The OpFConvert +
SaturatedToLargestFloat8NormalConversionEXT encoding is emitted only
when SPV_EXT_float8 is enabled and SPV_INTEL_fp_conversions is not.
- Reader: scope the ClampConvertFToFINTEL rmap rewrite to OpFConvert.
The decoration is also valid on OpConvertSToF/OpConvertUToF, but
there is no {Integer, E4M3/E5M2, OpClampConvertFToFINTEL} entry in
the FP-conversions encoding map; restricting the rewrite avoids an
rmap assert on integer-source conversions.
- Drop a comment that duplicated the error message text.
AI-assisted: Claude Opus 4.7 (commercial SaaS)
| @@ -0,0 +1,56 @@ | |||
| ; Clamping FP-to-FP8 conversions: when SPV_EXT_float8 is enabled, the | |||
There was a problem hiding this comment.
nit
| ; Clamping FP-to-FP8 conversions: when SPV_EXT_float8 is enabled, the | |
| ; Clamping FP-to-FP8 conversions: when SPV_EXT_float8 is enabled and SPV_INTEL_fp_conversions is not, the |
…` decoration (KhronosGroup#3767) Add round-trip handling for `SPV_EXT_float8`'s saturating FP-to-FP8 conversion. At the LLVM IR level it is represented via `_sat` suffix on the existing `__builtin_spirv_Convert<Src>To<E4M3|E5M2>EXT` interface. When `_sat` is present, the resulting `OpFConvert` is decorated with `SaturatedToLargestFloat8NormalConversionEXT`. AI-assisted: Claude Opus 4.7 (commercial SaaS)
…` decoration (KhronosGroup#3767) Add round-trip handling for `SPV_EXT_float8`'s saturating FP-to-FP8 conversion. At the LLVM IR level it is represented via `_sat` suffix on the existing `__builtin_spirv_Convert<Src>To<E4M3|E5M2>EXT` interface. When `_sat` is present, the resulting `OpFConvert` is decorated with `SaturatedToLargestFloat8NormalConversionEXT`. AI-assisted: Claude Opus 4.7 (commercial SaaS)
…` decoration (KhronosGroup#3767) Add round-trip handling for `SPV_EXT_float8`'s saturating FP-to-FP8 conversion. At the LLVM IR level it is represented via `_sat` suffix on the existing `__builtin_spirv_Convert<Src>To<E4M3|E5M2>EXT` interface. When `_sat` is present, the resulting `OpFConvert` is decorated with `SaturatedToLargestFloat8NormalConversionEXT`. AI-assisted: Claude Opus 4.7 (commercial SaaS)
…` decoration (#3767) Add round-trip handling for `SPV_EXT_float8`'s saturating FP-to-FP8 conversion. At the LLVM IR level it is represented via `_sat` suffix on the existing `__builtin_spirv_Convert<Src>To<E4M3|E5M2>EXT` interface. When `_sat` is present, the resulting `OpFConvert` is decorated with `SaturatedToLargestFloat8NormalConversionEXT`. AI-assisted: Claude Opus 4.7 (commercial SaaS)
…` decoration (#3767) Add round-trip handling for `SPV_EXT_float8`'s saturating FP-to-FP8 conversion. At the LLVM IR level it is represented via `_sat` suffix on the existing `__builtin_spirv_Convert<Src>To<E4M3|E5M2>EXT` interface. When `_sat` is present, the resulting `OpFConvert` is decorated with `SaturatedToLargestFloat8NormalConversionEXT`. AI-assisted: Claude Opus 4.7 (commercial SaaS)
…` decoration (#3767) Add round-trip handling for `SPV_EXT_float8`'s saturating FP-to-FP8 conversion. At the LLVM IR level it is represented via `_sat` suffix on the existing `__builtin_spirv_Convert<Src>To<E4M3|E5M2>EXT` interface. When `_sat` is present, the resulting `OpFConvert` is decorated with `SaturatedToLargestFloat8NormalConversionEXT`. AI-assisted: Claude Opus 4.7 (commercial SaaS)
…` decoration (#3767) Add round-trip handling for `SPV_EXT_float8`'s saturating FP-to-FP8 conversion. At the LLVM IR level it is represented via `_sat` suffix on the existing `__builtin_spirv_Convert<Src>To<E4M3|E5M2>EXT` interface. When `_sat` is present, the resulting `OpFConvert` is decorated with `SaturatedToLargestFloat8NormalConversionEXT`. AI-assisted: Claude Opus 4.7 (commercial SaaS)
…` decoration (#3767) Add round-trip handling for `SPV_EXT_float8`'s saturating FP-to-FP8 conversion. At the LLVM IR level it is represented via `_sat` suffix on the existing `__builtin_spirv_Convert<Src>To<E4M3|E5M2>EXT` interface. When `_sat` is present, the resulting `OpFConvert` is decorated with `SaturatedToLargestFloat8NormalConversionEXT`. AI-assisted: Claude Opus 4.7 (commercial SaaS)
…` decoration (#3767) Add round-trip handling for `SPV_EXT_float8`'s saturating FP-to-FP8 conversion. At the LLVM IR level it is represented via `_sat` suffix on the existing `__builtin_spirv_Convert<Src>To<E4M3|E5M2>EXT` interface. When `_sat` is present, the resulting `OpFConvert` is decorated with `SaturatedToLargestFloat8NormalConversionEXT`. AI-assisted: Claude Opus 4.7 (commercial SaaS)
…` decoration (#3767) Add round-trip handling for `SPV_EXT_float8`'s saturating FP-to-FP8 conversion. At the LLVM IR level it is represented via `_sat` suffix on the existing `__builtin_spirv_Convert<Src>To<E4M3|E5M2>EXT` interface. When `_sat` is present, the resulting `OpFConvert` is decorated with `SaturatedToLargestFloat8NormalConversionEXT`. AI-assisted: Claude Opus 4.7 (commercial SaaS)
…` decoration (#3767) Add round-trip handling for `SPV_EXT_float8`'s saturating FP-to-FP8 conversion. At the LLVM IR level it is represented via `_sat` suffix on the existing `__builtin_spirv_Convert<Src>To<E4M3|E5M2>EXT` interface. When `_sat` is present, the resulting `OpFConvert` is decorated with `SaturatedToLargestFloat8NormalConversionEXT`. AI-assisted: Claude Opus 4.7 (commercial SaaS)
…` decoration (#3767) Add round-trip handling for `SPV_EXT_float8`'s saturating FP-to-FP8 conversion. At the LLVM IR level it is represented via `_sat` suffix on the existing `__builtin_spirv_Convert<Src>To<E4M3|E5M2>EXT` interface. When `_sat` is present, the resulting `OpFConvert` is decorated with `SaturatedToLargestFloat8NormalConversionEXT`. AI-assisted: Claude Opus 4.7 (commercial SaaS)
Add round-trip handling for
SPV_EXT_float8's saturating FP-to-FP8 conversion.At the LLVM IR level it is represented via
_satsuffix on the existing__builtin_spirv_Convert<Src>To<E4M3|E5M2>EXTinterface. When_satis present, the resulting OpFConvert is decorated withSaturatedToLargestFloat8NormalConversionEXT.AI-assisted: Claude Opus 4.7 (commercial SaaS)