# CUDAnative support for Float16

**URL:** <https://discourse.julialang.org/t/cudanative-support-for-float16/17369>\
**Category:** GPU\
**Tags:** question\
**Created:** [November 9, 2018, 10:41pm UTC](https://discourse.julialang.org/t/cudanative-support-for-float16/17369 "2018-11-09T22:41:06Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![pedramz](https://avatars.discourse-cdn.com/v4/letter/p/ac8455/32.png) [@pedramz](https://discourse.julialang.org/u/pedramz)\
**Post date:** [November 9, 2018, 10:41pm UTC](https://discourse.julialang.org/t/cudanative-support-for-float16/17369/1 "2018-11-09T22:41:07Z")

</div>

I want to perform Float16 computation on GPU. In the vadd.jl example, when I change the rand function type from Float32 to Float16, the following error happens while running:

> ERROR: LoadError: InvalidIRError: compiling vadd(CuDeviceArray{Float16,2,CUDAnative.AS.Global}, CuDeviceArray{Float16,2,CUDAnative.AS.Global}, CuDeviceArray{Float16,2,CUDAnative.AS.Global}) resulted in invalid LLVM IR

Is there any other way to do Float16 computation with CUDAnative?

---

<div class="post-metadata">

**Author:** ![pedramz](https://avatars.discourse-cdn.com/v4/letter/p/ac8455/32.png) [@pedramz](https://discourse.julialang.org/u/pedramz)\
**Post date:** [November 14, 2018, 5:00pm UTC](https://discourse.julialang.org/t/cudanative-support-for-float16/17369/2 "2018-11-14T17:00:02Z")

</div>

Any ideas?!

---

<div class="post-metadata">

**Author:** ![maleadt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maleadt/32/10097_2.png) [@maleadt](https://discourse.julialang.org/u/maleadt)\
**Post date:** [November 14, 2018, 8:05pm UTC](https://discourse.julialang.org/t/cudanative-support-for-float16/17369/3 "2018-11-14T20:05:30Z")

</div>

You should post in the GPU category, more people will spot your post that way.

You didn’t post the actual invalid IR, so it’s unclear what went wrong here. But IIRC Float16 is missing some bits in Base to work properly on GPUs, @vchuravy will know more.

---

<div class="post-metadata">

**Author:** ![pedramz](https://avatars.discourse-cdn.com/v4/letter/p/ac8455/32.png) [@pedramz](https://discourse.julialang.org/u/pedramz)\
**Post date:** [November 14, 2018, 10:47pm UTC](https://discourse.julialang.org/t/cudanative-support-for-float16/17369/4 "2018-11-14T22:47:58Z")

</div>

I did not notice that GPU category exists. I change the category to GPU.

How can I get the actual invalid IR?

---

<div class="post-metadata">

**Author:** ![maleadt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maleadt/32/10097_2.png) [@maleadt](https://discourse.julialang.org/u/maleadt)\
**Post date:** [November 15, 2018, 6:45am UTC](https://discourse.julialang.org/t/cudanative-support-for-float16/17369/5 "2018-11-15T06:45:12Z")

</div>

> [@pedramz](#):
>
> How can I get the actual invalid IR?

By writing GPU compatible code.

Please show a full MWE and all output. [Please read: make it easier to help you](https://discourse.julialang.org/t/psa-make-it-easier-to-help-you/14757)

---

<div class="post-metadata">

**Author:** ![vchuravy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vchuravy/32/8_2.png) [@vchuravy](https://discourse.julialang.org/u/vchuravy)\
**Post date:** [November 15, 2018, 10:19pm UTC](https://discourse.julialang.org/t/cudanative-support-for-float16/17369/6 "2018-11-15T22:19:44Z")

</div>

`Float16` support in Julia is currently eagerly simulated in software by casting to and from Float32, and won’t be able use the hardware support that GPU have. There are many things necessary before we can fully use `Float16` and the first step is [https://github.com/JuliaLang/julia/pull/26381](https://github.com/JuliaLang/julia/pull/26381), but nobody has cared enough to invest the time to make it happen.
