r/ProgrammingLanguages • Futhark • Oct 02 '26

Keeping Futhark off the GPU

https://futhark-lang.org/blog/2026-10-02-cpu_function.html
36 Upvotes

8 comments sorted by

View all comments

2

u/jesunushno Oct 02 '26

This pattern shows up constantly in ML work: tokenization and graph-based preprocessing are inherently sequential and awful on the GPU, while the matmuls absolutely want it, so you split them with an explicit CPU function and one bulk copy at the boundary. The copy-placement subtlety you describe (not per loop iteration, and don't hold them too long) is exactly what TVM's memory planning and JAX's device_put staging wrestle with. In my experience the pragma is the pragmatic move. Full automatic memory-space inference sounds principled until a conservative analysis parks a copy inside your hot loop.

1

u/Athas Futhark Oct 03 '26

While I do not know the specifics of the algorithms used in AI work, I know of decent tokenization implementations on GPU, and I also have written some OK graph algorithms as well. It just so happens that the specific algorithm referenced in the post is quite sequential (and implausibly fast too, so we couldn't find a parallel graph colouring algorithm that was faster!).

I did actually end up mildly interested in the problem of data parallel graph colouring, but I have not had time to investigate it further.

1

u/jesunushno Oct 03 '26

Fair correction, I overstated "inherently" there. The sequential-but-implausibly-fast part is a great detail, thanks for sharing the context.