Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cl_khr_fp16 is assumed to work on all hardware, even when this is not the case #4206

Open
softcookiepp opened this issue Apr 18, 2024 · 1 comment

Comments

@softcookiepp
Copy link

softcookiepp commented Apr 18, 2024

When using certain older GPUs via the Rusticl backend (I am using a RX 570 for this,) the following error shows up when trying to perform any operations on float16 tensors:

`RuntimeError: OpenCL Compile Error

input.cl:1:26: warning: unsupported OpenCL extension 'cl_khr_fp16' - ignoring [-Wignored-pragmas]
input.cl:3:3: error: use of undeclared identifier 'half4'
input.cl:4:15: error: unknown type name 'half4'
input.cl:4:36: error: use of undeclared identifier 'half4'
input.cl:4:44: error: use of undeclared identifier 'val0'
input.cl:4:51: error: use of undeclared identifier 'val0'
input.cl:4:60: error: use of undeclared identifier 'val0'
input.cl:4:67: error: use of undeclared identifier 'val0'
input.cl:4:76: error: use of undeclared identifier 'val0'
input.cl:4:83: error: use of undeclared identifier 'val0'
input.cl:4:92: error: use of undeclared identifier 'val0'
input.cl:4:99: error: use of undeclared identifier 'val0'
Error executing LLVM compilation action.`

Here is the code that can be used to reproduce this bug provided you have the hardware:

`from tinygrad import Tensor, dtypes

t = Tensor([1, 2, 3, 4], dtype = dtypes.float16)
(t + t).realize()`

Given that cl_khr_fp16 is an optional OpenCL extension, it may be better to not assume that it exists on all backends, and to use type promotion or similar means of eliminating the issue.

@chenyuxyz
Copy link
Collaborator

implicitly upcasting to float32 if half is not available is bad, but maybe we can support a global flag to say all half should be interpret as float

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants