Skip to content

Improve performance of gemma4 MoE inference.#3875

Open
NicoGrande wants to merge 1 commit into
mainfrom
nicogrande/improve-gemma4-vllm-perf
Open

Improve performance of gemma4 MoE inference.#3875
NicoGrande wants to merge 1 commit into
mainfrom
nicogrande/improve-gemma4-vllm-perf

Conversation

@NicoGrande
Copy link
Copy Markdown
Collaborator

Description

This PR introduces a small, inference specific optimization to reduce overall step time. Specifically, this PR moves the per-expert scale application to the model initialization instead of during the call method, given that these parameters are static during inference.

Tests

vllm_decode.py before and after.

Step time without this PR: 13.59 ms
Step time with this PR: 7.975 ms

Checklist

Before submitting this PR, please make sure (put X in square brackets):

  • I have performed a self-review of my code. For an optional AI review, add the gemini-review label.
  • I have necessary comments in my code, particularly in hard-to-understand areas.
  • I have run end-to-end tests tests and provided workload links above if applicable.
  • I have made or will make corresponding changes to the doc if needed, including adding new documentation pages to the relevant Table of Contents (toctree directive) as explained in our documentation.

Comment thread src/maxtext/layers/moe.py Outdated
@NicoGrande NicoGrande force-pushed the nicogrande/improve-gemma4-vllm-perf branch from 1bea1ad to e3bc236 Compare May 11, 2026 22:28
@codecov
Copy link
Copy Markdown

codecov Bot commented May 11, 2026

Codecov Report

❌ Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/maxtext/layers/moe.py 0.00% 1 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

@NicoGrande NicoGrande force-pushed the nicogrande/improve-gemma4-vllm-perf branch from 2f91e1b to 5b0ae2f Compare May 11, 2026 23:58
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.

3 participants