beehive-lab/TornadoVM

Write Java. Run on GPUs. Fast.

What it solves

Writing GPU programs traditionally means using CUDA C, OpenCL, or other native languages, which forces Java developers to leave the JVM, manage native bindings, and maintain separate codebases. TornadoVM lets you write kernels in pure Java, then at runtime its compiler (TC) turns your Java bytecode into GPU code (NVIDIA CUDA, OpenCL C, or Apple Metal). It also solves the gap between custom kernels and tuned vendor libraries: on NVIDIA hardware you can call cuBLAS, cuFFT, cuDNN, and cuDF directly from Java, with the same data buffers shared between your own kernels and those library calls.

How it works

You write Java methods and annotate the parallel loops with @Parallel, or use the KernelContext API to manually index threads (like CUDA). TornadoVM infers the thread mapping or accepts your explicit indices, then JIT-compiles the bytecode at runtime into GPU kernels. The compiler also manages data transfers between host and device, and the whole execution is expressed as a TaskGraph that you run via an execution plan. On NVIDIA GPUs, the generated CUDA kernels are compiled through NVRTC to native cubins. Beyond custom kernels, TornadoVM offers library tasks that bind to NVIDIA libraries (cuBLAS, cuFFT, cuDNN, cuDF) through Java's foreign function interface, so those calls appear as ordinary Java tasks in the same graph. A newer TileContext API lets you write kernels in tiles rather than threads; the tile compiler chooses the threads, tensor-core instructions, and shared-memory staging.

Who it's for

Java developers who want to accelerate compute-heavy workloads — machine learning, computer vision, physics simulation, financial analysis, signal processing — on GPUs or multi-core CPUs without leaving the JVM. It's also for teams that need the performance of tuned NVIDIA libraries but want to keep everything in Java, with no JNI or native toolchain in the application. The README notes its use in LLM inference (jitllm), ray tracing, and even the ESA's Gaia mission.

Highlights

  • JIT-compiles Java bytecode to CUDA, OpenCL C, and Apple Metal at runtime — no native code to write or maintain.
  • Supports three programming styles: @Parallel annotations for automagic thread mapping, KernelContext for explicit CUDA-style indexing, and TileContext for tile-based programming.
  • Native integration with NVIDIA's library ecosystem (cuBLAS, cuFFT, cuDNN, cuDF) from Java, with shared device buffers and a single CUDA graph capture.
  • Exposes Tensor Core mma.sync instructions from Java, enabling FP16 and INT8 matrix operations without writing CUDA C.
  • The same TaskGraph can mix JIT-compiled kernels and native library calls, and can be captured into a CUDA Graph for single-launch replay.
  • Works with JDK 21+ (up to JDK 27) and can leverage Project Leyden or GraalVM native image for fast startup (e.g., ~0.3 s for Saxpy on RTX 4090).

Related

  • Project
  • Project
  • Dispatch
  • Project
  • Project