Fix CudaCallable type inference never being called - #1048
Merged
inducer merged 1 commit intoSep 11, 2026
Conversation
Owner
|
Thanks for making this. LGTM! I'll merge it after #1050 goes in. |
Owner
|
FWIW, that bpr failure is spurious and addressed in #1050. |
CudaCallable declared its type inference as cuda_with_types, but the name the callables machinery calls is with_types (loopy/type_inference.py:557). Nothing in the tree ever referenced cuda_with_types, so CudaCallable fell back to ScalarCallable.with_types, which raises "No type inference information present for the function ...". The method has been dead since the 2018 callables refactor that converted the OpenCL and C siblings (438fd1d) but skipped cuda.py. The effect is that rsqrt, atan2 and dot cannot be used with CudaTarget at all. atan2 is a regression against CTarget, because CUDACASTBuilder.known_callables replaces the working CMathCallable("atan2") with the broken CudaCallable("atan2"). Rename the method to with_types and repair what reviving it exposes: - dtype.kind does not exist on LoopyType, use LoopyType.is_complex(); - the "dot" branch returned a bare callable rather than the (callable, clbl_inf_ctx) tuple every other branch and the base class return, and read .fields off the LoopyType rather than off its numpy_dtype; - "dot" did not set name_in_target; - the returned arg_id_to_dtype mappings were plain dicts, which InKernelCallable.__init__ warns about as deprecated.
inducer
force-pushed
the
fix-cuda-callable-with-types
branch
from
September 11, 2026 21:26
fa8816c to
47b705d
Compare
inducer
enabled auto-merge (rebase)
September 11, 2026 21:26
inducer
disabled auto-merge
September 11, 2026 21:44
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CudaCallablespells its type inference methodcuda_with_types(loopy/target/cuda.py:148), but the name the callables machinery calls iswith_types(loopy/type_inference.py:557). Nothing in the tree referencescuda_with_types, soCudaCallablefalls through toScalarCallable.with_types, which raisesLoopyError("No type inference information present for the function ...")(loopy/kernel/function_interface.py:677). The method has been unreachable since 438fd1d, the 2018 refactor that movedwith_typesonto the callables and converted the OpenCL and C siblings without touchingloopy/target/cuda.py.The result is that
rsqrt,atan2anddotcannot be used withCudaTarget.atan2is a regression againstCTarget, which handles it throughCMathCallable:CUDACASTBuilder.known_callables(loopy/target/cuda.py:336) overwrites that working entry with the brokenCudaCallable("atan2").Renaming the method to
with_typesmakes four latent errors in it reachable, so this fixes those too.LoopyTypehas no.kind, so the complex-argument check would have raisedAttributeError; it now usesLoopyType.is_complex(). Thedotbranch returned a bare callable instead of the(callable, clbl_inf_ctx)tuple that every other branch and the base class return, read.fieldsoff theLoopyTyperather than off itsnumpy_dtype, and never setname_in_target. The returnedarg_id_to_dtypemappings are nowconstantdicts, matchingOpenCLCallable.with_typesand avoiding the deprecation warning inInKernelCallable.__init__.Generating code for
CudaTarget, before and after, withLOOPY_NO_CACHE=1because loopy's disk cache masks the failure once a working result has been stored:test_cuda_specific_callablesintest/test_target.pycovers all six cases. Liketest_fma_codegenit needs no device, sinceCudaTargetonly generates code.Verified on macOS 26.2, Python 3.13.12, numpy 2.4.6, pyopencl 2026.1.4, islpy 2026.2.1:
The failing tests in both files come from the only OpenCL platform on this machine, Apple's framework on an M3, which fails at
clCreateKernel failed: INVALID_KERNEL. The failing test ids are identical with and without this change.