Repository navigation
Pass kernel arguments that exceed the device's limit through memory - #767
Open
michel2323 wants to merge 1 commit into
Open
michel2323 wants to merge 1 commit into
michel2323 wants to merge 1 commit into
Conversation
maleadt
force-pushed
the
spill-oversized-kernel-args
branch
2 times, most recently
from
December 2, 2026 17:35
c072a68 to
58eaa6c
Compare
maleadt
marked this pull request as ready for review
December 2, 2026 17:35
Member
|
I force-pushed a reworked version: the tests now use Float32 (CI's Iris Xe has no FP64), launches hold their own reference to a cached copy so a concurrent eviction can't free it before submission, the wrapper returns the kernel's result so GPUCompiler still validates it, and the test now forces evictions. |
maleadt
approved these changes
Dec 2, 2026
Level Zero limits the total size of a kernel's arguments to the device's
`maxArgumentsSize`, 2048 bytes on current Intel GPUs, and IGC refuses to
build a kernel beyond it ("Total size of kernel arguments exceeds
limit"). Large isbits arguments, like ExaModels' expression patterns,
hit that.
When the arguments of a kernel don't fit, `zefunction` now compiles it
as a wrapper, `SpilledKernel`, that takes the largest arguments (as few
as needed) as device pointers and loads their values before calling the
kernel. Launches upload those values to device memory, cached by content
so that relaunching with the same value doesn't copy it again, as a
small upload waits for the queue on discrete GPUs. Launches take
ownership of the copies like of any array the kernel uses. Kernels whose
arguments fit compile and launch as before.
IGC also fails to build some kernels whose large arguments are within
the limit ("Kernel inputs exceed total register size", e.g. a 1 KB
tuple indexed dynamically on DG2), so those are built again with the
larger arguments passed through memory. Arguments that don't fit even
when passing everything larger than a pointer through memory throw an
`ArgumentError` naming the kernel, the size and the limit.
Fixes JuliaGPU#497
maleadt
force-pushed
the
spill-oversized-kernel-args
branch
from
December 3, 2026 05:40
58eaa6c to
449352f
Compare
This branch has not been deployed
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.
Level Zero limits the total size of a kernel's arguments to the device's
maxArgumentsSize, 2048 bytes on current Intel GPUs (Arc, Data Center GPU Max), and IGC refuses to build a kernel that goes over it. Julia kernels take their arguments by value, so large isbits arguments hit this; ExaModels' expression patterns are 4–16 KB each in a process flowsheet model:On PVC this is a hardware limit, so
IGC_OverrideOCLMaxParamSizeonly hides the error (#497).With this PR, a kernel whose arguments don't fit is compiled as a wrapper that takes the largest arguments, as few as needed, as pointers to a copy in device memory and loads them before calling the kernel, so the kernel sees the same values. chipStar does the same for HIP on Level Zero. Kernels whose arguments fit are unaffected.
Each launch needs the value in device memory. On discrete GPUs NEO waits for the queue before copying a small upload, so uploading on every launch would make every such launch synchronous (as it is in AMReX's equivalent). The copies are therefore cached by content (LRU, 256 entries / 64 MiB per device) and never written again, and launches take ownership of them like of any array they use. Relaunching with the same value, which ExaModels does for every callback, copies nothing.
IGC also fails some kernels within the limit with "Kernel inputs exceed total register size", e.g. one looping over a 1 KB tuple on an A770. When the arguments are larger than half the limit and the build fails, the kernel is built again with its large arguments through memory. Arguments that don't fit even then (e.g. 256
Ints) throw anArgumentErrorwith the kernel name, the sizes and the limit.Limitations: a kernel that indexes such a value dynamically keeps a copy in private memory, which counts against scratch space. A new value on every launch still waits for the queue on discrete GPUs.
Tested on an Arc A770 and on a Data Center GPU Max 1550 (Aurora, LTS stack):
@oneapiand KernelAbstractions kernels with 2–32 KB arguments (64 KB on PVC) fail to build on main and give correct results here, also when launched without synchronization with more distinct values than the cache holds. On the A770, a kernel indexing a 64 KB argument dynamically needs 66 KB of scratch per work-item and loses the device. On Aurora, an ExaModels flowsheet model now builds and evaluates its objective, constraints and Jacobian.Fixes #497