Questions tagged [half-precision-float]

half-precision 16-bit floating point

Filter by
Sorted by
Tagged with
3 votes
0 answers
38 views

How to verify if the tensorflow code trains completely in FP16?

I'm trying to train a TensorFlow (version 2.11.0) code in float16. I checked that FP16 is supported on the RTX 3090 GPU. So, I followed the below link to train the whole code in reduced precision. ...
0 votes
1 answer
77 views

Can language model inference on a CPU, save memory by quantizing?

For example, according to https://cocktailpeanut.github.io/dalai/#/ the relevant figures for LLaMA-65B are: Full: The model takes up 432.64GB Quantized: 5.11GB * 8 = 40.88GB The full model won't fit ...
  • 30.7k
0 votes
0 answers
15 views

Deviation caused by half() in ptyroch

I have met a question that the value of a tensor is 6.3982e-2 in float32. After I changed it to float16 using half() function, it became 6.3965e-2. Will there be a method to convert tensor without ...
  • 13
0 votes
0 answers
55 views

What's the fastest way to convert a matrix tile from float to half in CUDA?

Computation with Tensor Cores requires that A and B matrix tiles are of type half. But I get float matrices as input, and I don't do enough multiplications to favor unfused matrix conversion in a ...
0 votes
0 answers
135 views

How do I know that Tensor Cores used in PyTorch (for FP16, bFloat16, INT8)?

From PyTorch documentation it is very to know if a model is using Tensor Cores or not (for FP16, bFloat16, INT8)?. What I know so far: FP32 will not run on Tensor Cores, since it is not supported ...
0 votes
1 answer
149 views

atomicAdd half-precision floating-point (FP16) on CUDA Compute Capability 5.2

I am trying to atomically add a float value to a __half in CUDA 5.2. This architecture does support the __half data type and its conversion functions, but it does not include any arithmetic and atomic ...
  • 30
0 votes
0 answers
116 views

Is there a reason why a nan value appears when there is no nan value in the model parameter?

I want to train the model with FP32 and perform inference with FP16. For other networks (ResNet) with FP16, it worked. But EDSR (super resolution) with FP16 did not work. The differences I found are ...
0 votes
1 answer
45 views

Can float16 data type save compute cycles while computing transcendental functions?

it's clearly that float16 can save bandwidth, but is float16 can save compute cycles while computing transcendental functions, like exp()?
38 votes
2 answers
5k views

Why is operating on Float64 faster than Float16?

I wonder why operating on Float64 values is faster than operating on Float16: julia> rnd64 = rand(Float64, 1000); julia> rnd16 = rand(Float16, 1000); julia> @benchmark rnd64.^2 ...
  • 4,795
0 votes
1 answer
73 views

What are vector division and multiplication as in CUDA __half2 arithmetic?

