Skip to content
5 changes: 4 additions & 1 deletion megatron/core/transformer/multi_token_prediction.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,10 +642,13 @@ def process_mtp_loss(
Returns:
Tensor: Updated hidden states after MTP loss processing (first chunk only).
"""
mtp_labels = labels.clone()
hidden_states_list = torch.chunk(hidden_states, 1 + config.mtp_num_layers, dim=0)
hidden_states = hidden_states_list[0]

if labels is None:
return hidden_states

mtp_labels = labels.clone()
if loss_mask is None:
loss_mask = torch.ones_like(mtp_labels)

Expand Down
Loading