Add prefill-decode and batch-prefill-decode for Qwen3 (FP16 and Q8_0)#122
Merged
Conversation
…`State` and `Configuration` in batch-prefill and batch-decode activations
…efill activations
… for Qwen3 models and FP16 and Q8_0 quantizations
stratika
reviewed
Jun 12, 2026
Comment on lines
+198
to
+199
| WorkerGrid rmsWorker = WorkerGridFactory.genericWorker(batchSize, 1); | ||
| WorkerGrid rmsApplyWorker = WorkerGridFactory.genericWorker(batchSize * dim, 256); |
Collaborator
There was a problem hiding this comment.
does it pass code formatting?
stratika
approved these changes
Jun 12, 2026
stratika
left a comment
Collaborator
There was a problem hiding this comment.
LGTM, just minor comments/questions. I tested it on macOS and Linux (with PTX).
mikepapadim
approved these changes
Jun 12, 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.
Summary
This PR extends the
prefill-decodeandbatch-prefill-decodeGPU inference paths to Qwen3 models for both FP16 and Q8_0 quantizations. It also adds corresponding coverage in CI.The core challenge is that Qwen3 diverges from Llama in two ways that affect every attention kernel:
Qwen3Kernels.rmsnormReductionWithParallelOffset/rmsnormNormalisationWithParallelOffset) and cannot reuse the scalar Llama path.Qwen3Configuration.headSize(),kvDim(), andkvMul()throw for Qwen3 (dimensions are stored differently). All new Qwen3 layers derive head dimensions fromnEmbdHeadK/nEmbdHeadV/nHeadKvdirectly.State changes
State.qDimandState.kvDimare made model-agnostic (previously carried Llama assumptions) so batch-prefill activations can be correctly sized for Qwen3's GQA layout.LlamaStateandLlamaConfigurationreferences in batch-prefill/batch-decode activations are replaced with the base
StateandConfigurationtypes.Verification