[Refactor] Send producer-written residual streams through to_pp (#41753)

This commit is contained in:
Cheng Wan
2026-09-29 21:11:02 -07:00
committed by GitHub
parent 843f50f5c1
commit faa5064f6e
3 changed files with 9 additions and 5 deletions
@@ -115,13 +115,19 @@ def to_pp(hidden_states, forward_batch, *, preserve_declared=True):
partial sum unreduced for the receiver's from_pp to complete; pass
False only when the receiver does not declare that sum.
Runtime-selected completion work is finished before transport.
Runtime-selected completion work is finished before transport. A stream
the producer already wrote (MHC writes its streams at the FFN exit) has no
separate residual and is sent as hidden_states alone; the receiver's
from_pp reconstructs it as written.
"""
hidden_states, residual = stream_of(forward_batch).export(
hidden_states, preserve_declared=preserve_declared
)
forward_batch.residual_stream = None
return PPProxyTensors({"hidden_states": hidden_states, "residual": residual})
tensors = {"hidden_states": hidden_states}
if residual is not None:
tensors["residual"] = residual
return PPProxyTensors(tensors)
def snapshot(hidden_states, forward_batch):
-2
View File
@@ -1185,8 +1185,6 @@ class Glm5NextModel(nn.Module):
)
if not self.pp_group.is_last_rank:
if self.config.mhc:
return PPProxyTensors({"hidden_states": hidden_states})
return residual_batch.to_pp(hidden_states, forward_batch)
else:
hidden_states = residual_batch.complete_output(hidden_states, forward_batch)