Stabilize spec-v2 draft graph metadata
Spec-v2 draft extend can receive token ids from producers whose dtype is not already int64, while DP collective paths require a stable integer dtype across ranks. EAGLE draft CUDA graph replay also pads raw batches to a captured batch size, so the metadata/replay path must see seq_lens_sum consistent with the padded seq_lens and then restore the caller-visible raw value. Constraint: Keep this as a narrow correctness port from upstream rather than pulling the larger spec-v2 refactor chain. Rejected: Cherry-pick broader attention-backend and decode-result refactors | current branch lacks the same upstream forward-context scaffolding and would require a separate port. Confidence: high Scope-risk: narrow Directive: Do not remove the seq_lens_sum restore without rechecking padded EAGLE draft CUDA graph metadata construction. Tested: python -m pytest test/registered/spec/eagle/test_eagle_v2_draft_extend_contract.py -q Tested: remote g0034/cjy-glm5-new PYTHONPATH=python python3 -m pytest test/registered/spec/eagle/test_eagle_v2_draft_extend_contract.py -q Not-tested: full multi-node GLM5 spec-v2 decode startup smoke Co-authored-by: OmX <omx@oh-my-codex.dev>
This commit is contained in:
@@ -411,12 +411,19 @@ class EAGLEDraftCudaGraphRunner:
|
||||
buffers.seq_lens_cpu[:raw_bs].copy_(forward_batch.seq_lens_cpu)
|
||||
forward_batch.seq_lens_cpu = buffers.seq_lens_cpu[:bs]
|
||||
|
||||
# Save the raw seq_lens_sum and keep it consistent with padded seq_lens
|
||||
# while replay metadata and graph kernels observe the padded fake rows.
|
||||
raw_seq_lens_sum = forward_batch.seq_lens_sum
|
||||
if bs != raw_bs and raw_seq_lens_sum is not None:
|
||||
forward_batch.seq_lens_sum = raw_seq_lens_sum + (
|
||||
bs - raw_bs
|
||||
) * self.seq_len_fill_value
|
||||
|
||||
self.model_runner.draft_attn_backend.init_forward_metadata_replay_cuda_graph(
|
||||
forward_batch, bs
|
||||
)
|
||||
self.raw_bs = raw_bs
|
||||
self.bs = bs
|
||||
# TODO: The forward_batch.seq_len_sum might need to be updated to reflect the padding in the cuda graph
|
||||
|
||||
# Replay
|
||||
self._replay(forward_batch)
|
||||
@@ -430,5 +437,6 @@ class EAGLEDraftCudaGraphRunner:
|
||||
forward_batch.req_pool_indices = buffers.req_pool_indices[:raw_bs]
|
||||
if forward_batch.seq_lens_cpu is not None:
|
||||
forward_batch.seq_lens_cpu = buffers.seq_lens_cpu[:raw_bs]
|
||||
forward_batch.seq_lens_sum = raw_seq_lens_sum
|
||||
|
||||
return out
|
||||
|
||||
@@ -192,7 +192,10 @@ class EagleDraftInputV2Mixin:
|
||||
extend_num_tokens = len(batch.seq_lens) * num_draft_tokens
|
||||
|
||||
batch.spec_info = self
|
||||
batch.input_ids = predict
|
||||
# Normalize draft token ids before ForwardBatch construction; DP
|
||||
# collectives require input_ids to have a consistent integer dtype
|
||||
# across ranks.
|
||||
batch.input_ids = predict.to(torch.int64)
|
||||
batch.extend_seq_lens = [num_draft_tokens for _ in range(len(batch.seq_lens))]
|
||||
batch.extend_prefix_lens = seq_lens_cpu_.tolist()
|
||||
batch.extend_num_tokens = extend_num_tokens
|
||||
|
||||
Reference in New Issue
Block a user