# \#kernelabstractions

**URL:** https://discourse.julialang.org/tag/kernelabstractions/898.md

[Latest](https://discourse.julialang.org/latest.md) · [Categories](https://discourse.julialang.org/categories.md) · [Tags](https://discourse.julialang.org/tags.md)

---

## [Looking for advice on package for lazily evaluated kernel matrix on the GPU](https://discourse.julialang.org/t/looking-for-advice-on-package-for-lazily-evaluated-kernel-matrix-on-the-gpu/139089)

<div class="topic-metadata">

**Author:** [@trevorgloe](https://discourse.julialang.org/u/trevorgloe)\
**Replies:** 2\
**Last updated:** [September 1, 2026, 12:37am UTC](https://discourse.julialang.org/t/looking-for-advice-on-package-for-lazily-evaluated-kernel-matrix-on-the-gpu/139089 "2026-09-01T00:37:29Z")

</div>

I am working on creating a package for lazily evaluated kernel matrices, which will work on the GPU via KernelAbstractions. The idea is to create a central object (LazyKernelMatrix) which does not allocate and evaluates …

---

## [Where do these NaNs in my KernelAbstraction derivative come from?](https://discourse.julialang.org/t/where-do-these-nans-in-my-kernelabstraction-derivative-come-from/139105)

<div class="topic-metadata">

**Author:** [@rkube](https://discourse.julialang.org/u/rkube)\
**Replies:** 0\
**Last updated:** [August 30, 2026, 5:35pm UTC](https://discourse.julialang.org/t/where-do-these-nans-in-my-kernelabstraction-derivative-come-from/139105 "2026-08-30T17:35:37Z")

</div>

Hi, I (mostly chatgpt though) am working on an MHD code using KernelAbstractions.jl, Reactant.jl and Enzyme.jl. In one step, a kernel derivative produces NaNs whereas the reactant gradient using plain arrays gives corre…

---

## [KernelForge.jl — High-performance portable GPU primitives for arbitrary types and operators](https://discourse.julialang.org/t/kernelforge-jl-high-performance-portable-gpu-primitives-for-arbitrary-types-and-operators/135780)

<div class="topic-metadata">

**Author:** [@epilliat](https://discourse.julialang.org/u/epilliat)\
**Replies:** 13\
**Last updated:** [June 16, 2026, 3:31pm UTC](https://discourse.julialang.org/t/kernelforge-jl-high-performance-portable-gpu-primitives-for-arbitrary-types-and-operators/135780 "2026-06-16T15:31:07Z")

</div>

I’m happy to announce two related packages for high-performance GPU computing in Julia: KernelForge.jl — high-level GPU primitives (mapreduce, scan, matvec, search, vectorized copy) with performance competitive with ve…

---

## [Choosing between KernelAbstractions, AcceleratedKernels, ParallelStencils, or just CUDA.jl](https://discourse.julialang.org/t/choosing-between-kernelabstractions-acceleratedkernels-parallelstencils-or-just-cuda-jl/135833)

<div class="topic-metadata">

**Author:** [@Ludovic\_Dumoulin](https://discourse.julialang.org/u/Ludovic_Dumoulin)\
**Replies:** 18\
**Last updated:** [March 18, 2026, 3:38pm UTC](https://discourse.julialang.org/t/choosing-between-kernelabstractions-acceleratedkernels-parallelstencils-or-just-cuda-jl/135833 "2026-03-18T15:38:30Z")

</div>

Hello, Until today, I have used mainly CUDA.jl to run simulations. I mostly do hydrodynamics and solve various PDEs. I would like to make my code available for other users in my lab, to be able to run simulations also …

---

## [\[ANN\] Breeze.jl: GPU-based high-res atmospheric modeling based on Oceananigans.jl](https://discourse.julialang.org/t/ann-breeze-jl-gpu-based-high-res-atmospheric-modeling-based-on-oceananigans-jl/135347)

<div class="topic-metadata">

**Author:** [@glwagner](https://discourse.julialang.org/u/glwagner)\
**Replies:** 10\
**Last updated:** [February 6, 2026, 10:06pm UTC](https://discourse.julialang.org/t/ann-breeze-jl-gpu-based-high-res-atmospheric-modeling-based-on-oceananigans-jl/135347 "2026-02-06T22:06:45Z")

</div>

Hello Julia community! We’re building GPU-first, finite volume, pure Julia software for atmospheric modeling called “Breeze.jl”, based on Oceananigans.jl. Breeze looks and smells like Oceananigans and reuses grids, fiel…

---

## [KernelAbstractions + CUDA + Reactant - how to get minimal working example](https://discourse.julialang.org/t/kernelabstractions-cuda-reactant-how-to-get-minimal-working-example/134164)

<div class="topic-metadata">

**Author:** [@Jakub\_Mitura](https://discourse.julialang.org/u/Jakub_Mitura)\
**Replies:** 12\
**Last updated:** [November 30, 2025, 6:34am UTC](https://discourse.julialang.org/t/kernelabstractions-cuda-reactant-how-to-get-minimal-working-example/134164 "2025-11-30T06:34:06Z")

</div>

Hello I tried to get minimal working example for reactant powered kernel abstractions plus Enzyme like using Pkg Pkg.activate(".") using Reactant using KernelAbstractions using CUDA using Enzyme using Test # Simple squ…

---

## [InvalidIRError when running AcceleratedKernels.sum on a GPU SubArray (CuArray view)](https://discourse.julialang.org/t/invalidirerror-when-running-acceleratedkernels-sum-on-a-gpu-subarray-cuarray-view/133994)

<div class="topic-metadata">

**Author:** [@0samuraiE](https://discourse.julialang.org/u/0samuraiE)\
**Replies:** 2\
**Last updated:** [November 20, 2025, 9:20am UTC](https://discourse.julialang.org/t/invalidirerror-when-running-acceleratedkernels-sum-on-a-gpu-subarray-cuarray-view/133994 "2025-11-20T09:20:41Z")

</div>

I’m running into an issue when trying to use AcceleratedKernels.sum on a GPU SubArray (a view into a CuArray). Calling AK.sum on the full array works fine, but calling it on the view throws an InvalidIRError. Question …

---

## [\[San Francisco, CA\] Performance Engineer - GPU Atmospheric Modeling](https://discourse.julialang.org/t/san-francisco-ca-performance-engineer-gpu-atmospheric-modeling/133858)

<div class="topic-metadata">

**Author:** [@giordano](https://discourse.julialang.org/u/giordano)\
**Replies:** 2\
**Last updated:** [November 14, 2025, 3:48am UTC](https://discourse.julialang.org/t/san-francisco-ca-performance-engineer-gpu-atmospheric-modeling/133858 "2025-11-14T03:48:00Z")

</div>

Aeolus Labs are looking for a performance engineer building a next-generation, differentiable atmospheric model for hurricane science and weather forecasting. Model will be based on Oceananigans.jl, experience with the …

---

## [Postdoc offer: graph algorithms on GPU with Julia](https://discourse.julialang.org/t/postdoc-offer-graph-algorithms-on-gpu-with-julia/133465)

<div class="topic-metadata">

**Author:** [@gdalle](https://discourse.julialang.org/u/gdalle)\
**Replies:** 0\
**Last updated:** [October 27, 2025, 5:34pm UTC](https://discourse.julialang.org/t/postdoc-offer-graph-algorithms-on-gpu-with-julia/133465 "2025-10-27T17:34:59Z")

</div>

Hi all :waving\_hand: I’m recruiting a postdoctoral researcher on a fully funded 2-year contract. The topic is developing and implementing new parallel graph algorithms in Julia, with applications to data-driven transpor…

---

## [ERROR: LoadError: UndefVarError: \`local\_d\` not defined in \`Main\`](https://discourse.julialang.org/t/error-loaderror-undefvarerror-local-d-not-defined-in-main/131296)

<div class="topic-metadata">

**Author:** [@darkg3n3sis](https://discourse.julialang.org/u/darkg3n3sis)\
**Replies:** 2\
**Last updated:** [August 5, 2025, 11:37am UTC](https://discourse.julialang.org/t/error-loaderror-undefvarerror-local-d-not-defined-in-main/131296 "2025-08-05T11:37:32Z")

</div>

I’m making a project for my university i have many problems with julia but this i can’t understand. The problem is local\_d = @ private(1) i try also to write local\_d = 1 but same error, if i write @ private local\_d = 1 …

---

## [😤 Multi-line expressions aren't fully computed](https://discourse.julialang.org/t/multi-line-expressions-arent-fully-computed/130599)

<div class="topic-metadata">

**Author:** [@bpsomu](https://discourse.julialang.org/u/bpsomu)\
**Replies:** 22\
**Last updated:** [July 11, 2025, 7:46am UTC](https://discourse.julialang.org/t/multi-line-expressions-arent-fully-computed/130599 "2025-07-11T07:46:14Z")

</div>

I had a KernelAbstractions.jl based Kernel function with a multi-line expression as below: using KernelAbstractions @kernel function karniadakis\_update!( n\_eₜ₊₁, n\_eₜ, n\_eₜ₋₁, n\_eₜ₋₂, e\_rhsₜ, e\_rhsₜ₋₁, e\_rhsₜ₋₂, …

---

## [Julia (AcceleratedKernels) vs JAX time comparison](https://discourse.julialang.org/t/julia-acceleratedkernels-vs-jax-time-comparison/129781)

<div class="topic-metadata">

**Author:** [@mcp](https://discourse.julialang.org/u/mcp)\
**Replies:** 21\
**Last updated:** [June 11, 2025, 1:54pm UTC](https://discourse.julialang.org/t/julia-acceleratedkernels-vs-jax-time-comparison/129781 "2025-06-11T13:54:33Z")

</div>

Hi everyone! Following this topic, I’d like to understand how to write an efficient CPU/GPU agnostic code using AcceleratedKernels.jl. My problem is writing the joint PDF of two random variables, one of which is condit…

---

## [KernelAbstractions.get\_backend(::BitArray) causes StackOverflowError](https://discourse.julialang.org/t/kernelabstractions-get-backend-bitarray-causes-stackoverflowerror/129551)

<div class="topic-metadata">

**Author:** [@0samuraiE](https://discourse.julialang.org/u/0samuraiE)\
**Replies:** 1\
**Last updated:** [June 2, 2025, 9:23am UTC](https://discourse.julialang.org/t/kernelabstractions-get-backend-bitarray-causes-stackoverflowerror/129551 "2025-06-02T09:23:57Z")

</div>

Hi all, I’m using KernelAbstractions.jl, and encountered a StackOverflowError when trying to call get\_backend on a BitArray (e.g., from a comparison like .\<): using KernelAbstractions x = rand(10) msk = x .\< 0.5 get\_ba…

---

## [Unusually Slow First Device-to-Host Copy on A100 GPU](https://discourse.julialang.org/t/unusually-slow-first-device-to-host-copy-on-a100-gpu/129348)

<div class="topic-metadata">

**Author:** [@magicura](https://discourse.julialang.org/u/magicura)\
**Replies:** 6\
**Last updated:** [May 27, 2025, 8:57pm UTC](https://discourse.julialang.org/t/unusually-slow-first-device-to-host-copy-on-a100-gpu/129348 "2025-05-27T20:57:54Z")

</div>

Hi everyone, I’m running into an issue where the first attempt to copy data from the device to the host is extremely slow. This problem persists even after running the function multiple times, so I don’t think it’s rela…

---

## [Val{N} + LinearIndices Causes Massive Compile-Time Unrolling](https://discourse.julialang.org/t/val-n-linearindices-causes-massive-compile-time-unrolling/128248)

<div class="topic-metadata">

**Author:** [@0samuraiE](https://discourse.julialang.org/u/0samuraiE)\
**Replies:** 2\
**Last updated:** [April 20, 2025, 2:47pm UTC](https://discourse.julialang.org/t/val-n-linearindices-causes-massive-compile-time-unrolling/128248 "2025-04-20T14:47:46Z")

</div>

I’m seeing strange behavior when using @code\_warntype on a function that takes a Val{N} parameter and creates a LinearIndices object with size (N, N, N). Here’s a minimal example: function test(::Val{N}) where {N} L…

---

## [Is there a way to use @allowscalar in a heterogeneous manner using KernelAbstractions?](https://discourse.julialang.org/t/is-there-a-way-to-use-allowscalar-in-a-heterogeneous-manner-using-kernelabstractions/127828)

<div class="topic-metadata">

**Author:** [@0samuraiE](https://discourse.julialang.org/u/0samuraiE)\
**Replies:** 3\
**Last updated:** [April 10, 2025, 6:33am UTC](https://discourse.julialang.org/t/is-there-a-way-to-use-allowscalar-in-a-heterogeneous-manner-using-kernelabstractions/127828 "2025-04-10T06:33:57Z")

</div>

Hi all, Is it correct that scalar indexing like Out\[1\] is not allowed with KernelAbstractions.jl alone, and that we need GPUArrays.@allowscalar for this? Should we always use GPUArrays together with KernelAbstractions f…

---

## [Lightweight dependency for GPU programming](https://discourse.julialang.org/t/lightweight-dependency-for-gpu-programming/127386)

<div class="topic-metadata">

**Author:** [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Replies:** 7\
**Last updated:** [March 27, 2025, 5:22pm UTC](https://discourse.julialang.org/t/lightweight-dependency-for-gpu-programming/127386 "2025-03-27T17:22:24Z")

</div>

As a package author is it possible to define KernelAbstractions.jl in my package without adding heavy dependencies? I see that the package currently depends on \[deps\] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" Atomi…

---

## [How to benchmark a function that uses KernelAbstractions kernels?](https://discourse.julialang.org/t/how-to-benchmark-a-function-that-uses-kernelabstractions-kernels/127026)

<div class="topic-metadata">

**Author:** [@pitsianis](https://discourse.julialang.org/u/pitsianis)\
**Replies:** 4\
**Last updated:** [March 17, 2025, 1:27pm UTC](https://discourse.julialang.org/t/how-to-benchmark-a-function-that-uses-kernelabstractions-kernels/127026 "2025-03-17T13:27:19Z")

</div>

What is the correct way to benchmark a function that uses KernelAbstractions.jl (KA) kernels? I noticed that KA/CUDA i.e. KA with the CUDA.jl backend requires the @synchronize(device) macro. Consider this @btime beg…

---

## [How does a kernel function in KernelAbstractions.jl work when the backend is a CPU?](https://discourse.julialang.org/t/how-does-a-kernel-function-in-kernelabstractions-jl-work-when-the-backend-is-a-cpu/126173)

<div class="topic-metadata">

**Author:** [@frankwswang](https://discourse.julialang.org/u/frankwswang)\
**Replies:** 1\
**Last updated:** [February 22, 2025, 4:59pm UTC](https://discourse.julialang.org/t/how-does-a-kernel-function-in-kernelabstractions-jl-work-when-the-backend-is-a-cpu/126173 "2025-02-22T16:59:50Z")

</div>

I’m trying to add GPU-based parallelization to my code. I found KernelAbstractions.jl and liked its backend (vendor) agnostic approach, especially the fall-back support for CPU multi-threading. However, I didn’t find de…

---

## [Cumulative sum on GPUArray using KernelAbstractions](https://discourse.julialang.org/t/cumulative-sum-on-gpuarray-using-kernelabstractions/124098)

<div class="topic-metadata">

**Author:** [@albertomercurio](https://discourse.julialang.org/u/albertomercurio)\
**Replies:** 4\
**Last updated:** [December 24, 2024, 3:16pm UTC](https://discourse.julialang.org/t/cumulative-sum-on-gpuarray-using-kernelabstractions/124098 "2024-12-24T15:16:37Z")

</div>

Hello, I need to implement the cumulative sum (cumsum) on a GPU array (CUDA.jl or Metal.jl). Looking at the CUDA.jl repository, I found this definition function cumsum!(sums) shift = 1 while shift \< length(sum…

---

## [Implement feature common to all \`AbstractGPUArrays\` through KernelAbstractions.jl](https://discourse.julialang.org/t/implement-feature-common-to-all-abstractgpuarrays-through-kernelabstractions-jl/123855)

<div class="topic-metadata">

**Author:** [@albertomercurio](https://discourse.julialang.org/u/albertomercurio)\
**Replies:** 2\
**Last updated:** [December 15, 2024, 2:20pm UTC](https://discourse.julialang.org/t/implement-feature-common-to-all-abstractgpuarrays-through-kernelabstractions-jl/123855 "2024-12-15T14:20:39Z")

</div>

Hello, Let’s imagine I have a very common function LinearAlgebra.kron(a::VT, b::VT) where VT\<:AbstractGPUArray which can support any AbstractGPUArray since I’m using KernelAbstractions.jl. Where should I implement suc…

---

## [Parallel launch of CUDA kernels](https://discourse.julialang.org/t/parallel-launch-of-cuda-kernels/122529)

<div class="topic-metadata">

**Author:** [@hexaeder](https://discourse.julialang.org/u/hexaeder)\
**Replies:** 5\
**Last updated:** [November 13, 2024, 1:14pm UTC](https://discourse.julialang.org/t/parallel-launch-of-cuda-kernels/122529 "2024-11-13T13:14:28Z")

</div>

I have a system with some kernels which are repeatatly called in a loop. My kernels operate on the same input data but in know at launchtime which kernels are safe to spawn asynchronously and which aren’t. A MWE would lo…

---

## [Difference between GPUArrays.jl and KernelAbstractations.jl](https://discourse.julialang.org/t/difference-between-gpuarrays-jl-and-kernelabstractations-jl/115457)

<div class="topic-metadata">

**Author:** [@albertomercurio](https://discourse.julialang.org/u/albertomercurio)\
**Replies:** 4\
**Last updated:** [June 12, 2024, 2:17pm UTC](https://discourse.julialang.org/t/difference-between-gpuarrays-jl-and-kernelabstractations-jl/115457 "2024-06-12T14:17:50Z")

</div>

Hello, I would like to implement some simple matrix-vector multiplication, when none of them are strided arrays (e.g., @view(A\[\[1, 4, 5\], 1:10\])). Standard LinearAlgebra.mul! doesn’t support these arrays, so I thought t…

---

## [How to write generic simulations with KernelAbstractions](https://discourse.julialang.org/t/how-to-write-generic-simulations-with-kernelabstractions/114963)

<div class="topic-metadata">

**Author:** [@SteffenPL](https://discourse.julialang.org/u/SteffenPL)\
**Replies:** 0\
**Last updated:** [May 30, 2024, 11:09am UTC](https://discourse.julialang.org/t/how-to-write-generic-simulations-with-kernelabstractions/114963 "2024-05-30T11:09:30Z")

</div>

I’m working on a project that should work with CUDA.jl and Metal.jl at the same time. Basically some simulation scripts, so, the user is me or collaborators running code (not somebody installing a package I make). With …

---

## [KernelAbstractions for splines](https://discourse.julialang.org/t/kernelabstractions-for-splines/104312)

<div class="topic-metadata">

**Author:** [@weymouth](https://discourse.julialang.org/u/weymouth)\
**Replies:** 6\
**Last updated:** [March 22, 2024, 2:58pm UTC](https://discourse.julialang.org/t/kernelabstractions-for-splines/104312 "2024-03-22T14:58:48Z")

</div>

I’m trying to code a simple b-spline (and then NURBS) on the GPU using kernels to speed up a ton of simultaneous evaluations. I’m having trouble because Cox-deBoor is recursive and throws an error when I try to use this…

---

## [Problems with LinearAlgebra functions within KernelAbstractions and CUDA](https://discourse.julialang.org/t/problems-with-linearalgebra-functions-within-kernelabstractions-and-cuda/97566)

<div class="topic-metadata">

**Author:** [@weymouth](https://discourse.julialang.org/u/weymouth)\
**Replies:** 9\
**Last updated:** [February 22, 2024, 9:58am UTC](https://discourse.julialang.org/t/problems-with-linearalgebra-functions-within-kernelabstractions-and-cuda/97566 "2024-02-22T09:58:47Z")

</div>

I’m almost done porting my solver over to GPU with the help of CUDA and KernelAbstractions. However, I keep running into problem with LinearAlgebra functions. Take this simple example using StaticArrays using CUDA: allo…

---

## [Optimize code which uses KernelAbstractions.jl](https://discourse.julialang.org/t/optimize-code-which-uses-kernelabstractions-jl/110068)

<div class="topic-metadata">

**Author:** [@roflmaostc](https://discourse.julialang.org/u/roflmaostc)\
**Replies:** 1\
**Last updated:** [February 11, 2024, 5:29pm UTC](https://discourse.julialang.org/t/optimize-code-which-uses-kernelabstractions-jl/110068 "2024-02-11T17:29:57Z")

</div>

Hi, in RadonKA.jl I just launch the kernel with the following code: \[....\] kernel! = radon\_kernel!(backend) kernel!(sinogram::AbstractArray{T}, img, weights, in\_height, out\_height, angles, mid, rad…

---

## [Using custom structs with KernelAbstractions](https://discourse.julialang.org/t/using-custom-structs-with-kernelabstractions/102278)

<div class="topic-metadata">

**Author:** [@berk.geveci](https://discourse.julialang.org/u/berk.geveci)\
**Replies:** 6\
**Last updated:** [July 31, 2023, 7:33pm UTC](https://discourse.julialang.org/t/using-custom-structs-with-kernelabstractions/102278 "2023-07-31T19:33:23Z")

</div>

Hi folks. I am trying to pass a custom struct to a kernel. I have done this successfully with CUDA.jl and Metal.jl successfully using the Adapt package. I can get the same to work with KernelAbstractions. Here is the re…

---

## [How does one create a GPU array from an Array](https://discourse.julialang.org/t/how-does-one-create-a-gpu-array-from-an-array/102247)

<div class="topic-metadata">

**Author:** [@berk.geveci](https://discourse.julialang.org/u/berk.geveci)\
**Replies:** 1\
**Last updated:** [July 29, 2023, 6:42pm UTC](https://discourse.julialang.org/t/how-does-one-create-a-gpu-array-from-an-array/102247 "2023-07-29T18:42:07Z")

</div>

Hi folks, I apologize for this basic question but I have not been able to resolve this by going through the documentation. How does one create a GPU array from an Array using KernelAbstractions? Similar to CuArray(array…

---

## [KernelAbstractions on CPU. Why so slow?](https://discourse.julialang.org/t/kernelabstractions-on-cpu-why-so-slow/99272)

<div class="topic-metadata">

**Author:** [@fedoroff](https://discourse.julialang.org/u/fedoroff)\
**Replies:** 8\
**Last updated:** [May 24, 2023, 9:40am UTC](https://discourse.julialang.org/t/kernelabstractions-on-cpu-why-so-slow/99272 "2023-05-24T09:40:00Z")

</div>

In the following code, launched with a single thread, KernelAbstractions’ function is almost twice slower than a simple broadcasting. Any ideas why? using BenchmarkTools using KernelAbstractions @kernel function mulcab…

[Next page](https://discourse.julialang.org/tag/kernelabstractions/898.md?match_all_tags=true&page=1&tags%5B%5D=kernelabstractions)
