feat(speculative): context parallelism for draft-model training#2918
Conversation
Signed-off-by: Kashif Rasul <kashif.rasul@gmail.com>
Signed-off-by: Kashif Rasul <kashif.rasul@gmail.com>
Signed-off-by: Kashif Rasul <kashif.rasul@gmail.com>
…n sync Signed-off-by: Kashif Rasul <kashif.rasul@gmail.com>
…ence Signed-off-by: Kashif Rasul <kashif.rasul@gmail.com>
Signed-off-by: Kashif Rasul <kashif.rasul@gmail.com>
|
One design question for reviewers on the Right now the CP hook intercepts attention by swapping A more robust alternative: register a dedicated Worth doing in this PR, or fine as a follow-up? Leaning follow-up since the current gated version is correct where it's enabled, but happy to fold it in if preferred. |
…arallelism Signed-off-by: Kashif Rasul <kashif.rasul@gmail.com>
Signed-off-by: Kashif Rasul <kashif.rasul@gmail.com>
Signed-off-by: Kashif Rasul <kashif.rasul@gmail.com>
…thout one Signed-off-by: Kashif Rasul <kashif.rasul@gmail.com>
Signed-off-by: Kashif Rasul <kashif.rasul@gmail.com>
…fp32) Signed-off-by: Kashif Rasul <kashif.rasul@gmail.com>
Signed-off-by: Kashif Rasul <kashif.rasul@gmail.com>
|
Taking a look at this now, will review shortly. |
|
One PR-level item: none of the 13 commits carries a Signed-off-by trailer, and CONTRIBUTING requires DCO sign-off on every commit. A rebase with |
Signed-off-by: Kashif Rasul <kashif.rasul@gmail.com>
…rgets don't crash Signed-off-by: Kashif Rasul <kashif.rasul@gmail.com>
Signed-off-by: Kashif Rasul <kashif.rasul@gmail.com>
…ngth breaks the cp preconditions Signed-off-by: Kashif Rasul <kashif.rasul@gmail.com>
Signed-off-by: Kashif Rasul <kashif.rasul@gmail.com>
Signed-off-by: Kashif Rasul <kashif.rasul@gmail.com>
…raft trainers Signed-off-by: Kashif Rasul <kashif.rasul@gmail.com>
|
There are a few more issues that I am still reviewing in depth. |
Signed-off-by: Kashif Rasul <kashif.rasul@gmail.com>
Adds context parallelism (
cp_size>1) to the DFlash/Domino/JetSpec and DSpark draft trainers for long-context training, and fixes the same path in EAGLE-3.The approach follows EAGLE-3's existing seam: only the frozen target's forward is sharded across the
cpmesh, and its captured hidden states are gathered back to the full sequence before the draft runs — so the draft's block/anchor masks are never sequence-split. The draft shards over thedpsubmesh; cp ranks in a dp group share data and draft weights.Two things that bit me and are worth a careful look in review:
context_parallelring doesn't actually fire for a plain HF target — q/k/v reach SDPA as local tensors, so each rank silently attended only to its own sequence shard. Since the target is frozen (forward-only), I all-gather K/V and attend the local Q against the full sequence with a global causal mask (newattach_cp_kv_gather_hooks). This needs the HF torch-SDPA path, socp_size>1requirestarget_force_hf=true.Validated on 2 GPUs (Qwen3-0.6B): with the fix, per-step draft loss matches the 1-GPU baseline within bf16 noise (mean signed +0.18%, symmetric above/below), versus a systematic +2–7% before. Unit tests pass.
Defaults (
cp_size=1) are unchanged, and DSpark CP is gated to the dense Qwen3 target (the MoE targets already run under their own EP/FSDP mesh).