Repository navigation
Transformer & generation optimizations: Gemma 4 support, zero-copy WithSeqLens KV-cache prefill/decode, OnlyLastTokenLogits, and WithDonateStore - #501
Merged
Conversation
…32 RoPE angles for half-precision
…jections during prefill
…thSeqLens prefill, and dynamic promptExec
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
Transformer inference, KV-cache, and Gemma 4 improvements in
gomlx(companion to thecomputeandgo-huggingfacedemo-gen-aiPRs):use_double_wide_mlpsupport for KV-shared layers inml/zoo/transformer.pos.WithPartialRotaryFactor) and Float32 RoPE angle computation for half-precision (Float16/BFloat16) accuracy (ml/layers/attention/pos).WithSeqLens):WithSeqLens(kvLimit), avoiding full-cache buffer copies/slices during autoregressive generation, and fixed an off-by-one bug inPadTensors.promptExecto avoid per-length recompilation and unnecessary mask broadcasts.CallOptions.OnlyLastTokenLogitsto skip unused promptlm_headprojections during prefill (only computing logits for the final prompt token).Generator.WithDonateStore(ml/zoo/transformer/generate) to donate model weights to shared backend constants across prefill and decode graphs without duplicating memory.MaxRSSprintout at the end ofexamples/FlowMatching/demo/main.go.Verification
ml/layers/attention/pos/rope_test.goandml/zoo/transformer/transformer_test.go.google/gemma-4-E2B-it(BFloat16) against Ollama (gemma4:e2b-it-bf16).