Skip to content

Audit tie_word_embeddings handling in custom model implementations #2512

Description

@yuhezhang-ai

Some custom CausalLM/VLM model classes expose or pass through tie_word_embeddings,
but not all of them explicitly implement weight tying between the input embeddings
and lm_head.

This is usually fine for current released configs because many of these models
intentionally default to tie_word_embeddings=False, and some architectures may
require separate embedding/head weights, especially with pipeline parallelism or
asymmetric model structure.

However, the behavior is confusing when a user sets tie_word_embeddings=True.
It may not be obvious whether the model should actually tie lm_head.weight to
embed_tokens.weight, or whether the config value should be rejected or
documented as unsupported.

Suggested cleanup

Audit custom nn.Module model implementations that define lm_head and input
embeddings:

  • If the architecture supports tied embeddings, add explicit _tied_weights_keys
    and tie_weights() handling.
  • If the architecture intentionally requires separate weights, document that
    tie_word_embeddings=True is unsupported or validate against it.
  • Add small tied/untied config tests where tying is supported.

This is not currently considered an urgent checkpoint-resume correctness issue
after the tied-lm-head checkpoint guard in #2511, but it would make model behavior clearer
and safer for future configs.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions