Skip to content

Add DSpine draft training #37

Todo

Description

@zhouaihui

Support training a DSpine Draft in ASpec, with adjacent-token injection and candidate refinement.
This adds another parallel Draft design alongside the existing DSpark and DFlash paths.

Suggested scope

Start with one supported Target, such as Qwen, and a selected public DSpine reference.
Preserve its injection, transfer-code initialization, refinement and alignment objectives.
Keep loss reductions and the predecessor-replacement schedule explicit; review upstream objective
and configuration fixes when choosing the reference revision.

Getting started

A first PR may introduce the model and injection components, the loss, or another focused
prerequisite, with checks against applicable upstream code or an independent numerical reference.
Reuse ASpec's existing Target feature and Draft training workflow where compatible.

The outcomes below can land across PRs. A proposal consumer or serving adapter can follow
separately; training support does not require building a serving engine.

Expected outcome

  • The selected model, objectives, trainable parameters and Target feature timing are documented
    and checked, including gradients and objective normalization.

  • A runnable recipe supports training and exact resume, preserving schedule and algorithm state.

  • Exported assets retain injection weights, transfer codes and Target bindings, load strictly
    and reproduce checkpoint predictions.

  • Bounded held-out observations and supported scope are recorded; pending proposal or acceptance
    validation is tracked before related quality or serving claims.

  • Run a small training comparison with the chosen reference implementation, using the same
    starting weights, data, training budget and settings. Compare loss curves and acceptance lengths
    with the same evaluation setup, and explain any noticeable differences.

This comparison can come in a follow-up once training and evaluation are ready; it does not need
to be part of the first model/loss PR.

References

Activity

  1. hereisaway commented on Nov 25, 2026

    @hereisaway
    Contributor

    @zhouaihui I'd like to work on this issue. Below is my preliminary design; I'd appreciate a scope/config sanity check before I start the first PR.

    Reference revisions

    • Tencent/DSpine @ 75cade7ab0307fc2daac8eda95337705226b217e
    • SpecForge DSpine training: #965 (merge eaa6b03f6b4a65f38954fa0ebc13e59a8f295d02) plus the objective corrections in #1038 (merge 1b5c0dde137a28447606ffb6078e01eddfa77980)
    • I will also account for SpecForge #1170 (stale OnlineDSpineModel config) by reading the draft config at use time / rejecting config replacement after construction.

    Selected scope for the first PR

    Qwen3-8B Target, the published DSpine-b16 layout, dense full attention, padded inputs, CP1, no packing. I would start with the model/injection/loss prerequisite and leave trainer, recipe, exact resume, export and consumer to follow-ups (same split as our Domino #45 → #48 → #52 → #55 series).

    Proposed implementation

    • DSpineConfig(DFlashConfig) for the published dflash_config fields: selected_prefix_code_bridge (code_size, rank, eps), selected_prefix_feature_layers, selected_prefix_feature_write_mode="independent", selected_prefix_feature_writes=true, terminal disabled, draft_block_causal=true, selected_prefix_last_write_refine / code_bridge_second_pass, selected_prefix_terminal_residual_rank, replacement_probability, and alignment-warmup state. Fail closed on terminal-corrected bridges, reliability probes, next-token rows, MoE/sparse attention, and non-causal draft attention.
    • Reuse the DFlash block backbone. Add a selected_prefix_code_bridge with the published names:
      • persistent codebook + per-layer read_weight / early_read_weights for transfer-code initialization;
      • prev + gate + predecessor_gate + out + per-layer feature_write_weights for adjacent-token causal injection;
      • exact last-write serial refinement and head_topk K (power of two in [2, 64]).
    • Implement the predecessor-replacement schedule and the refinement/alignment objective explicitly, not as an implicit trainer default. Follow #1038 normalization: average code loss over draft layers, normalize the total objective by sequence count, normalize refinement CE/L1 separately and scale by supervised-row count per microbatch; default alignment warmup to the LR warmup unless explicitly overridden.
    • Initial numerical contracts: tiny-model forward/gradient parity against an independent dense reference, zero-L1/zero-subgradient for equal draft/teacher distributions, causal isolation (future tokens cannot change earlier refined logits), transfer-code loading from the published checkpoint, top-k refinement coverage, and config fail-closed cases.

    Questions

    1. Is the model/injection/loss-only first PR acceptable, with trainer/recipe/resume/export split into later PRs?
    2. Do you prefer the Tencent reference at 75cade7 or the corrected SpecForge objective as the primary parity target? I plan to use the corrected #1038 normalization.
    3. Any preference on Qwen3-8B vs another Target for the first numerical contract? I have Qwen3-8B working locally.

    Could you assign this issue to me if the direction looks right?

  2. hereisaway commented on Nov 25, 2026

    @hereisaway
    Contributor

    First model/injection/loss increment is up for review: #66

    Scope is intentionally limited to the DSpine model/loss prerequisite (dense full attention, padded, CP1, non-packing). Trainer, recipe, exact resume, export and consumer/acceptance are follow-ups. CPU tests: 1423 passed; DSpine-targeted 5 passed; ruff/check_docs/diff-check pass.

    I kept the scope explicit and left the primary-reference question in the PR: Tencent/DSpine for architecture/weight layout, SpecForge #1038 for objective normalization. Happy to adjust the split or pin a different reference.

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

Metadata

Metadata

Assignees

Labels

good first issue

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions