Support llama3 eagle3 head with llama4 verifier (#25961)
Signed-off-by: rahul-tuli <rtuli@redhat.com> Signed-off-by: Rahul Tuli <rtuli@redhat.com>
This commit is contained in:
@@ -2943,15 +2943,24 @@ class GPUModelRunner(LoRAModelRunnerMixin, KVConnectorModelRunnerMixin):
|
||||
logger.info("Loading drafter model...")
|
||||
self.drafter.load_model(self.model)
|
||||
if self.use_aux_hidden_state_outputs:
|
||||
if supports_eagle3(self.model):
|
||||
self.model.set_aux_hidden_state_layers(
|
||||
self.model.get_eagle3_aux_hidden_state_layers()
|
||||
)
|
||||
else:
|
||||
if not supports_eagle3(self.model):
|
||||
raise RuntimeError(
|
||||
"Model does not support EAGLE3 interface but "
|
||||
"aux_hidden_state_outputs was requested"
|
||||
)
|
||||
|
||||
# Try to get auxiliary layers from speculative config,
|
||||
# otherwise use model's default layers
|
||||
aux_layers = self._get_eagle3_aux_layers_from_config()
|
||||
if aux_layers:
|
||||
logger.info(
|
||||
"Using auxiliary layers from speculative config: %s",
|
||||
aux_layers,
|
||||
)
|
||||
else:
|
||||
aux_layers = self.model.get_eagle3_aux_hidden_state_layers()
|
||||
|
||||
self.model.set_aux_hidden_state_layers(aux_layers)
|
||||
time_after_load = time.perf_counter()
|
||||
self.model_memory_usage = m.consumed_memory
|
||||
logger.info(
|
||||
@@ -3006,6 +3015,30 @@ class GPUModelRunner(LoRAModelRunnerMixin, KVConnectorModelRunnerMixin):
|
||||
self.model, self.vllm_config, CUDAGraphMode.NONE, self.device
|
||||
)
|
||||
|
||||
def _get_eagle3_aux_layers_from_config(self) -> Optional[tuple[int, ...]]:
|
||||
"""Extract Eagle3 auxiliary layer indices from speculative config.
|
||||
|
||||
These indices specify which hidden states from the base model should
|
||||
be used as auxiliary inputs for the Eagle3 drafter model during
|
||||
speculative decoding.
|
||||
|
||||
Returns:
|
||||
Tuple of layer indices if found in draft model config,
|
||||
None otherwise.
|
||||
"""
|
||||
if not (self.speculative_config and self.speculative_config.draft_model_config):
|
||||
return None
|
||||
|
||||
hf_config = self.speculative_config.draft_model_config.hf_config
|
||||
if not hasattr(hf_config, "eagle_aux_hidden_state_layer_ids"):
|
||||
return None
|
||||
|
||||
layer_ids = hf_config.eagle_aux_hidden_state_layer_ids
|
||||
if layer_ids and isinstance(layer_ids, (list, tuple)):
|
||||
return tuple(layer_ids)
|
||||
|
||||
return None
|
||||
|
||||
def reload_weights(self) -> None:
|
||||
assert getattr(self, "model", None) is not None, (
|
||||
"Cannot reload weights before model is loaded."
|
||||
|
||||
Reference in New Issue
Block a user