Skip to content

[Bugfix] Load untied Gemma LM head weights - #53170

Merged
khluu merged 1 commit into
mainfrom
fix/gemma-tied-lm-head
Aug 21, 2026
Merged

khluu merged 1 commit into
mainfrom
fix/gemma-tied-lm-head

Conversation

@khluu

@khluu khluu commented Aug 20, 2026 •

Copy link
Copy Markdown
Member

Purpose

Fix Gemma checkpoint loading after #51665 when a config declares tied word embeddings but the checkpoint contains a physical lm_head.weight.

Checkpoint inspection deliberately flips tie_word_embeddings to False so the physical head can be compared with the input embeddings after loading. GemmaForCausalLM did not construct an lm_head, so GPTQ Gemma checkpoints failed with There is no module or parameter named 'lm_head'. This change constructs the output head, ties it to the input embeddings for normally tied configs, and uses it for logits.

Duplicate-work check: searched open PRs and issues for Gemma lm_head weight, tie_word_embeddings Gemma, and the affected TechxGenus/gemma-1.1-2b-it-GPTQ model. No open change addresses this Gemma loader failure; #30412 is scoped to GGUF mapping.

AI assistance was used to investigate the regression, implement the change, and draft the test. The submitting human reviewed the changed lines and validation results.

Test Plan

  • Focused CPU regression for checkpoint-driven Gemma untying.
  • Pre-commit hooks on both changed files.
  • Exact H200 Quantized Models Buildkite job with TechxGenus/gemma-1.1-2b-it-GPTQ at this PR head.

Test Result

  • .venv/bin/python -m pytest tests/models/language/generation/test_gemma.py -q -k checkpoint_lm_head_can_override_tied_config: 1 passed, 3 deselected.
  • uvx pre-commit run --files vllm/model_executor/models/gemma.py tests/models/language/generation/test_gemma.py: all applicable hooks passed, including ruff and mypy.
  • Model evaluation: Buildkite #84894 passed at exact PR commit d3494fc2 on H200 (h200-ci-3). The complete Quantized Models suite finished 22 passed, 32 skipped, 0 failed in 33m16s of pytest time (34m27s job wall time). Both formerly failing TechxGenus/gemma-1.1-2b-it-GPTQ cases passed: test_models[5-32-half-model2] and test_models[5-32-bfloat16-model2]. Proposed fix is validated; the incident remains open until merge and a post-merge main exact-job pass.

Assisted-by: OpenAI Codex

Signed-off-by: Kevin Luu <51931015+khluu@users.noreply.github.com>
@mergify mergify Bot added the bug Something isn't working label Aug 20, 2026
@khluu
khluu marked this pull request as ready for review August 20, 2026 22:15

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.

Tip: disable this comment in your organization's Code Review settings.

@khluu

khluu commented Aug 20, 2026

Copy link
Copy Markdown
Member Author

/ci run

@github-actions

Copy link
Copy Markdown

✅ Triggered Buildkite CI #84897 for commit d3494fc2281b.

@khluu
khluu enabled auto-merge (squash) August 20, 2026 23:02
@github-actions github-actions Bot added the ready ONLY add when PR is ready to merge/full CI is needed label Aug 20, 2026
@khluu
khluu merged commit d29f7f5 into main Aug 21, 2026
104 checks passed
@khluu
khluu deleted the fix/gemma-tied-lm-head branch August 21, 2026 00:47
zufangzhu pushed a commit to zufangzhu/vllm that referenced this pull request Aug 24, 2026
Signed-off-by: Kevin Luu <51931015+khluu@users.noreply.github.com>
Signed-off-by: Zhu, Zufang <zufang.zhu@intel.com>
am-cohere pushed a commit to am-cohere/vllm that referenced this pull request Sep 1, 2026
Signed-off-by: Kevin Luu <51931015+khluu@users.noreply.github.com>
michael-gpu pushed a commit to practical-inference/vllm-ampere-extended that referenced this pull request Oct 20, 2026
Signed-off-by: Kevin Luu <51931015+khluu@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ready ONLY add when PR is ready to merge/full CI is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants