Enable Eagle3 speculative decoding for GPT-OSS model (#25246)

Signed-off-by: Eldar Kurtic <8884008+eldarkurtic@users.noreply.github.com>
This commit is contained in:
Eldar Kurtić
2025-09-22 08:50:39 +00:00
committed by GitHub
parent f92d952632
commit 21467f9a1c
3 changed files with 41 additions and 12 deletions
+23 -9
View File
@@ -823,15 +823,29 @@ class EagleProposer:
else:
target_language_model = target_model
# share embed_tokens with the target model if needed
if get_pp_group().world_size == 1 \
and self.model.model.embed_tokens.weight.shape \
== target_language_model.model.embed_tokens.weight.shape:
logger.info(
"Assuming the EAGLE head shares the same vocab embedding"
" with the target model.")
del self.model.model.embed_tokens
self.model.model.embed_tokens = (
target_language_model.model.embed_tokens)
if get_pp_group().world_size == 1:
if hasattr(target_language_model.model, 'embed_tokens'):
target_embed_tokens = target_language_model.model.embed_tokens
elif hasattr(target_language_model.model, 'embedding'):
target_embed_tokens = target_language_model.model.embedding
else:
raise AttributeError(
"Target model does not have 'embed_tokens' or 'embedding' "
"attribute")
# Check if shapes match and we found the embedding
eagle_shape = self.model.model.embed_tokens.weight.shape
target_shape = target_embed_tokens.weight.shape
if eagle_shape == target_shape:
logger.info(
"Assuming the EAGLE head shares the same vocab embedding"
" with the target model.")
del self.model.model.embed_tokens
self.model.model.embed_tokens = target_embed_tokens
else:
logger.info(
"The EAGLE head's vocab embedding will be loaded separately"
" from the target model.")
else:
logger.info(
"The EAGLE head's vocab embedding will be loaded separately"