We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents ba95b4e + fea5832 commit a97d162Copy full SHA for a97d162
2 files changed
src/hpc/gguf.rs
@@ -425,8 +425,11 @@ fn f16_to_f32(bits: u16) -> f32 {
425
e -= 1;
426
}
427
m &= 0x3FF;
428
- let f32_exp = (127i32 - 15 + 1 + e).max(0) as u32;
429
- let f32_bits = (sign << 31) | ((f32_exp & 0xFF) << 23) | (m << 13);
+ // f16 bias=15, f32 bias=127. Subnormal f16 has implicit exponent 1-15=-14.
+ // After normalizing mantissa (e shifts), f32 exponent = 127 + (1-15) + e = 113 + e.
430
+ // Minimum e = -10 (mantissa 0x001), giving f32_exp = 103. Always valid.
431
+ let f32_exp = (113 + e) as u32;
432
+ let f32_bits = (sign << 31) | (f32_exp << 23) | (m << 13);
433
return f32::from_bits(f32_bits);
434
435
if exp == 31 {
src/hpc/openchat/weights/openchat-3.5-0106.bgz7
40.6 MB
0 commit comments