[XPU] Fix Eagle3 initialization on XPU (#43957)
Signed-off-by: Chaojun Zhang <chaojun.zhang@intel.com> Co-authored-by: Andreas Karatzas <akaratza@amd.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Kunshang Ji <kunshang.ji@intel.com>
This commit is contained in:
co-authored by
Andreas Karatzas
mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Kunshang Ji
parent
78a04c208d
commit
d2ec433e37
@@ -1468,6 +1468,26 @@ class SpecDecodeBaseProposer:
|
||||
"Sharing target model embedding weights with the draft model."
|
||||
)
|
||||
|
||||
if share_embeddings:
|
||||
draft_embed = self.model.model.embed_tokens
|
||||
# Only share when both models use the same embedding width.
|
||||
# Guard with isinstance so non-Tensor weights (e.g. in tests)
|
||||
# are not affected — mirrors the weight-equality check above.
|
||||
if isinstance(target_embed_tokens.weight, torch.Tensor) and isinstance(
|
||||
draft_embed.weight, torch.Tensor
|
||||
):
|
||||
target_dim = target_embed_tokens.weight.shape[-1]
|
||||
draft_dim = draft_embed.weight.shape[-1]
|
||||
if target_dim != draft_dim:
|
||||
share_embeddings = False
|
||||
logger.info(
|
||||
"Target embedding dim (%d) differs from draft "
|
||||
"embedding dim (%d). Keeping separate embedding "
|
||||
"weights.",
|
||||
target_dim,
|
||||
draft_dim,
|
||||
)
|
||||
|
||||
if share_embeddings:
|
||||
if hasattr(self.model.model, "embed_tokens"):
|
||||
del self.model.model.embed_tokens
|
||||
|
||||
Reference in New Issue
Block a user