Eagle3 DP attention for Qwen3 MoE (#12002)
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
from dataclasses import dataclass
|
||||
from enum import Enum, auto
|
||||
from functools import partial
|
||||
from typing import Dict, Optional
|
||||
from typing import Dict, List, Optional
|
||||
|
||||
import torch
|
||||
|
||||
@@ -216,6 +216,28 @@ class LayerCommunicator:
|
||||
get_global_server_args().speculative_algorithm
|
||||
)
|
||||
|
||||
def prepare_attn_and_capture_last_layer_outputs(
|
||||
self,
|
||||
hidden_states: torch.Tensor,
|
||||
residual: torch.Tensor,
|
||||
forward_batch: ForwardBatch,
|
||||
captured_last_layer_outputs: Optional[List[torch.Tensor]] = None,
|
||||
):
|
||||
hidden_states, residual = self.prepare_attn(
|
||||
hidden_states, residual, forward_batch
|
||||
)
|
||||
if captured_last_layer_outputs is not None:
|
||||
gathered_last_layer_output = self._communicate_simple_fn(
|
||||
hidden_states=residual,
|
||||
forward_batch=forward_batch,
|
||||
context=self._context,
|
||||
)
|
||||
if gathered_last_layer_output is residual:
|
||||
# Clone to avoid modifying the original residual by Custom RMSNorm inplace operation
|
||||
gathered_last_layer_output = residual.clone()
|
||||
captured_last_layer_outputs.append(gathered_last_layer_output)
|
||||
return hidden_states, residual
|
||||
|
||||
def prepare_attn(
|
||||
self,
|
||||
hidden_states: torch.Tensor,
|
||||
|
||||
Reference in New Issue
Block a user