Draft
Conversation
…ith InferenceCoreWithPrefillDecode and InferenceEngineWithPrefillDecode
… Implements `InferenceEngineWithPrefillDecode` and `TornadoVMMasterPlanWithPrefillDecode` for batched token generation. Refactor `Llama` to support the batched prefill flag.
…king state, with cuda graphs only)
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 WIP PR implements the prefill-decode concept in GPULlama3.java:
Based on the above, this PR breaks down the prefill-decode feature implementation in 4 discrete phases:
Phase 1: splits CPU inference to prefill + decode (no batching, skip logits during prefill)
Phase 2: splits GPU inference to prefill + decode (no batching, skip logits during prefill)
Phase 3: adds batching to CPU prefill
Phase 4: adds batching to GPU prefill
Current Working and Performance State
The implementation is progressing in stages, with varying levels of completeness across phases and configurations.
Functional Status
Phases 1–3 are fully implemented and functional for:
Remaining work:
Phase 4 (GPU prefill batching):
Performance State (RTX 5090 ROG Laptop, TornadoVM PTX Backend)
The following results were collected using LLaMA 1B FP16 and batch size 32:
Key Observations
Prefill batching is already beneficial for both CPU and GPU (Phases 1–4):
Long prompts benefit the most, confirming that prefill dominates runtime as input grows
GPU + batched prefill (Phase 4) delivers the highest throughput:
Summary