recoverssm: allow pipeline parallelism for Qwen4Exp on the V2 runner

Upstream RecoverSSM commits a step in the same step's postprocess, hence PP=1. Under pipeline parallelism a
non-last rank learns a step's accepted counts only when the PP broadcast arrives pp_size steps later, while later
builds overwrite the persistent commit inputs. The commit is now deferred with its own copy of those inputs, and
the PP=1 check is lifted for Qwen4Exp on Model Runner V2. Config and CPU tests cover the deferral.

Co-Authored-By: Hinata <hinata@idihore.id>
Signed-off-by: MOVZX <movzx@yahoo.com>
This commit is contained in:
2026-10-09 20:08:56 +07:00
co-authored by Hinata
parent 8918d40b59
commit 812d662602
10 changed files with 254 additions and 7 deletions
+30 -1
View File
@@ -3,7 +3,7 @@
"""Pipeline Parallelism utils for V2 Model Runner."""
from collections import deque
from dataclasses import dataclass
from dataclasses import dataclass, replace
import numpy as np
import torch
@@ -33,6 +33,9 @@ class PendingRecv:
# detect requests aborted since then.
gen_at_receive_np: np.ndarray # [num_reqs]
draft_tokens: torch.Tensor | None = None # [num_reqs, num_speculative_steps]
# Model-state data the step's postprocess needs once the sampled tokens
# arrive (RecoverSSM: the snapshot of the step's deferred commits).
deferred_state: object | None = None
def compute_need_sampled_mask(input_batch: InputBatch) -> np.ndarray | None:
@@ -167,8 +170,34 @@ class PPHandler:
num_sampled=slot.num_sampled,
num_rejected=slot.num_rejected,
idx_mapping=idx_mapping,
deferred_state=slot.deferred_state,
)
def attach_deferred_state(self, state: object | None) -> None:
"""Attach model-state data to the entry `receive` just reserved for this
step. Called right after `receive` in the same step."""
assert not self.is_last_rank
if state is None:
return
slot = self.queue[-1]
if slot is None:
# receive() skipped the broadcast: no row of this step samples, so
# no row can have a speculative window to commit.
raise RuntimeError(
"deferred model state for a step without sampled outputs"
)
self.queue[-1] = replace(slot, deferred_state=state)
def drop_deferred_states(self) -> int:
"""Release every pending entry's deferred state (profiling teardown: the
state references the KV cache it was built for). Returns the count."""
dropped = 0
for i, slot in enumerate(self.queue):
if slot is not None and slot.deferred_state is not None:
self.queue[i] = replace(slot, deferred_state=None)
dropped += 1
return dropped
def broadcast_drafts(
self, draft_tokens: torch.Tensor, input_batch: InputBatch
) -> None: