Skip to content

Fix Gemma RMSNorm +1 offset missing on --checkpoint path#19901

Open
psiddh wants to merge 2 commits into
pytorch:mainfrom
psiddh:main
Open

Fix Gemma RMSNorm +1 offset missing on --checkpoint path#19901
psiddh wants to merge 2 commits into
pytorch:mainfrom
psiddh:main

Conversation

@psiddh
Copy link
Copy Markdown
Contributor

@psiddh psiddh commented May 30, 2026

The --checkpoint code path skipped the Gemma-specific RMSNorm weight adjustment (weight + 1). Gemma stores norm weights as deviations from 1 and computes (1 + w) * x, but ExecuTorch's RMSNorm computes w * x. The HF download path applied the +1 offset correctly, but passing a converted checkpoint via --checkpoint silently produced garbage output from all 36+ norm layers, regardless of quantization recipe.

##Test Plan

  • PASS: Gemma 1 2B and Gemma 3 1B run on S23 HTP at 23.5 and 48.6 tok/s after fixing the RMSNorm +1 offset
  • FAIL: Gemma 2 2B crashes because its attention soft-capping tanh op is unsupported on V73.(Need to test on S25)

Copilot AI review requested due to automatic review settings May 30, 2026 16:02
@psiddh psiddh requested a review from abhinaykukkadapu as a code owner May 30, 2026 16:02
@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented May 30, 2026

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/19901

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit dce6eca with merge base ec31735 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label May 30, 2026
@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla Bot commented May 30, 2026

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: psiddh / name: Siddartha Pothapragada (bae4e37)

@github-actions
Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes incorrect Gemma model behavior when supplying a pre-converted checkpoint via --checkpoint by ensuring Gemma RMSNorm weights are offset by +1 (to match Gemma’s (1 + w) * x convention) on that code path as well.

Changes:

  • Apply Gemma RMSNorm +1 weight offset when loading weights from --checkpoint.
  • Keep Gemma model handling consistent between HF-download and --checkpoint loading paths.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread examples/qualcomm/oss_scripts/llama/wrappers/llm_wrappers.py
The `--checkpoint` code path skipped the Gemma-specific RMSNorm weight
adjustment (`weight + 1`). Gemma stores norm weights as deviations from
1 and computes `(1 + w) * x`, but ExecuTorch's RMSNorm computes `w * x`.
The HF download path applied the +1 offset correctly, but passing a
converted checkpoint via `--checkpoint` silently produced garbage output
from all 36+ norm layers, regardless of quantization recipe.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants