Keeping Futhark off the GPU

Posted on October 2, 2026

Earlier this year, Elias Smedegaard did a BSc thesis on efficiently computing sparse Jacobian matrices via automatic differentiation. For this post, it is not important to understand exactly what this is, or why it is useful - it relates to automatic differentiation, which I have yet to write a blog post about. For the purpose of this post, the salient detail is that part of his solution involves colouring a graph corresponding to the sparsity pattern of a matrix.

Now, optimal graph colouring is a famously NP-hard problem, but we did not need optimal colouring - we just needed decent , and implemented with an efficient algorithm. Elias found a pretty fast greedy algorithm for distance-2 colouring (Algorithm 3.1 in this paper if you are curious), but unfortunately the algorithm is inherently sequential. This is not a problem for Futhark as Futhark supports quite efficient in-place updates, but the problem is that Elias’s overall program has two steps: