News for hackers. Stuff that matters.
Re:Bfloat16 support coming to Apple's Metal and PyTorch [video] by dlewis1788 on Monday July 03, 2023 @02:06PM (#36576673)
Confirmed Apple M1 lacks bfloat16 support completely - M1: hw.optional.arm.FEAT_BF16: 0 vs M2: hw.optional.arm.FEAT_BF16: 1
Re:Bfloat16 support coming to Apple's Metal and PyTorch [video] by londons_explore on Monday July 03, 2023 @02:35PM (#36577102)
Luckily BF16 is just a truncated FP32. That means that the hardware can do BF16, just you don't get any performance benefit compared to FP32 (and depending on the hardware design, you might also have to space the data 4 bytes apart rather than 2), so you lose the memory bandwidth and RAM usage benefits too.
Re:Bfloat16 support coming to Apple's Metal and PyTorch [video] by pklausler on Monday July 03, 2023 @02:53PM (#36577337)
Conversions from IEEE-32 to BF16 don't round?
Re:Bfloat16 support coming to Apple's Metal and PyTorch [video] by londons_explore on Monday July 03, 2023 @02:58PM (#36577386)
I don't believe the standard defines it. I believe implementations truncate (ie. round towards zero).

Remember BF16 was invented specifically to be able to be backwards compatible with existing silicon - and pulling 2 bytes out of 4 is a far cheaper operation than any rounding.

Re:Bfloat16 support coming to Apple's Metal and PyTorch [video] by kelnos on Monday July 03, 2023 @05:25PM (#36579069)
Just to elaborate, as I was confused about this and had to look it up: BF16 is indeed designed to just be a truncated F32: you can grab the top 16 bits of a F32 value and it'll still "make sense": the sign bits are in the same place in both (unsurprisingly), and the exponent part of BF16 and F32 are both 8 bits. In the case of the mantissa, you end up grabbing the top 7 bits of the F32's 23-bit mantissa, so it all works out, as this will "round" the value toward zero.
Re:Bfloat16 support coming to Apple's Metal and PyTorch [video] by pclmulqdq on Monday July 03, 2023 @08:30PM (#36580646)
There's no standardized definition of BF16.
Re:Bfloat16 support coming to Apple's Metal and PyTorch [video] by sillysaurusx on Monday July 03, 2023 @03:19PM (#36577608)
At that point it’d be better to do everything in fp32. The hardware can’t do bf16 in the way you’re saying; the conversions would consume all your time.
Re:Bfloat16 support coming to Apple's Metal and PyTorch [video] by BooneJS on Monday July 03, 2023 @04:00PM (#36578026)
Compute in F32, but then round and pack a pair of BF16 into 4 bytes.
Re:Bfloat16 support coming to Apple's Metal and PyTorch [video] by brrrrrm on Tuesday July 04, 2023 @01:40AM (#36582619)
The conversions are just a mask and shift? Super cheap
Re:Bfloat16 support coming to Apple's Metal and PyTorch [video] by stephencanon on Monday July 03, 2023 @11:34PM (#36581885)
You still get a perf benefit from half the memory traffic and keeping twice as much data in caches, since you can do the expansion to f32 when loading into registers.