swift15: BF16 absmax bits belong in the HIGH half of the float32
This commit is contained in:
1 parent
d062a376b2
commit
3e46d51df8
1 file changed
+3
-3
@@ -57,9 +57,9 @@ for fname, keys in sorted(shards.items()):
|
||||
gfile = k
|
||||
mm.close()
|
||||
|
||||
# rebuild the BF16 value from the sign-cleared uint16 bit pattern
|
||||
absmax = np.frombuffer(np.uint16(gmax).tobytes() + b"\x00\x00",
|
||||
dtype=np.float32)[0]
|
||||
# rebuild the BF16 value: the 16 bits are the HIGH half of the float32
|
||||
absmax = np.frombuffer(b"\x00\x00" + np.uint16(gmax).tobytes(),
|
||||
dtype=np.float32)[0]
|
||||
cap = FP8_E4M3_MAX * SCALE
|
||||
print(f"absmax = {absmax!r} (tensor: {gfile})")
|
||||
print(f"2^log2 = 2^{math.log2(absmax):.3f}")
|
||||
|
||||
Reference in new issue
Block a user