Skip to content

Gemma 4 on the batched-decode branch: merge #120 + perf findings (CUDA graphs +13.6%)#1

Open
mikepapadim wants to merge 18 commits into
feat/static-batched-decodefrom
feat/gemma4-batched-decode
Open

Gemma 4 on the batched-decode branch: merge #120 + perf findings (CUDA graphs +13.6%)#1
mikepapadim wants to merge 18 commits into
feat/static-batched-decodefrom
feat/gemma4-batched-decode

Conversation

@mikepapadim

Copy link
Copy Markdown
Owner

Gemma 4 on the batched-decode branch

Merges Gemma 4 support (PR beehive-lab#120, gemma4-new) onto the vLLM-style batched-decode work
(feat/static-batched-decode, PR beehive-lab#129) and evaluates squeezing Gemma 4 decode perf. Full
write-up: GEMMA4_BATCHED.md. Model: unsloth/gemma-4-E2B-it-Q8_0 (5 GB), RTX 4090, CUDA backend.

Results

  • Clean merge — Gemma 4 coexists with all batched-decode features; builds + runs.

  • Stock Gemma 4 GPU decode works"The capital of France is **Paris**."

  • CUDA graphs (model-agnostic) squeeze:

    Gemma-4-E2B Q8_0 tok/s speedup
    no CUDA graphs 22.3 / 11.5 (200-tok) 1.0×
    CUDA graphs 25.3 / 12.3 +13.6% / +6.5%

Why full batched decode is a larger follow-up

Gemma 4 (Gemma-3n-class MatFormer) breaks the batched-decode engine's uniform-layer assumptions:
per-layer head/FFN dims, alternating sliding-window / full attention, shared-KV layers,
per-layer embeddings (PLE) + AltUp, pre+post norms + per-head Q/K RMSNorm + query scaling,
GeGLU (not SiLU), NEOX RoPE with two thetas, final logit softcap, and BF16/Q8_0
weights (no plain FP16 for the FP16 MMA path). A Gemma 4 batched-decode layer graph therefore
needs new windowed decode attention, GeGLU FFN, and NEOX RoPE kernels + Gemma
norm/scale tasks + shared-KV addressing + a PLE embedding path + a BF16-or-FP16 weight story —
a dedicated multi-file build, not a small fork.

What transfers for free

The engine-level features (on-device sampling, continuous batching, PagedAttention,
prefix caching, logits-skip) are model-agnostic and drop in once a Gemma 4 batched
forward exists. On-device sampling would help Gemma 4 more (vocab ~262 k → bigger per-step D2H);
greedy stays valid through the monotonic tanh softcap.

Tracked in the vLLM roadmap issue beehive-lab#130. Base branch: feat/static-batched-decode (PR beehive-lab#129).

mikepapadim and others added 18 commits June 7, 2026 22:50
…y stock GPU decode, CUDA-graphs +13.6%, batched-decode adaptation analysis
…nel (scale 1.0), validated bit-exact; port plan
…ernels complete + bit-exact; remaining is layer-graph assembly
…e, layerBaseOff) for per-layer/shared KV; re-validated
…F16 PLE matvec + FP16 norm-apply; E2B dims probed (1536/35L/nHeadKv=1/PLE F32)
…Dim-512 + F32-PLE handled); engine assembly is the remaining integration
…Configuration + parameterize RoPE theta; full serving stack works (12x batched, coherent, prefix-consistent)
…, no crash); fixed HalfFloat-lowering (local var) + double-embed-scale + scale/normed buffer aliasing. Forward still produces garbage - wiring bug pending intermediate-value debug
…ot NaN/scale); residual non-accumulating (wrapX ~0.1); PLE affects but not sole bug; CPU-ref needs 2nd standard-weights model. Debug flags: gemma.noPle/cpuRef/dbg
… CPU forward for Q8 Gemma per-layer-token-embd; cpuRef harness (2nd standard-weights model) hits pre-existing CPU-path AIOOB
…hout (rms 0.2-1.0, no blowup) - subtle direction bug, not a corrupting layer; references blocked by CPU-path bugs
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