Repository navigation
Implement compute-follows-data programming model [kernel API] - #598
Conversation
| def _raise_datatype_mixed_error(argtypes): | ||
| error_message = ( | ||
| "Datatypes of array passed to @numba_dppy.kernel " | ||
| "has to be uniform. Passed datatypes: %s" % str(argtypes) |
There was a problem hiding this comment.
The error message can be improved. What does "to be uniform" imply?
There was a problem hiding this comment.
Addressed. Please resolve if the changes are satisfactory.
| """ | ||
| return tuple([self.typingctx.resolve_argument_type(a) for a in args]) | ||
|
|
||
| def _datatype_uniform(self, argtypes): |
There was a problem hiding this comment.
Please think of a better name. The work "uniform" does not convey much information.
There was a problem hiding this comment.
Addressed. Please resolve if the changes are satisfactory.
There was a problem hiding this comment.
As I said somewhere in other place here about this function - it breaks Single-responsibility principle. It have 2 responsibilities and you will eventually extract one of them:
- Return one of uniformed array types
- Check if array types are uniform
| if type(array_type) == USMNdArrayType: | ||
| if dpctl.is_in_device_context(): | ||
| raise ValueError( | ||
| "Compute will follow data! Please do not use context manager " |
There was a problem hiding this comment.
Should this be a warning instead?
There was a problem hiding this comment.
Possibly warning should show the location in code somehow.
|
|
||
| current_queue = dpctl.utils.get_execution_queue(queues) | ||
| if current_queue is None: | ||
| raise ValueError( |
There was a problem hiding this comment.
I will prefer us raising a specialized Error (say IndeterminateExecutionQueueError) instead of a ValueError.
| "create dpctl.tensor.usm_ndarray with equivalent SYCL queue." | ||
| ) | ||
|
|
||
| if current_queue is None: |
There was a problem hiding this comment.
We should rename current_queue to selected_queue or something more relevant. Especially as we move to the new model the notion of current queue is going away.
There was a problem hiding this comment.
compute_queue, target_queue?
There was a problem hiding this comment.
Addressed. Please resolve if the changes are satisfactory.
| buffer_ctor_kwargs={"queue": queue}, | ||
| ) | ||
|
|
||
| sum_kernel[global_size, local_size](da, db, dc) |
There was a problem hiding this comment.
Can we test that computations was performed on specific queue?
There was a problem hiding this comment.
Good question. I do not know of any such mechanism.
@oleksandr-pavlyk Do you happen to have any idea?
There was a problem hiding this comment.
If the queue has enable_profiling property, one can use dpctl.SyclTimer to check that device timer is sufficiently large. Otherwise, we need to employ profiling tools pti-gpu.
There was a problem hiding this comment.
I take we do not have a straight-forward way to check if computation was performed on a specific queue.
There was a problem hiding this comment.
It opens a very important question that has been brought up by customers as well. Numba-dppy should provide a way for users to determine where execution occurred. I will look into pti-gpu.
|
|
||
| expected = a + b | ||
|
|
||
| assert np.array_equal(got, expected) |
There was a problem hiding this comment.
Checking results is not what should be tested. Queue selected for computation should be tested.
| buffer_ctor_kwargs={"queue": queue}, | ||
| ) | ||
|
|
||
| with pytest.raises(TypeError): |
There was a problem hiding this comment.
I think better to test that TypeError contains message related to compute follows data.
There was a problem hiding this comment.
Addressed. Please resolve if the changes are satisfactory.
| buffer_ctor_kwargs={"queue": queue}, | ||
| ) | ||
|
|
||
| with pytest.raises(ValueError): |
There was a problem hiding this comment.
I think it is better to test that ValueError contains message specific to compute follows data.
There was a problem hiding this comment.
Addressed. Please resolve if the changes are satisfactory.
| buffer_ctor_kwargs={"queue": queue1}, | ||
| ) | ||
|
|
||
| with pytest.raises(ValueError): |
There was a problem hiding this comment.
I think it is better to test ValueError with specific message about compute follows data.
There was a problem hiding this comment.
Addressed. Please resolve if the changes are satisfactory.
| - cython | ||
| - numba 0.54*|0.55* | ||
| - dpctl 0.10*|0.11* | ||
| - dpctl 0.11* |
There was a problem hiding this comment.
Please avoid these hard pinnings. Can we use >= 0.11 instead?
There was a problem hiding this comment.
We can not. It cause problems when dpctl 0.12 will appear and will be incompatible.
There was a problem hiding this comment.
Better we release patch if it will be compatible.
There was a problem hiding this comment.
Better we release a patch if it is incompatible. We organize development of dpctl to ensure that necessary changes in dependent projects are done concurrently
There was a problem hiding this comment.
As a developer I want to have control whether to use new unstable dpctl or not to use.
There was a problem hiding this comment.
I would like to use wider range for dependencies. But then we have to control which package use for CI in different way.
I.e. conda_build_confgi.yaml.
I agree that conda recipe should be with wide range. An we can restrict some dependency versions only for releasing as @oleksandr-pavlyk said. But we usually work with latest dpctl version and it is not always stable.
I want to have a tool to control which stable version of dpctl to use for checking code changes in numba-dppy (which are not related to dpctl) and which potentially unstable version to use for checking that numba-dppy compatible with latest dpctl. It should be 2 separate CI branches.
I agree that configuring it via conda recipe is not ok.
There was a problem hiding this comment.
Also it is not clear for me how and when we understand when we should change >=0.11 to >=0.12.
If we always test with latest dpctl we are not controlling how numba-dppy works with previous version. We should know "is it backward compatible yet or no?".
I suppose there should be separate test environments in CI.
| In the CFD style of programming kernels, the execution queue is determined based on the input arguments passed to a kernel function. Currently, numba-dppy's kernel API only supports array arguments that provide the :code:`__sycl_usm_array_interface__` (SUAI) attribute for CFD style programming. The SUAI attribute encodes the queue where the array was defined. | ||
|
|
||
|
|
||
| We also allow passing arrays and data types that do not provide SUAI. For such cases, programmers need to specify the queue using the :code:`dpctl.device_context` context manager. Do note that the use of :code:`dpctl.device_context` is deprecated and slotted for removal in some future release. |
There was a problem hiding this comment.
Do note that the use of :code:
dpctl.device_contextis deprecated and slotted for removal in some future release.
Better to format as note.
PokhodenkoSA
left a comment
There was a problem hiding this comment.
I am ok to merge it after small polishing.
* Remove skips for opencl to helper * Change all filter_strings_with_skips_for_opencl
* Initial test and check for data uniformity * Add equivalent queue check and context_manager check * Add equivalent test from dpctl * Update Documentation, CHANGELOG and add example * Use as_usm_memory for receiving sycl_queue * Update dpctl 0.12 * dpctl 0.12 in environment.yml * Add dpctl_support.py with dpctl_version * Make code compatible with dpctl 0.11 Co-authored-by: Sergey Pokhodenko <pokhodenko.s.a@gmail.com> 9649878
This PR introduces compute follows data for kernel.
The spec can be found here: https://github.com/IntelPython/DPPY-Spec/blob/compute-follows-data/compute_follows_data.md.