Repository navigation
Conversation
ae5719b to
17f86f2
Compare
Targets with tie_word_embeddings=True (e.g. Qwen2.5-0.5B-Instruct) store only model.embed_tokens.weight, so TargetHead failed with "Target head key 'lm_head.weight' is missing". When the head key is absent and the target config (top level or text_config) is tied, load cfg.model.embedding_key instead. A stored head still takes precedence and untied targets keep the existing error. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@cih9088 thank you for this PR. I filed issue #927 because even with your fix, Qwen2.5-0.5B still fails because cih9088/SpecForge@feature/robust-weight-load...lru49:SpecForge:fix/target-head-tied-embeddings Tell me if you think this makes more sense as a separate PR. edit: my changes have been merged into this PR branch, so the diff link above no longer shows any changes |
|
@lru49 |
|
Thanks @cih9088 ! I just merged my changes |
|
@cih9088 Have you posted this PR in sglang slack for review? That could help get eyes on it |
@lru49 no, I didn't join the slack. If you happened to be in the slack, be my guest. I have no idea who to ping. Could you take a look at this PR? @curnane-lab @jiapingW |
| cache_dir=cache_dir, | ||
| ) | ||
| except KeyError as exc: | ||
| if not self._ties_word_embeddings(): |
There was a problem hiding this comment.
For a tied checkpoint that still stores lm_head.weight, this prefers the stored lm_head while TargetEmbeddingsAndHead (and transformers, which re-ties after load) ignores it — worth picking one answer for both.
Motivation
When loading the weights for
TargetHead, the logic looks formodel.safetensors.index.jsonand raises an error if it is not found. Howevermodel.safetensors.index.jsonexits only if the model weights are shards. (index creation, index saving intransformers).Some of checkpoint loading logics implemented this feature and they are scattered around. I factored them out to a single utility function
Modifications
Related Issues
Closes #927
Accuracy Test
Benchmark & Profiling
Checklist