Skip to content

biojava-tornadovm: opt-in GPU paths for ASA and all-pairs alignment scores (TornadoVM 8.0.0) - #1162

Open
mikepapadim wants to merge 1 commit into
biojava:masterfrom
mikepapadim:feat/tornadovm-gpu
Open

mikepapadim wants to merge 1 commit into
biojava:masterfrom
mikepapadim:feat/tornadovm-gpu

Conversation

@mikepapadim

@mikepapadim mikepapadim commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to #1158 and #1161: the GPU paths for ASA and all-pairs alignment scores, as an opt-in module, biojava-tornadovm, using TornadoVM 8.0.0.

In #1158 you suggested keeping the GPU code in a separate repository, and it lives at mikepapadim/biojava-tornadovm-extensions. This draft shows the alternative of shipping it inside BioJava without affecting anything else:

  • Default build unchanged. The module builds only with -Ptornadovm. It needs JDK 21, and every other module keeps the JDK 11 baseline.
  • Not a runtime dependency. tornado-api is provided; nothing in the existing modules depends on the new one.
  • Drop-in and exact. TornadoAsaCalculator and TornadoAlignments mirror AsaCalculator and Alignments.getAllPairsScores / getAllPairsScorers (GLOBAL, LOCAL) and return exactly the same results. Without a TornadoVM runtime, below a size threshold, or after a GPU failure, they run an exact multi-threaded CPU path.

Happy to keep it in the separate repository instead if you prefer; this PR is so you can see what it would look like in-tree.

How to run

Linux with an NVIDIA GPU, using SDKMAN. For AMD or Intel GPUs, use tornadovm 8.0.0-jdk21-opencl and TORNADO_BACKEND=opencl.

sdk install java 21.0.2-open
sdk install tornadovm 8.0.0-jdk21-cuda
export JAVA_HOME=$HOME/.sdkman/candidates/java/21.0.2-open

git fetch origin pull/1162/head:tornadovm && git checkout tornadovm
mvn -Ptornadovm -pl biojava-tornadovm -am install -DskipTests

cd biojava-tornadovm
scripts/test-gpu.sh      # the 23 parity tests under TornadoVM: GPU results == BioJava results
./bench.sh               # parity tests + ASA and all-pairs benchmarks (downloads 5 PDB entries)

git fetch origin pull/1162/head only checks out this PR, because the module exists here until it is merged. TornadoVM itself is the stock 8.0.0 release: tornado-api 8.0.0-jdk21 from Maven Central, and the SDKMAN SDK. After a merge, git clone of master and the same mvn -Ptornadovm ... line are enough.

The scripts find TornadoVM 8.0.0 in SDKMAN by version, and install it with sdk install if it is missing. Without SDKMAN they download the release SDK. mvn -Ptornadovm -pl biojava-tornadovm test runs the same tests on a plain JVM, which covers the CPU paths. biojava-tornadovm/README.md covers using the classes in an application.

Tested

  • 23/23 parity tests under TornadoVM 8.0.0 on an RTX 4090 with the CUDA backend, an RTX 4090 with OpenCL, and an Intel UHD 770 with OpenCL (no FP64; ASA then uses its exact single-precision path).
  • 23/23 on a plain JVM (CPU paths).
  • mvn validate without the profile does not include the module.
Workload (RTX 4090, i9-13900K 32 threads, end to end) BioJava lean Java (32 thr) GPU
ASA 4V6X, 238k atoms 558 ms (32 thr) 109 ms 35.7 ms
ASA 3J3Q, 2.4M atoms 6.92 s (32 thr) 1.16 s 373 ms
All-pairs global, 200 proteins, 20k pairs 9.97 s 417 ms 17.0 ms
All-pairs local, 200 proteins, 20k pairs 10.5 s 293 ms 17.0 ms

All results are identical to BioJava's. "Lean Java" is the same algorithm in plain Java; it is this module's CPU path, and #1161 brings the alignment part of it into biojava-alignment itself.

…TornadoVM 8.0.0)

A new module, built only with -Ptornadovm (JDK 21; the rest of BioJava keeps
its JDK 11 baseline). TornadoAsaCalculator and TornadoAlignments are drop-in
replacements for AsaCalculator and Alignments.getAllPairsScores /
getAllPairsScorers (GLOBAL, LOCAL) and return exactly the same results; without
a TornadoVM runtime, below a size threshold or after a GPU failure they run an
exact multi-threaded CPU path.

TornadoVM 8.0.0 comes from SDKMAN (scripts/env.sh). scripts/test-gpu.sh runs
the 23 parity tests under TornadoVM, bench.sh the benchmarks. See biojava#1158.
@mikepapadim
mikepapadim marked this pull request as ready for review October 28, 2026 16:49
@mikepapadim

Copy link
Copy Markdown
Contributor Author

@josemduarte is it something you are keen on merging?

it should work also on Apple M-silicon and AMD hw through hip if we bumpp the version to 8.2.0

Also, no need for an sdk any more just the jars from maven centeral

@josemduarte

Copy link
Copy Markdown
Contributor

I think this is a very nice addition. But I am hesitant about where to place it. It could be as a new module as proposed here or as a separate project under the biojava org umbrella.

And also there's the JDK 21 upgrade that is pending for the rest of biojava. I'd like to have a release on 21 soon. Perhaps that can be the moment to get this one in.

Let me think about it a little more. In the meantime we'll keep this open. And also let's think about other possible features that might benefit from GPU. If we had more features it would give us more reasons to keep the tornado module proposed here for the long run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants