Skip to content

Add DSpine draft model and training support - #917

Closed
maocheng23 wants to merge 3 commits into
sgl-project:mainfrom
maocheng23:codex/dspine-draft-support
Closed

maocheng23 wants to merge 3 commits into
sgl-project:mainfrom
maocheng23:codex/dspine-draft-support

Conversation

@maocheng23

@maocheng23 maocheng23 commented Oct 2, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

Add an independent implementation of DSpine to SpecForge so draft models can be built, trained, saved, and resumed through training.strategy=dspine. This draft covers model and training integration; native serving/verifier integration remains outside this PR.

Modifications

  • Add DSpineDraftModel on the shared DFlash backbone, with causal draft blocks, frozen whitened token codes, adjacent-slot injection, shallow teacher replacement, and cached last-write refinement/transition scoring.
  • Register DSpine with the existing online/offline feature providers and training lifecycle. Implement the CE/L1 backbone and refinement objectives, scheduled alignment, and checkpointed vocabulary chunks.
  • Cast predecessor features at the shared injection boundary so FP32 transfer buffers work with BF16 projections under FSDP, including anchor, teacher-replacement, and last-write refinement paths.
  • Use one detached backbone-CE coefficient across the entire optimizer window and data-parallel ranks. With gradient accumulation, a graph-free prepass collects CE statistics; the trainer then replays one microbatch at a time with the original RNG state. This makes loss, gradients, and parameter updates agree with the combined effective batch while retaining CPU inputs rather than a window of accelerator activations. The tradeoff is an extra forward pass and CPU input storage when accumulation_steps > 1; single-microbatch training and evaluation do not replay.
  • Preserve transfer buffers and DSpine settings in model checkpoints and resume contracts; add a strict converter for the independent reference checkpoint format (model weights only).
  • Add model, provider, checkpoint, accumulation, distributed, and mixed-precision regression tests, and document the trainer's optional window replay contract.

Accuracy Test

  • 265 tests passed, with 141 subtests and 4 skipped tests, across DSpine, existing DFlash variants, model loading, algorithm providers, trainer lifecycle, checkpoint/resume, configuration, and package architecture.
  • Combined-batch versus 2- and 4-microbatch comparisons pass for loss, every draft parameter gradient, and parameter updates across two optimizer windows with uneven supervision masks.
  • Two-process CPU/Gloo DDP gradients match the combined batch both with and without gradient accumulation.
  • Actual single-process CPU FSDP with per-layer wrapping passes BF16 forward/backward with FP32 buffers, window replay, and both teacher-replacement and predicted-predecessor phases. At world size one FSDP uses NO_SHARD; this does not validate multi-GPU sharding.
  • Replay preserves anchor/curriculum random draws and the caller's RNG state. Incomplete replay windows fail without an optimizer step; evaluation uses the direct path.
  • Pre-commit checks passed on all files changed by these fixes.

Validation used CPU PyTorch 2.14.0 and Transformers 5.12.1. CUDA FlexAttention execution, multi-GPU/FSDP training, and an end-to-end training run of this integrated port have not been validated.

Benchmark & Profiling

No throughput or task-accuracy claim is made in this draft. Native spec_generate is explicitly unsupported until serving/verifier integration is implemented; the PR provides model-side cached refinement and greedy transition selection. Temperature-one proposal sampling, lossless verification, fused serving kernels, and paper benchmark reproduction remain unimplemented.

Checklist

  • Format changed code with pre-commit.
  • Add model, training, checkpoint, accumulation, distributed, and FSDP buffer-dtype regression tests.
  • Document implementation contracts and the accumulation prepass cost.
  • Validate the integrated GPU/FSDP training path and provide end-to-end accuracy/performance results before promoting from draft.

jiapingW added a commit to jiapingW/SpecForge that referenced this pull request Oct 4, 2026
Integrate PR sgl-project#917 functionality while preserving DFlash and Domino optimizations. Add DSpine Liger support, flattened vocabulary projection, CE-only accumulation prepass, and balanced consumer dispatch. Include L20N training recipes and regression coverage.

Validation: 150 CPU tests and 125 subtests passed; 18 GPU-dependent tests skipped. Synced files verified against the L20N-7 training checkout.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant