Repository navigation
Keep kernel macro and POCL device code concretely typed - #914
Merged
Merged
Conversation
vchuravy
approved these changes
Oct 21, 2026
Contributor
Benchmark ResultsShow table
Benchmark PlotsA plot of the benchmark results have been uploaded as an artifact to the workflow run for this PR. |
`default_forwarders!` reduced over a value of unknown type, `split_branches` sliced one, and `default_sub_group_size` spliced the untyped result of the device's `getproperty` into an array literal. That compiled them with edges to generic Base methods that packages loaded before KernelAbstractions invalidate (e.g. ChainRulesCore's `mapreduce` and `promote_rule` methods), making Julia discard their precompiled code, and that of the POCL back-end's launch path, when loading KernelAbstractions.
maleadt
force-pushed
the
tb/invalidations
branch
from
October 21, 2026 13:07
a1addbb to
4b72f59
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #914 +/- ##
=======================================
Coverage 82.73% 82.73%
=======================================
Files 28 28
Lines 2461 2461
=======================================
Hits 2036 2036
Misses 425 425 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Packages loaded before KernelAbstractions that extend generic Base functions (e.g. ChainRulesCore's
mapreducefor thunks and itspromote_rule) invalidate precompiled KernelAbstractions code that calls those functions on values of unknown type, so Julia recompiles it on first use. Three places did that:default_forwarders!reduced overdef[:args]from an untypedDict,split_branchessliced an untyped expression, and the POCL back-end'sdefault_sub_group_sizespliced the untyped result of the device'sgetpropertyinto an array literal. The last one is on the CPU back-end's launch path, so with ChainRulesCore loaded first it was recompiled for every session's first kernel, together with its callers. This asserts the (known) types at those three places.This is part of a series addressing JuliaGPU/GPUCompiler.jl#1048 (with JuliaGPU/GPUCompiler.jl#1052, JuliaLLVM/LLVM.jl#702 and maleadt/CompilerCaching.jl#33). With all of them, the first CPU kernel with ChainRulesCore loaded first goes from 2.51 s to 1.09 s (0.78 s without ChainRulesCore). Tested with the test suite on Julia 1.13.
The launch path still infers some abstract types when kernels are launched with abstractly-typed arguments (e.g.
partitionandnormalize_workgroupsizefrom AcceleratedKernels' generic backends); I'll look at normalizing those at the launch boundary separately.