__device__​ __half2 __h2div ( const __half2 a, const __half2 b ) Description: Divides half2 input vector a by input vector b in round-to-nearest mode. __device__​ __half2 __hmul2 ( const __half2 a, ...
  • 420
0 votes
0 answers
60 views

How to round up or down when converting f32 to bf16 in rust?

I am converting from f32 to bf16 in rust, and want to control the direction of the rounding error. Is there an easy way to do this? Converting using the standard bf16::to_f32 rounds to the nearest ...
  • 868
4 votes
1 answer
54 views

float.h-like definitions for IEEE 754 binary16 half floats

I'm using half floats as implemented in the SoftFloat library (read: 100% IEEE 754 compliant), and, for the sake of completeness, I wish to provide my code with definitions equivalent to those ...
  • 810
0 votes
1 answer
423 views

Convert 16 bit hex value to FP16 in Python?

I'm trying to write a basic FP16 based calculator in python to help me debug some hardware. Can't seem to find how to convert 16b hex values unto floating point values I can use in my code to do the ...
  • 323
2 votes
2 answers
205 views

Double vs Float vs _Float16 (Running Time)

I have a simple question in C language. I am implementing a half-precision software using _Float16 in C (My mac is based on ARM), but running time is not quite faster than single or double-precision ...
4 votes
1 answer
288 views

Why does bfloat16 have so many exponent bits?

It's clear why a 16-bit floating-point format has started seeing use for machine learning; it reduces the cost of storage and computation, and neural networks turn out to be surprisingly insensitive ...
  • 30.7k
1 vote
1 answer
2k views

How to Enable Mixed precision training

i'm trying to train a deep learning model on vs code so i would like to use the GPU for that. I have cuda 11.6 , nvidia GeForce GTX 1650, TensorFlow-gpu==2.5.0 and pip version 21.2.3 for windows 10. ...
  • 23
-1 votes
2 answers
591 views

Why is it dangerous to convert integers to float16?

I have run recently into a surprising and annoying bug in which I converted an integer into a float16 and the value changed: >>> import numpy as np >>> np.array([2049]).astype(np....
  • 2,410
0 votes
2 answers
631 views

Bit shifting a half-float into a float

I have no choice but to read in 2 bytes that make up a half-float. I would like to work with this in the form of a 4 byte float. Ive done some research and the only thing I can come up with is bit ...
4 votes
1 answer
215 views

GCC: why cannot compile clean printf("%f\n", f16) under -std=c11 -Wall?

Sample code: #include <stdio.h> #define __STDC_WANT_IEC_60559_TYPES_EXT__ #include <float.h> #ifdef FLT16_MAX _Float16 f16; int main(void) { printf("%f\n", f16); return ...
  • 5,104
0 votes
1 answer
135 views

Declaring Half precision floating point memory in SYCL

I would like to know and understand how can one declare half-precision buffers and pointers in SYCL namely in the following ways - Via the buffer class. Using malloc_device() function. Also, suppose ...
1 vote
1 answer
1k views

Using Half Precision Floating Point on x86 CPUs

I intend to use half-precision floating-point in my code but I am not able to figure out how to declare them. For Example, I want to do something like the following- fp16 a_fp16; bfloat a_bfloat; ...
1 vote
1 answer
301 views

Reading a binary structure in Javascript

I have a table that I am trying to read in Javascript, with data that is large enough that I would like to have it in binary format to save space. Most of the table is either numbers or enums, but ...
4 votes
3 answers
1k views

How to correctly determine at compile time that _Float16 is supported?

I am trying to determine at compile time that _Float16 is supported: #define __STDC_WANT_IEC_60559_TYPES_EXT__ #include <float.h> #ifdef FLT16_MAX _Float16 f16; #endif Invocations: # gcc trunk ...
  • 5,104
4 votes
1 answer
2k views

How to select half precision (BFLOAT16 vs FLOAT16) for your trained model?

how will you decide what precision works best for your inference model? Both BF16 and F16 takes two bytes but they use different number of bits for fraction and exponent. Range will be different but I ...
  • 1,066
0 votes
1 answer
214 views

Convert ieee754 half-precision bytes to double and vise versa in Flutter

I have a device that provides temperature data in ieee754 half-precision float format, i.e. [78, 100] = +25.5C. Now, Dart/Flutter doesn't support HP-Float conversions out of the box. After googling ...
  • 546
1 vote
1 answer
2k views

Why does converting from np.float16 to np.float32 modify the value?

When converting a number from half to single floating representation I see a change in the numeric value. Here I have 65500 stored as a half precision float, but upgrading to single precision changes ...
  • 7,658
2 votes
0 answers
195 views

TensorFlow mixed precision training: Conv2DBackpropFilter not using TensorCore

I am using the keras mixed precision API in order to fit my networks in GPU. Typically in my code this will look like this. A MWE would be: from tensorflow.keras.mixed_precision import experimental as ...
2 votes
0 answers
836 views

Detecting support for __fp16

Since version 6, clang has supported a __fp16 type. I would like to use it, but I need to support other compilers (both clang-based and non-clang-based) as well as older versions of clang, so I need ...
  • 16.3k
2 votes
1 answer
432 views

CUDA half float operations without explicit intrinsics

I am using CUDA 11.2 and I use the __half type to do operations on 16 bit floating point values. I am surprised that the nvcc compiler will not properly invoke fused multiply add instructions when I ...
  • 7,078
0 votes
0 answers
151 views

How to Initialise 16-bit Half Floats (GAS for ARM32)?

When writing an ARM assembly program one can use data type directives to initialise some values. For example, in the example below we are initializing a single float: label: .single 0.0 However, when ...
  • 181
3 votes
1 answer
773 views

FLT_MAX for half floats

I am using CUDA with half floats, or __half as they are called in CUDA. What is the half-float equivalent of FLT_MAX? The cuda_fp16.h header does not seem to have a macro that resembles this. $ grep ...
  • 7,078
0 votes
0 answers
606 views

converting Golang float32 to half-precision float (GLSL float16) as uint16

I need to pass some data over from Go to an '300 es' shader. The data consists of two uint16s packed into a uint32. Each uint16 represents a half-precision float (float16). I found some PD Java ...
  • 388
2 votes
1 answer
776 views

Casting __fp16 to float fails to link on Clang 9

I need to read a file containing floating point numbers stored in binary16 format and convert them to float. Based on https://releases.llvm.org/9.0.0/tools/clang/docs/LanguageExtensions.html#half-...
1 vote
0 answers
82 views

Is there an implementation of Keras Adam Optimizer to support Float16

I am currently working with deploying tiny-yolov3 on openvino toolkit and for that i need to convert my model to float16. But for that I need an optimizer that supports FP16. I tried modifying SGD to ...
3 votes
1 answer
965 views

Gathering half-float values using AVX

Using AVX/AVX2 intrinsics, I can gather sets of 8 values, either 1,2 or 4 byte integers, or 4 byte floats using: _mm256_i32gather_epi32() _mm256_i32gather_ps() But currently, I have a case where I ...
  • 7,078
0 votes
1 answer
184 views

IEEE-754 Standard

I have an actually very easy question about the IEEE-754 standard in which numbers are coded and saved on the computer. At uni (exams) I have come across the following definition for 16-bit IEEE-754-...
2 votes
0 answers
326 views

How to keep the accuacy when convert a pytorch model to TensorRT in FP16 mode

I want to use TensorRT FP16 mode to accelerate my pytorch model, but there is a loss of precision. My question is how can I use the mixed precision training of pytorch, to avoid the loss of accuracy ...
  • 43
0 votes
1 answer
984 views

Converting Float32 to Float16

This is more a follow up to https://stackoverflow.com/a/5587983/13586005. @sam hocevar or anybody else who understands this: Would you mind explaining what is happening here: tmp = (tmp - 0x70) &...
1 vote
0 answers
537 views

Falling to use TensorCore from Tensorflow Mixed Precision Tutorial

I have followed the Mixed precision tutorial from Tensorflow: https://www.tensorflow.org/guide/keras/mixed_precision but apparently I fail to use TensorCore. My setup: Windows 10 Nvidia driver: 441....
0 votes
1 answer
1k views

Incomplete Cholesky Factorization Very Slow

Background: I'm doing a project for my Numerical Linear Algebra course. For this project I decided to experiment with doing incomplete cholesky factorization with half precision arithmetic and using ...
  • 195
2 votes
0 answers
147 views

Is there a way to test whether a target has native half-precision support in Clang?

Clang documentation says: _Float16 arithmetic will be performed using native half-precision support when available on the target (e.g. on ARMv8.2a); otherwise it will be performed at a higher ...
3 votes
0 answers
963 views

C++ support of _Float16 [duplicate]

I want to do half-precision floating-point computations on Jetson AGX Xavier(with armv8.2 architecture) which supports half-precision floating-point natively. As _Float16 data type is an arithmetic ...
  • 171
2 votes
2 answers
983 views

How to get the value of kCVPixelFormatType_DepthFloat16 (half-point float)?

I am working with a project on iOS front depth camera with swift. The media type is kCVPixelFormatType_DepthFloat16, half-point float at 640*360 dimension with 30fps according to apple documentation. ...
  • 51
1 vote
1 answer
261 views

How do I pass half to a vertex shader?

The D3D11 Input Element Description has a field that specifies the format. How can I pass halfs (e.g. DXGI_FORMAT_R16_FLOAT) to the Input assembler when we have float (i.e. 32 bit fp) only on the CPU ...
  • 3,227
1 vote
1 answer
172 views

Encoding Numbers into IEEE754 half precision

I have a quick question about a problem I'm trying to solve. For this problem, I have to convert (0.0A)16 into IEEE754 half precision floating point standard. I converted it to binary (0000.0000 1010),...
  • 31
2 votes
0 answers
219 views

fp16 support in the Object Detection API(tensorflow)

fp16 support in the Object Detection API [Feature request] · Issue #3706 · tensorflow/models https://github.com/tensorflow/models/issues/3706 I asked on the github issue: fp16 support in the Object ...
  • 62
0 votes
1 answer
2k views

Training with Keras/TensorFlow in fp16 / half-precision for RTX cards

I just got an RTX 2070 Super and I'd like to try out half precision training using Keras with TensorFlow back end. So far I have found articles like this one that suggest using this settings: import ...
3 votes
0 answers
137 views

math library for half-precision numbers [closed]

I want to use half-precision arithmetic on Cortex-A76. I installed clang compiler to use _Float16 data type (which is for 16-bit arithmetic purpose). I was wondering is there any library for half-...
  • 171
3 votes
0 answers
145 views

half-precision floating point numbers [duplicate]

I want to use half-precision floating-point numbers in c++ on an ARM processor. I want to use half-precision numbers for arithmetic purposes. I don't know how can I define half numbers in C++? Is ...
  • 171
2 votes
2 answers
1k views

how to do convolution with fp16(Eigen::half) on tensorflow

How can I use tensorflow to do convolution using fp16 on GPU? (the python api using __half or Eigen::half). I want to test a model with fp16 on tensorflow, but I got stucked. Actually, I found that ...