Fix DSpark + DeepSeek V4 prefill CP compatibility (#33865)
This commit is contained in:
@@ -371,14 +371,27 @@ class EagerRunner(BaseRunner):
|
||||
else hidden_states
|
||||
)
|
||||
|
||||
hidden_states = cp_gather_after_forward(
|
||||
hidden_states, forward_batch, torch.cuda.current_stream()
|
||||
)
|
||||
stream = torch.cuda.current_stream()
|
||||
hidden_states = cp_gather_after_forward(hidden_states, forward_batch, stream)
|
||||
# DSpark aux tensors ride the same CP token split; gather them the same way.
|
||||
if aux_hidden_states is not None:
|
||||
if isinstance(aux_hidden_states, torch.Tensor):
|
||||
aux_hidden_states = cp_gather_after_forward(
|
||||
aux_hidden_states, forward_batch, stream
|
||||
)
|
||||
else:
|
||||
aux_hidden_states = [
|
||||
cp_gather_after_forward(aux, forward_batch, stream)
|
||||
for aux in aux_hidden_states
|
||||
]
|
||||
logits_kwargs = {}
|
||||
# DSV4 returns (hidden_states, hidden_states_before_norm) from its model body.
|
||||
if isinstance(hidden_states, tuple):
|
||||
hidden_states, hidden_states_before_norm = hidden_states
|
||||
logits_kwargs["hidden_states_before_norm"] = hidden_states_before_norm
|
||||
# Mirror DeepseekV4ForCausalLM.forward: drop pre_hc_head when
|
||||
# DSpark aux capture is on, else it overrides the packed aux.
|
||||
if aux_hidden_states is None:
|
||||
logits_kwargs["hidden_states_before_norm"] = hidden_states_before_norm
|
||||
return model.logits_processor(
|
||||
forward_batch.input_ids,
|
||||
hidden_states,
|
||||
|
||||
Reference in New Issue
Block a user