Add TornadoVM CUDA backend support and tensor-core (MMA) accelerated batch prefill (FP16 & Q8_0, Llama & Qwen3)#127
Open
mairooni wants to merge 19 commits into
Open
Add TornadoVM CUDA backend support and tensor-core (MMA) accelerated batch prefill (FP16 & Q8_0, Llama & Qwen3)#127mairooni wants to merge 19 commits into
mairooni wants to merge 19 commits into
Conversation
Add a --cuda flag to llama-tornado that selects the TornadoVM CUDA backend, mirroring the existing --opencl/--ptx/--metal plumbing: it loads the tornado.drivers.cuda module and the cuda-exports export list. Also disambiguate --ptx help text (was 'PTX/CUDA').
The CUDA backend is only available in a dev build of TornadoVM (PR #861), so point the JDK21 build at 4.0.2-jdk21-dev. The project's own version is unchanged.
List CUDA among the supported backends, add a --cuda usage example, and note that the CUDA backend requires a TornadoVM build with the CUDA backend from PR #861 (beehive-lab/TornadoVM#861).
Add a cuda variant to the build, standalone-inference, and quarkus-integration backend matrices. The setup-tornadovm action now builds the CUDA backend from the cuda2 branch (TornadoVM PR #861) until it is merged to master; other backends still build from master. Shared inference steps run on CUDA via the matrix; the PTX-only CUDA-graph steps remain gated to ptx.
…ntion accumulation in FP16 batch prefill
…with packed QK-norm and split-half RoPE
mikepapadim
approved these changes
Jul 7, 2026
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.
This PR enables GPULlama3.java to run on TornadoVM's new CUDA backend and adds a tensor-core (MMA) accelerated batched-prefill pipeline on top of it. It incorporates and supersedes #124 (this branch is based on it, the CUDA backend changes are carried here so backend support and the MMA path that requires it land together).
All five prefill projections (QKV, Wo, W1/W3, W2) are executed as 128×128-tile GEMMs on tensor cores (m16n8k16, FP32 accumulate) via TornadoVM's MMA kernel API, replacing the per-token matvec formulation. Key elements:
[q|k|v]buffer (fixes grid starvation on the skinny GQA projections), and W1/W3 fused into a packed[gate|up]buffer.Example usage:
./llama-tornado --gpu --cuda --model Q8_0-Llama-3.2-1B-Instruct.gguf --prompt "$LONG_PROMPT" --max-tokens 2048 --with-prefill-decode --batch-prefill-size 128