Skip to content

Introduction

Fornax lets you call open-weight models as plain Java methods, on your GPU, inside your JVM.

import org.liberationdata.fornax.llama.LlamaModel;
import org.liberationdata.fornax.llama.LlamaModel.Message;
import org.liberationdata.fornax.llama.LlamaModel.Options;
import java.util.List;
try (var llm = new LlamaModel("Qwen3-4B-Instruct-2507-Q4_K_M.gguf")) { // weights load onto the GPU once
llm.chat(List.of(Message.user("Name a country song about a robot.")), Options.DEFAULT, System.out::print);
}

That is a language model running in your own process. There is no Python, no model server, no HTTP and no second process. The weights stay loaded between calls, and tokens stream back to a Java callback as they are produced.

Fornax binds the C and C++ inference engines that the open-model world already runs on. They are the same engines behind the popular command-line tools and servers, so you get their speed and their model support.

Module Engine What it runs
fornax-llama llama.cpp any GGUF language model (Qwen, Llama, Gemma, Mistral, …), with chat, streaming, tool calls and JSON schemas; embeddings and reranking (Qwen3-Embedding, Qwen3-Reranker)
fornax-tts llama.cpp (mtmd) text to speech: Kokoro, ZONOS3, LFM3-Audio, Chatterbox, VoxCPM2, Qwen3-TTS, …
fornax-sd stable-diffusion.cpp images and video: FLUX.1 and FLUX.2, Qwen-Image and Qwen-Image-Edit, SD 1.x/2.x/XL/3, Wan, LTX
fornax-acestep acestep.cpp ACE-Step 1.5 songs, with vocals and lyrics, up to several minutes
fornax-yue2 yue2.cpp YuE2 songs
fornax-whisper whisper.cpp speech to text with word timings: Whisper large-v3-turbo, base.en, any ggml Whisper model
fornax-demucs stems.cpp stem separation: vocals and backing, or drums, bass, other and vocals, with HTDemucs v4
fornax-core what the others share: native loading, ModelPool, HfCache, Audio, Vectors

Every model class is AutoCloseable, and its weights are freed on close(). A model can be called from any thread; its calls run one at a time. From virtual threads, use the ...Async methods, which run the native call on the model’s own thread (see Threading). A ModelPool keeps several models loaded and gives each one user at a time.

Fornax calls the engines through Java’s Foreign Function & Memory API (Java 22 or newer; Kiln 0.1.0 itself needs 25). A Fornax call is a native function call, made directly from your thread, or from the model’s own thread for the async methods.

Each engine is built into one self-contained shared library, with its own copy of ggml (the tensor library under all the engines) linked in statically and kept private. The engines pin different ggml versions, so this is what lets several of them share one process: an LLM, a diffusion model and a song model can all be loaded in the same JVM at once.

How each module binds its engine depends on what the engine offers:

  • stable-diffusion.cpp has a key/value C API, so fornax-sd binds it directly. Any option the engine documents can be passed through.
  • llama.cpp has a C API too, but it passes structs by value and is moving to a new batch API, so fornax-llama binds a small, stable C layer instead. fornax-tts is one more such layer, over llama.cpp’s audio generation.
  • acestep.cpp and yue2.cpp are C++ only, so each gets a layer of about 100 lines: a JSON request in, PCM audio out.
  • whisper.cpp has a C API, but it passes two large parameter structs by value, so fornax-whisper binds a small C layer that takes plain arguments and reads the results back token by token.
  • stems.cpp has a C ABI of size-tagged structs in a function table, so fornax-demucs binds a small C layer over it: planar audio in, planar stems out.

Fornax doesn’t download anything. You fetch weights with the Hugging Face CLI, and HfCache finds them in the cache, or you pass file paths directly.

Fornax is early. Everything below runs from Java on Linux with an AMD Radeon 8060S (Ryzen AI Max+ 395 “Strix Halo”, 128 GB unified memory) using the Vulkan backend:

Model Result
Qwen3 4B Instruct (Q4_K_M) ~60 tokens/s, streamed through a Java callback
Qwen3-Embedding 0.6B (Q8_0) ~420 embeddings/s (20-token passages, 256 to a batch), matching llama-embedding’s vectors (cosine 1.000000)
ACE-Step 1.5 XL turbo a 3 min 20 s song in 57 s
ACE-Step 1.5 turbo a 60 s song in ~15 s
YuE2 3B (Q8_0) a 60 s song in ~60 s
FLUX.2 [klein] base 4B (fp8) 768×768, 12 steps in ~130 s
Qwen-Image 2512 (fp8) 1024×1024, 20 steps in ~13 min
Whisper large-v3-turbo (q5_0) 55 s of speech in 1.8 s (31× real time), with DTW word timings
HTDemucs v4 (F32) a 3 min 9 s song split into four stems in 26 s (7.3 s of audio per second)

You choose a GPU backend when you build the native libraries; the Java code is the same for every backend.

Backend GPUs State
Vulkan AMD, Intel, NVIDIA what Fornax is tested on
HIP (ROCm) AMD builds; has run LTX video on the 8060S, where it was faster than Vulkan
CUDA NVIDIA builds from the same script; not tested yet
Metal Apple silicon and Intel Macs builds from the same script; not tested yet
CPU any no GPU; slow, but useful to check a setup

Choosing a GPU backend covers each one and the settings that matter. Reports and fixes for the untested ones are welcome.

Fornax is Apache 2.0. The engines it builds against are MIT-licensed. Check each model’s own license before you use what it makes: some are non-commercial (YuE2’s weights are CC BY-NC 4.0, for example).