Skip to content

[Feat] dflash: Run DFLASH on a pipelined PD prefill - #49648

Draft
yhyang201 wants to merge 9 commits into
sgl-project:mainfrom
yhyang201:port/dflash-pp-prefill
Draft

yhyang201 wants to merge 9 commits into
sgl-project:mainfrom
yhyang201:port/dflash-pp-prefill

Conversation

@yhyang201

@yhyang201 yhyang201 commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

Original authors: @yhyang201 @Fridge003

Port of #48414

Main rejects DFLASH whenever pp_size != 1. #48414 runs it on a pipelined PD prefill: only the last stage builds the draft, the aux hidden states reach it on the PP proxy (the dspark_hidden_states path DSPARK already uses), and it sends the prompt's draft KV with its own layers. Earlier stages run the target only and budget no draft KV. Decode and non-disaggregated serving still require pp_size == 1.

Changes against the raw port (first commit):

  • Dropped the draft KV ring references (draft_kv_ring_enabled() in _has_dflash_draft_kv, the ring wording in the Mooncake check). The ring is a later port.
  • The ported test keeps only the pipeline-stage cases, and now builds the worker through __init__ under a PP topology override (earlier stage: no draft build; last stage: draft built in a single-member pp scope with the target's seed and the stage-local load group).
  • Added a pool-configurator test.
  • test_mooncake_dflash_tp_mismatch_allows_dcp_collapsed_mla_draft used num_draft_entries=0 for its MHA-like draft, which the new guard skips. It now registers K and V entries of one draft layer, and a new case covers a manager with no draft entries.
  • Earlier stages follow DSparkWorkerV2 (same _hosts_draft gate, spec_v2_attn_backends from the base class). The class-level _hosts_draft = True stays because stub-built tests (object.__new__) reach gated methods without setting it.
  • One is_dflash_family() branch builds the PP draft input for DFLASH and DSPARK. DSPARK's make_next_draft_input only forwards to make_draft_input_v2.

Behavior changes:

  • DSPARK: earlier PP stages of a PD prefill no longer budget draft KV. They hold no draft, so they now get that memory as target KV. The last stage and pp_size == 1 are unchanged.
  • Mooncake: the DFLASH TP-mismatch check is skipped for any manager with no draft entries (an earlier PP stage, or any setup that sends no separate draft KV), not only earlier stages. Before, kv_layer_ids[-0:] took the whole target list and the check rejected the peer.
  • The DFLASH draft now takes random_seed=target_worker.random_seed on every launch, pp_size == 1 included. The value does not change (the target's seed comes from the same world broadcast); the draft's own broadcast is skipped. The load group is stage-local only when pp_size > 1.

Left for the draft KV ring port: the empty DRAFT_RING / REQUEST_ROW slots on earlier stages.

Modifications

  • arg_groups/speculative_hook.py, validation_hook.py: allow DFLASH with PP on a PD prefill only.
  • speculative/dflash_worker_v2.py: _hosts_draft (last PP stage). Earlier stages skip the draft build, pools, backends, graphs and sampling prewarm, and forward the target with aux capture.
  • managers/scheduler_pp_mixin.py: no topk_p relay for the DFLASH family. Every stage builds the same DFlashDraftInputV2 from the bonus token.
  • model_executor/pool_configurator.py: only the last stage budgets the draft KV (DFLASH and DSPARK).
  • disaggregation/mooncake/conn.py: skip the draft reslice check when no draft entries are registered.

Results

Unit tests (CPU, rebased on 6d12127cbb): test_dflash_pp_prefill 4 passed; test_pool_configurator 73 passed (+43 subtests); test_server_args 360 passed (+244 subtests); test_disaggregation_wire 79 passed (+110 subtests); test_disagg_idle_step_counters 22 passed (+51 subtests); test_pp_cp_rank_offsets 5 passed; test_weight_update_runners and test_dflash_draft_graph_eligibility pass.

PD end to end with a pipelined prefill has not been run yet. It needs two 8-GPU nodes. Like DSPARK, it needs a target that relays aux hidden states across stages (kimi_k3, kimi_linear).


CI States

Latest PR Test (Base): ❌ Run #42912825724
Latest PR Test (Extra): ❌ Run #42912824991
Latest PR Test (AMD ROCm 10): ❌ Run #42912825011

Tip

Base CI only covers the core cases, and its workload may not exercise your change. Use /rerun-test to run the tests your change touches, or copy this prompt for an agent:

Find the registered tests this PR affects and run them with /rerun-test, following https://github.com/sgl-project/sglang/blob/main/.agents/skills/rerun-test/SKILL.md

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mooncake run-ci CI: run the baseline test suite on this PR speculative-decoding

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant