[Quantization] Support packed NVFP4 Qwen4Exp PLE embeddings (#56273)
Signed-off-by: Stefano Castagnetta <scastagnetta@nvidia.com> Co-authored-by: Kartikey Vyas <kartikey@artificialanalysis.ai>
This commit is contained in:
co-authored by
Kartikey Vyas
parent
87e7dce3a7
commit
4e0681ed56
@@ -45,6 +45,22 @@ def _e2m1_inline(nibble):
|
||||
return tl.where(sign == 1, -val, val)
|
||||
|
||||
|
||||
@triton.jit
|
||||
def _e4m3_inline(byte):
|
||||
"""Decode an FP8 E4M3FN byte to float32 without an FP8 pointer type.
|
||||
|
||||
Typed FP8 loads need SM89+ in Triton; reading the scale as uint8 and
|
||||
decoding here keeps the caller portable.
|
||||
"""
|
||||
bits = byte.to(tl.int32)
|
||||
exponent = (bits >> 3) & 0xF
|
||||
mantissa = (bits & 0x7).to(tl.float32)
|
||||
normal = (1.0 + mantissa * 0.125) * tl.exp2((exponent - 7).to(tl.float32))
|
||||
val = tl.where(exponent == 0, mantissa * 0.001953125, normal)
|
||||
val = tl.where((bits & 0x7F) == 0x7F, float("nan"), val)
|
||||
return tl.where((bits & 0x80) != 0, -val, val)
|
||||
|
||||
|
||||
@triton.jit
|
||||
def _nvfp4_gathered_bias_kernel(
|
||||
markov_ptr,
|
||||
|
||||
Reference in New Issue
Block a user