Skip to content

cp: fix(gemma4_moe): re-tie lm_head to active embed_tokens on MoE path (2601) into r0.5.0 - #2709

Merged
akoumpa merged 1 commit into
r0.5.0from
cherry-pick-2601-r0.5.0
Jun 22, 2026
Merged

cp: fix(gemma4_moe): re-tie lm_head to active embed_tokens on MoE path (2601) into r0.5.0#2709
akoumpa merged 1 commit into
r0.5.0from
cherry-pick-2601-r0.5.0

Conversation

@svcnvidia-nemo-ci

Copy link
Copy Markdown
Contributor

beep boop [🤖]: Hi @Achyuthan-S 👋,

we've cherry picked #2601 into  for you! 🚀

Please review and approve this cherry pick by your convenience!

…2601)

* fix(gemma4_moe): re-tie lm_head to active embed_tokens on MoE path

The MoE path replaces language_model after HF __init__, orphaning the lm_head<->embed_tokens tie that HF set up. Re-tie lm_head to the active embed_tokens when tie_word_embeddings is set (Gemma defaults True). Add CPU tied/untied tests.

Refs #2512

Signed-off-by: Achyuthan-S <as21154@nyu.edu>

* refactor(gemma4_moe): expose MoE re-tie via tie_weights()
Wrap the post-swap lm_head re-point in a tie_weights() override so
AutoModel and ensure_tied_lm_head() re-tie to the active MoE embedding.
Add hook tests for re-tie and untied no-op.

Signed-off-by: Achyuthan Sivasankar <achyuthan.sivasankar@gmail.com>

* fix(gemma4_moe): make lm_head re-tie follow top-level config flag

Per review: HF Gemma4 ties on the top-level Gemma4Config.tie_word_embeddings regardless of the nested text_config (verified by construction on transformers 5.8.1). Read top-level first with a text_config fallback, set the top-level flag in tests, and add a case proving top-level wins when the two disagree.
Refs #2512

Signed-off-by: Achyuthan Sivasankar <achyuthan.sivasankar@gmail.com>

---------

Signed-off-by: Achyuthan-S <as21154@nyu.edu>
Signed-off-by: Achyuthan Sivasankar <achyuthan.sivasankar@gmail.com>
Signed-off-by: NeMo Bot <nemo-bot@nvidia.com>
@svcnvidia-nemo-ci
svcnvidia-nemo-ci requested a review from a team as a code owner June 22, 2026 16:52
@svcnvidia-nemo-ci svcnvidia-nemo-ci added cherry-pick Run CICD Trigger Testing CICD labels Jun 22, 2026
@svcnvidia-nemo-ci

Copy link
Copy Markdown
Contributor Author

/ok to test 8e289ee

@copy-pr-bot

copy-pr-bot Bot commented Jun 22, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@akoumpa

akoumpa commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

@akoumpa
akoumpa merged commit c6601c9 into r0.5.0 Jun 22, 2026
75 of 80 checks passed
@akoumpa
akoumpa deleted the cherry-pick-2601-r0.5.0 branch June 22, 2026 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cherry-pick Run CICD Trigger Testing CICD

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants