GNU bug report logs -
#68871
Can't use od to print half-precision floats
Previous Next
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 68871 in the body.
You can then email your comments to 68871 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-coreutils <at> gnu.org
:
bug#68871
; Package
coreutils
.
(Thu, 01 Feb 2024 14:28:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
"Rozenberg, Eyal (Consultant)" <Eyal.Rozenberg <at> gehealthcare.com>
:
New bug report received and forwarded. Copy sent to
bug-coreutils <at> gnu.org
.
(Thu, 01 Feb 2024 14:28:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
If I try to use the od utility to print half-precision (FP16) floating-point values, I get:
$ od -t f2 myfloats.bin
od: invalid type string 'f2';
this system doesn't provide a 2-byte floating point type
I'm not exactly sure what "this system" means, but that should work and print out my floats.
Eyal
PS - This is my first bug-coreutils post, please be gentle.
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#68871
; Package
coreutils
.
(Thu, 01 Feb 2024 18:06:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 68871 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On 01/02/2024 12:43, Rozenberg, Eyal (Consultant) wrote:
> If I try to use the od utility to print half-precision (FP16) floating-point values, I get:
>
> $ od -t f2 myfloats.bin
> od: invalid type string 'f2';
> this system doesn't provide a 2-byte floating point type
>
> I'm not exactly sure what "this system" means, but that should work and print out my floats.
>
> Eyal
>
> PS - This is my first bug-coreutils post, please be gentle.
I just had a read of these:
https://gcc.gnu.org/onlinedocs/gcc/Half-Precision.html
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0192r4.html
On the face of it it seems that various 16 bit floating point formats have consolidated,
and we could add support for _Float16 in od.
I see gnulib already enables __STDC_WANT_IEC_60559_TYPES_EXT__
so we should be able to do something like the attached.
This is just off the top of my head, and I haven't tested
or thought about this much at all.
Any testing your could do would be appreciated.
thanks,
Pádraig
[od-f16.patch (text/x-patch, attachment)]
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#68871
; Package
coreutils
.
(Thu, 01 Feb 2024 19:09:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 68871 <at> debbugs.gnu.org (full text, mbox):
Thanks for writing that. One suggestion I'd make is to change this:
#ifndef FLT16_MAX
/* This is just a place-holder to avoid a few '#if' directives.
In this case, the type isn't actually used. */
typedef float _Float16;
#endif
to something like this:
#ifdef FLT16_MAX
typedef _Float16 float16;
#else
/* This is just a place-holder to avoid a few '#if' directives.
In this case, the type isn't actually used. */
typedef float float16;
#endif
and use 'float16' thereafter. That way, the code doesn't usurp the
system namespace on older platforms, some of which might define _Float16
but not FLT16_MAX.
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#68871
; Package
coreutils
.
(Thu, 01 Feb 2024 19:18:01 GMT)
Full text and
rfc822 format available.
Message #14 received at 68871 <at> debbugs.gnu.org (full text, mbox):
Oh, and another thought: suppose someone wants to use od on bfloat16_t
values? They're popular in machine learning applications, and likely
will be more popular than float16_t overall. See:
https://sourceware.org/pipermail/libc-alpha/2024-February/154382.html
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#68871
; Package
coreutils
.
(Thu, 01 Feb 2024 22:00:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 68871 <at> debbugs.gnu.org (full text, mbox):
On 01/02/2024 19:16, Paul Eggert wrote:
> Oh, and another thought: suppose someone wants to use od on bfloat16_t
> values? They're popular in machine learning applications, and likely
> will be more popular than float16_t overall. See:
>
> https://sourceware.org/pipermail/libc-alpha/2024-February/154382.html
True. I suppose we would select between these like:
-t f2, -t fh = IEEE half precision
-t fb = brain floating point
bfloat16 looks like a truncated single precision IEEE,
so we should be able to just pad the extra 16 bits with zeros
when converting to single precision internally for processing.
cheers,
Pádraig
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#68871
; Package
coreutils
.
(Fri, 02 Feb 2024 01:48:01 GMT)
Full text and
rfc822 format available.
Message #20 received at 68871 <at> debbugs.gnu.org (full text, mbox):
On 2/1/24 13:59, Pádraig Brady wrote:
>
> bfloat16 looks like a truncated single precision IEEE,
> so we should be able to just pad the extra 16 bits with zeros
> when converting to single precision internally for processing.
Sounds good. This would mean od could work even the platform doesn't
support bfloat16_t, since od.c could fall back on the above code (though
I suppose it could be endianness-dependent).
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#68871
; Package
coreutils
.
(Fri, 02 Feb 2024 14:36:01 GMT)
Full text and
rfc822 format available.
Message #23 received at 68871 <at> debbugs.gnu.org (full text, mbox):
Seems ok to me as a user. Note also that there is the TF32 format (tf for tensor-float), which takes up 32 bits, but only uses 19. So, the switches could be:
-t f2 IEEE half
-t fh IEEE half
-t fb brain
-t ft tensor
or
-t ft4 tensor
(which indicates the 32-bitness)
Eyal
-----Original Message-----
From: Paul Eggert <eggert <at> cs.ucla.edu>
Sent: Friday, 2 February 2024 3:47
To: Pádraig Brady <P <at> draigBrady.com>; Rozenberg, Eyal (Consultant) <Eyal.Rozenberg <at> gehealthcare.com>; 68871 <at> debbugs.gnu.org
Subject: Re: bug#68871: Can't use od to print half-precision floats
WARNING: This email originated from outside of GE HealthCare. Please validate the sender's email address before clicking on links or attachments as they may not be safe.
On 2/1/24 13:59, Pádraig Brady wrote:
>
> bfloat16 looks like a truncated single precision IEEE, so we should be
> able to just pad the extra 16 bits with zeros when converting to
> single precision internally for processing.
Sounds good. This would mean od could work even the platform doesn't support bfloat16_t, since od.c could fall back on the above code (though I suppose it could be endianness-dependent).
Reply sent
to
Pádraig Brady <P <at> draigBrady.com>
:
You have taken responsibility.
(Sun, 04 Feb 2024 15:01:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
"Rozenberg, Eyal (Consultant)" <Eyal.Rozenberg <at> gehealthcare.com>
:
bug acknowledged by developer.
(Sun, 04 Feb 2024 15:01:02 GMT)
Full text and
rfc822 format available.
Message #28 received at 68871-done <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On 02/02/2024 01:47, Paul Eggert wrote:
> On 2/1/24 13:59, Pádraig Brady wrote:
>>
>> bfloat16 looks like a truncated single precision IEEE,
>> so we should be able to just pad the extra 16 bits with zeros
>> when converting to single precision internally for processing.
>
> Sounds good. This would mean od could work even the platform doesn't
> support bfloat16_t, since od.c could fall back on the above code (though
> I suppose it could be endianness-dependent).
I see that __bf16 is supported by released versions of gcc and clang,
so rather than add conversion complexity to the core od print loop,
the attached relies on compiler support for _Float16 and __bf16 types,
which compilers will expand to more targets going forward.
I tested the attached on:
gcc 13, clang 17 x86 (Both types supported)
gcc 7 aarch64 (Only -fH supported)
gcc 13 ppc(be) (Neither supported (both will be with GCC 14))
I'll commit this later.
Marking this bug as done.
thanks,
Pádraig
[od-half-float.patch (text/x-patch, attachment)]
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#68871
; Package
coreutils
.
(Sun, 04 Feb 2024 22:00:02 GMT)
Full text and
rfc822 format available.
Message #31 received at 68871 <at> debbugs.gnu.org (full text, mbox):
Thanks. One minor comment about this:
> +@item B
> +brain 16 bit float
> +@item H
> +half precision float
It might be helpful explain these two formats, e.g., to cite:
https://en.wikipedia.org/wiki/Bfloat16_floating-point_format
and
https://en.wikipedia.org/wiki/Half-precision_floating-point_format
respectively, since the formats are new compared to the other formats
being discussed.
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#68871
; Package
coreutils
.
(Mon, 05 Feb 2024 13:38:01 GMT)
Full text and
rfc822 format available.
Message #34 received at 68871 <at> debbugs.gnu.org (full text, mbox):
On 04/02/2024 21:59, Paul Eggert wrote:
> Thanks. One minor comment about this:
>
>> +@item B
>> +brain 16 bit float
>> +@item H
>> +half precision float
>
> It might be helpful explain these two formats, e.g., to cite:
>
> https://en.wikipedia.org/wiki/Bfloat16_floating-point_format
>
> and
>
> https://en.wikipedia.org/wiki/Half-precision_floating-point_format
>
> respectively, since the formats are new compared to the other formats
> being discussed.
Good call.
I added those references and pushed.
cheers,
Pádraig.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Tue, 05 Mar 2024 12:24:14 GMT)
Full text and
rfc822 format available.
This bug report was last modified 1 year and 162 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.