feat(gemma4/rocm): FP8 resident MoE + SharedK-WMMA (split from #228) - #317
Conversation
b73018c to
72e734f
Compare
b7a0622 to
2f58e58
Compare
2f58e58 to
606e894
Compare
localai-org-maint-bot
left a comment
There was a problem hiding this comment.
@bakon11 This is not reviewable/mergeable with the PR body itself listing tests/spec as honest follow-ups. The ~5k-line production change needs the project-required spike/spec, focused automated parity/regression coverage for the new resident MoE/peer/SharedK/decode paths, and the same-change STATUS/BENCHMARKS/matrix/state evidence anchors required by AGENTS.md. Please land those in this PR (or split the stack further) before asking for merge.
|
@localai-org-maint-bot Addressed the mergeability blockers you named:
Local: |
Maint-bot mudler#317: land the project-required spike/spec and a focused automated CPU gate for the portable fused_ops FP8 ExpertGeGLU seams (no AMD runner). Lab RDNA4 quality/speed remains recipe evidence; CUDA SACRED gates unchanged. FOLLOWING_AGENTS_PROTOCOL Following-Agents-Protocol: true AI-Assisted: true Assisted-by: Hermes:grok-4.5 [Hermes]
|
Reviewed while landing the external-PR queue. Holding this one — not rejecting it; the ROCm half looks good and the levers are honestly gated. The blocker is that it is not ROCm-only. Why it is held672 of the added lines are in The specific change I cannot sign off without a run is What would close it
What I checked and am not worried about
Splitting the unconditional Reviewed with Claude Code while landing #309/#316/#326/#328/#334-#348. Nothing here is a request to change the ROCm kernels. |
…estructure) Rebuild of mudler#317 on current origin/main. Keeps ROCm FP8 ExpertGeGLU, SharedK-WMMA prefill, fused_ops seams, expert LRU/prewarm, and CPU seam test. Deferred (localai-bot hold): ForwardGemma4Layers extract, Gemma4DecodeGraph, and any unguarded gemma4.cpp layer-loop restructure that would require a GB10 token-exact golden. Those remain lab-only until a separate CUDA-gated PR. FOLLOWING_AGENTS_PROTOCOL Following-Agents-Protocol: true AI-Assisted: true Assisted-by: Hermes:grok-4.5 [Hermes]
17df82f to
a5bd7ad
Compare
Rebuilt on current
|
| Deferred (lab-only / later PR) | Still in #317 |
|---|---|
ForwardGemma4Layers extract |
ROCm FP8 ExpertGeGLU + channel GEMV |
Gemma4DecodeGraph / decode hipGraph |
SharedK + SharedK-WMMA prefill |
| MLP∥MoE side-stream wiring | vt::fused_ops portable seams |
| Any CUDA-path layer-loop rewrite | Expert LRU / host cache / prewarm |
| GB10 token-exact requirement for this tip | DeviceMemoryInfo backend seam |
CPU seam test test_gemma4_rocm_fp8_seams |
|
| Spec + ENVIRONMENT/FEATURES/USAGE |
gemma4.cpp / gemma4.h are unchanged vs main in this tip. Registry only adds ExpertGeGLU prewarm after resident upload (no graph hook).
Bot checklist
- Token-exact GB10 — N/A for this tip (no forward restructure). Happy to land graph/extract later with golden.
- TLS vs graph capture — N/A (no Gemma4 decode graph in PR).
- thread_local lifetime — only existing main layer TLS remains; no new capture driver.
Local gates (green)
check-device-leakagecheck-env-doccheck-doc-checkpointcheck-agent-recordcheck-pr-size(feat(gemma4/rocm): FP8 resident MoE + SharedK-WMMA (split from #228) #317)
Sanitize-cpu ASan/TSan ambient noise may still red; not specific to this payload.
Please re-review when CI settles on a5bd7ad0.
|
Hardware-checked on dgx (GB10) — this PR is clear of the concern I raised, and the check found an unrelated bug on Two things, both useful to you: 1. The CUDA-forward concern is resolved. Your 2. The Gemma-4 SACRED gate was already RED on …and the baseline arm failed identically. Root cause was Please rebase — the gate can actually run for you now. What this does and does not tell us about #317. It says the PR does not regress the shipped Gemma-4 CUDA path. It says nothing about the FP8 resident MoE work itself, and cannot: The remaining review comment on the earlier head still applies to what is left: Two smaller things while I was in there: Checked with Claude Code. dgx GPU work was serialized behind |
a5bd7ad to
d1c4a65
Compare
…estructure) Rebuild of mudler#317 on current origin/main. Keeps ROCm FP8 ExpertGeGLU, SharedK-WMMA prefill, fused_ops seams, expert LRU/prewarm, and CPU seam test. Deferred (localai-bot hold): ForwardGemma4Layers extract, Gemma4DecodeGraph, and any unguarded gemma4.cpp layer-loop restructure that would require a GB10 token-exact golden. Those remain lab-only until a separate CUDA-gated PR. FOLLOWING_AGENTS_PROTOCOL Following-Agents-Protocol: true AI-Assisted: true Assisted-by: Hermes:grok-4.5 [Hermes]
Rebased on current main (post-#377 gate fix)Tip: Thanks for the GB10 hardware check — confirmed:
What CUDA / non-ROCm builds do with this tip
ROCm lab evidence (this box — not GB10)
Default-on ROCm knobs (explicit)These change ROCm default behavior when unset (documented in ENVIRONMENT); non-ROCm unaffected:
KV cache dtype (separate from weight FP8)Serve selection is env today (llama.cpp-style intent, different surface):
Local gates on
|
|
Rebased for you and re-gated on hardware — the CUDA concern is now measured and closed. I merged current Gate result — dgx GB10, both arms in one
|
| arm | tree | result |
|---|---|---|
gmain |
main |
gemma4-E4B STRICT: 32/32 token-exact vs vLLM 0.25.0 golden |
g317 |
main + this PR |
32/32 token-exact |
Same box, same checkpoint, same minute. This PR does not regress the shipped Gemma-4 CUDA path — that is the concern I raised originally, and it is now settled by measurement rather than by reading the diff. gemma4.cpp also remains byte-identical to main after the merge.
One fix carried in
The pre-push hook refused my merge, correctly: this branch's docs/FEATURES.md row was 254 chars against the 220-char cell budget that check-public-doc-tables enforces in CI, so the PR would have gone red there. Trimmed to 219 keeping every fact — dual-GPU FP8 resident experts, SharedK-WMMA prefill on RDNA4, the deferred decode-graph/forward extract, the env prefixes, the CPU seam test — with the spec link carrying the detail. Commit is on the branch.
What is still owed, and it is not much
The gate above proves non-regression. It cannot prove the feature, and no run on my side ever will: unsloth/gemma-4-E4B-it is dense bf16 with enable_moe_block: False, all nine Gemma checkpoints cached on that box are the same, and the FP8 path is hipBLASLt regardless — so RunGemma4Moe, EnsureGemma4Fp8*, ExpertGeGLU* and the guarded registry prewarm are simply unreachable on GB10.
So the last thing this PR needs is from your ROCm box:
- Which board and which MoE checkpoint you ran, and the result. A short paragraph in the PR body is enough — it does not need to be a formal gate.
- A line confirming what a CUDA build does with these changes. From my reading it is nothing (every new lever is env-gated off or behind
moe.enabled), and the gate above is consistent with that, but you know the code better.
Worth stating explicitly in the body too: VT_GEMMA4_PREFILL_PEER_ACT, VT_ATTN_PREFILL_FLASH_SHAREDK, VT_ATTN_PREFILL_SHAREDK_WMMA and VT_ROCM_GRAPH default on. That is fine — they are all ROCm-path — but they change default behavior on ROCm boards and a reader should not have to diff docs/ENVIRONMENT.md to find out.
Backend::DeviceMemoryInfo is a clean additive seam with a false default; no objection there at all.
Thanks for turning the CUDA forward restructure around so quickly — that is what made this checkable.
Rebased and gated with Claude Code. dgx GPU work serialized behind flock $HOME/gpu.lock alongside another session's campaign; nothing of theirs was touched.
…estructure) Rebuild of mudler#317 on current origin/main. Keeps ROCm FP8 ExpertGeGLU, SharedK-WMMA prefill, fused_ops seams, expert LRU/prewarm, and CPU seam test. Deferred (localai-bot hold): ForwardGemma4Layers extract, Gemma4DecodeGraph, and any unguarded gemma4.cpp layer-loop restructure that would require a GB10 token-exact golden. Those remain lab-only until a separate CUDA-gated PR. FOLLOWING_AGENTS_PROTOCOL Following-Agents-Protocol: true AI-Assisted: true Assisted-by: Hermes:grok-4.5 [Hermes]
FOLLOWING_AGENTS_PROTOCOL Following-Agents-Protocol: true AI-Assisted: true Assisted-by: Hermes:grok-4.5 [Hermes]
984f0c1 to
c03304d
Compare
…dK-WMMA (#41) Lands bakon11's work from PR #317, split out of #228. Merged --no-ff so the contributor commits keep their authorship rather than being re-authored to whoever pressed the button. FP8 resident MoE experts and a SharedK-WMMA prefill path for Gemma-4 on RDNA4 ROCm, plus a CPU seam test that pins the portable vt::ExpertGeGLUFp8* symbols link and the recipe env knobs parse inertly. The concern this PR was originally held on is CLOSED BY MEASUREMENT, not by reading the diff. It was held because ~1,600 added lines sat in gemma4.cpp and gemma4_moe.cpp and Gemma-4 is a gate model. bakon11 rebuilt it to drop the CUDA forward restructure entirely, and both arms were then gated on dgx GB10 in one flock window: `gmain` (main) and `g317` (main + this PR) each returned gemma4-E4B STRICT 32/32 token-exact vs the vLLM 0.25.0 golden. gemma4.cpp is byte-identical to main. Its cuda-fat-build red was never its own: the gencode audit failed on seven files, every one of them Marlin, while this branch touches ROCm and gemma4_moe.cpp and no Marlin gencode at all. That was the drift #407 fixed and the branch predated it -- the same stale-base class that also explained #383 and #393 tonight. ACCEPTED WITH A NAMED RESIDUAL, recorded because it is a product decision and not a gate result. This flips four knobs DEFAULT-ON for ROCm: VT_GEMMA4_PREFILL_PEER_ACT, VT_ATTN_PREFILL_FLASH_SHAREDK, VT_ATTN_PREFILL_SHAREDK_WMMA and VT_ROCM_GRAPH. Non-ROCm builds are unaffected -- every new lever is env-gated off or behind moe.enabled / ROCm ExpertGeGLU dispatch -- and each knob is individually reversible by env. But there is NO AMD CI runner, so those defaults rest entirely on the contributor's lab evidence (2x AMD Radeon AI PRO R9700 gfx1201 / RDNA4, ROCm 7.x, gemma-4-26B-A4B-it-fp8; prefill ~2k @11k, short decode ~45-52 t/s). Feature correctness is unprovable on GB10 and honestly so: all nine cached Gemma checkpoints there are dense bf16 with enable_moe_block false, so RunGemma4Moe, EnsureGemma4Fp8* and ExpertGeGLU* are simply unreachable. The GB10 gate proves NON-REGRESSION, never the feature. Gate: scripts/agent-preflight.sh rc=0 on the merged tree; check-agent-record, check-doc-checkpoint, check-public-doc-tables, check-now-current, check-env-doc and check-commit-trailers all green. CI is queue-blocked (#274), so the operator's own gate run is the authority, as AGENTS.md prescribes. FOLLOWING_AGENTS_PROTOCOL Following-Agents-Protocol: true AI-Assisted: true Assisted-by: AGENT:claude-opus-5 [Claude Code]
|
Landed on The hold is closed by measurement, not by reading the diff. Both arms gated on dgx GB10 in one Your Accepted with a residual I want on the record, because it is a product decision rather than a gate result. This flips four knobs default-ON for ROCm — Gate: |
Summary
ROCm / Gemma4 half of the #228 split. #228 is closed — land this instead.
In
Dual-GPU FP8 resident MoE, peer mix, SharedK-WMMA prefill, decode KV-split, fused_ops seam, ENVIRONMENT
VT_GEMMA4_*/VT_ATTN_*.Out
SSE/serving (#316),
rocm_sample(#234),support_static_graph_modeflip.Review fixes in this tip
#if VT_ROCWMMA_OKaround SharedK-WMMA launchesHonest follow-ups
HIP guards in
models/gemma4.cpp, MoE policy guards, peer weight_id/hscale, tests/spec. Large diff (~5k prod lines) — may need another slice or maintainer path like #154 if review asks.Lab: dual R9700 gfx1201 /
start-gemma4-fp8-8010.sh.Land order