Repository navigation
Update CtypesLinker::add_cu error message to include fp16 usage - #8744
Conversation
|
gpuci run tests |
|
gpuci run tests |
1 similar comment
|
gpuci run tests |
gmarkall
left a comment
There was a problem hiding this comment.
Thanks for the PR. In addition to the changed test, I think it would be wise to have a test that causes the exception to be raised through the use of an unsupported operation on float16 data.
A couple of other questions:
- Is it possible to identify what the user is doing (either using
float16or linking in additional.cufiles) and provide them an error message that references specifically what they're doing instead of providing a catch-all generic message? - Is the documentation of this restriction sufficient, or are some additions needed in the docs?
| raise NotImplementedError("Support for fp16 or linking CUDA source " | ||
| "files requires the use of the Nvidia CUDA " | ||
| "bindings and enabling the " | ||
| "NUMBA_CUDA_USE_NVIDIA_BINDING environment " | ||
| "variable. See documentation for me details.") |
There was a problem hiding this comment.
Suggested changes:
fp16should befloat16-I noticed that the code in Numba is unusual in Python referring to 16-bit floating point values asfp16rather thanfloat16which seems to be used everywhere else - for example, the NumPy dtype. This is an inconsistency I should probably have realised much sooner, so I'd like to try not introducing more instances of it.Nvidiais usually writtenNVIDIA- Instead of saying the environment variable should be enabled, say that it should be set to
1. See documentation for me detailsneeds the grammar correcting, and it would be helpful to provide a link to the relevant documentation. Where is the user supposed to look?
|
gpuci run tests |
|
@gmarkall error message updated. |
|
Thanks. What do you think about the other two questions from the review? |
@gmarkall I don't think it's possible to determine if this is a float 16 issue or the user is linking in .cu files; in both cases we end up in the CtypesLinker::add_cu which throws the exception. We would need to catch this higher up in the stack somewhere. I think the clarified error message along with the link to the documentation is sufficient. |
Is there anything wrong with this approach: diff --git a/numba/cuda/dispatcher.py b/numba/cuda/dispatcher.py
index a79120d85..bb85093f9 100644
--- a/numba/cuda/dispatcher.py
+++ b/numba/cuda/dispatcher.py
@@ -110,6 +110,9 @@ class _Kernel(serialize.ReduceMixin):
if (f'__numba_wrapper_{fn}' in lib.get_asm_str())]
if res:
+ if not config.CUDA_USE_NVIDIA_BINDING:
+ raise NotImplementedError('float16 needs NV Binding')
+
# Path to the source containing the foreign function
basedir = os.path.dirname(os.path.abspath(__file__))which causes the example from numba import cuda, types
@cuda.jit('void()')
def f():
types.float16(1) / types.float16(2)to emit: ? |
|
@gmarkall I was thinking about that after I mentioned "higher up in the stack", and yes that works as well. I'll make that change. |
|
gpuci run tests |
|
@gmarkall error message updated. |
| def test_linking_cu_ctypes_unsupported(self): | ||
| msg = ('Linking CUDA source files is not supported with the ctypes ' | ||
| 'binding') | ||
| msg = ('Support for fp16 or linking CUDA source files ' |
There was a problem hiding this comment.
The expected message doesn't seem to match the message added in dispatcher.py. Shouldn't this test be failing?
There was a problem hiding this comment.
@gmarkall the test was not failing it appears because it was not being run due to the skip_with_cuda_python decorator.
|
@testhound Some questions on the diff. |
…config variable for proper testing
|
gpuci run tests |
1 similar comment
|
gpuci run tests |
|
@gmarkall test case updates made to address your comments. |
gmarkall
left a comment
There was a problem hiding this comment.
Thanks for the changes. Whilst running test_linking_cu_ctypes_unsupported in a subprocess is a positive change (so it's good to keep it in), my point was that it doesn't test the changes you're making in this PR, which raises when the automatic linking of a .cufile is induced by the use of a float16 function that requires it - so, another test needs to be added for the new exception that's added here.
There are some other suggestions on the diff relating to spelling errors and simplification.
| msg = ("Use of float16 requires the use of the NVIDIA CUDA " | ||
| "bindings and settng the " | ||
| "NUMBA_CUDA_USE_NVIDIA_BINDING environment variable to " | ||
| "1. Relevant documentation is available here:\n" | ||
| f"{s}") |
There was a problem hiding this comment.
Some simplification of this comment (and the typo fix suggested yesterday incorporated):
| msg = ("Use of float16 requires the use of the NVIDIA CUDA " | |
| "bindings and settng the " | |
| "NUMBA_CUDA_USE_NVIDIA_BINDING environment variable to " | |
| "1. Relevant documentation is available here:\n" | |
| f"{s}") | |
| msg = ("Use of float16 requires the NVIDIA CUDA bindings and " | |
| "setting the NUMBA_CUDA_USE_NVIDIA_BINDING environment " | |
| f"variable to 1. See {s}") |
| self.assertIn('in the compilation of "error.cu"', msg) | ||
|
|
||
| @skip_with_cuda_python | ||
| # We need to run the test ina subprocess because the Linker class |
There was a problem hiding this comment.
| # We need to run the test ina subprocess because the Linker class | |
| # We need to run the test in a subprocess because the Linker class |
|
@stuartarchibald Could this have a CUDA BF run please? |
gmarkall
left a comment
There was a problem hiding this comment.
This looks good - just needs a BF run to move to RTM.
|
BFID |
|
Buildfarm failed with missing |
@sklam this error confuses me as I explicitly fixed the test case to refer to the new location of jitlink.cu and this passes all CI tests which refers to this location. |
|
gpuci run tests |
The test contained a hardcoded expectation of the working directory, which doesn't hold in all cases (in the buildfarm in this instance). Test data locations should be determined using |
|
I've tested this locally on both Linux and Windows, both in the Numba tree ( |
|
new BFID: |
passed |
@gmarkall thank you for the fix. |
gmarkall
left a comment
There was a problem hiding this comment.
I think this is good to merge.
|
gpuci run tests |
|
Not sure what happened to gpuci, just running again to make sure there's nothing odd lurking. |
|
Marking as RTM as gpuCI had no surprises. |
This pull request update the error message on the add_cu method in CtypesLinker to include fp16. The reason for the update is CUDA fp16 support requires linking of cu files in it's internal implementation.