feat: add DFlash2 training support - #176
Conversation
d9b7c24 to
5b543e1
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5b543e126e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if final_logit_softcapping == 0.0: | ||
| final_logit_softcapping = None |
There was a problem hiding this comment.
Remove a normalized zero softcap from the nested config
When an official-style dflash_config supplies final_logit_softcapping: 0.0, these lines disable it for training by setting the attribute to None, but the original 0.0 remains in nested. dflash2_config_for_serving() then preserves that nested value, so the exported artifact advertises a zero softcap while training used no softcap, potentially producing invalid serving logits or a training/serving mismatch. Remove the nested key or overwrite it with None when zero is normalized.
Useful? React with 👍 / 👎.
Add the grouped dynamic causal convolution and predecessor-conditioned candidate selector from the public DFlash2 architecture. Match the public serving implementations for transformed top-K unary logits, bilinear transition scores, verified-anchor alignment, and checkpoint schema. Reuse the shared DFlash training path, configuration dispatch, optimizer sharding, and strict serving export hooks. Public sources do not publish selector supervision, so define a TorchSpec-specific teacher-forced cross-entropy objective that inserts a missing gold successor into the training candidate set. Add focused configuration, loss, gradient, masking, inference-lattice parity, distributed export, and artifact tests. Signed-off-by: Aaron Batilo <AaronBatilo@gmail.com>
5b543e1 to
5c07f28
Compare
|
@yubofredwang Can you successfully reproduce the results of dflash2 using this PR? |
|
@yuyangxie96 I didn't try reproducing the exact open source models but I did try a 6 way comparison to train Qwen3-8b with a regenerated dataset based on these prompts: https://huggingface.co/datasets/lightseekorg/kimi-mtp-dataset DFlash, DFlash2, DSpark each with either the default cross entropy loss or D-PACE based loss. DFlash2 + D-PACE won 13 of the 16 categories in my eval set after 1 epoch.
|


Summary
DFlash2DraftModelconfiguration and checkpoint schema used by SGLang and vLLM.Public inference contract
TorchSpec follows the public DFlash2 architecture and serving behavior described by the Inco overview,
z-lab/dflash, SGLang PR #35371, and vLLM PR #52816:Training objective boundary
The public sources describe the selector architecture and inference computation. They do not publish selector targets, a loss, negative construction, initialization, or a training schedule.
TorchSpec therefore defines a teacher-forced cross-entropy objective. Training uses the gold predecessor and inserts the gold successor when it is outside the unary top-K candidates. This insertion is training-only. Serving retains the strict public top-K set.
This pull request does not claim parity with an unpublished upstream training recipe.
Validation
Limitations
block_size=B, configure vLLM withnum_speculative_tokens=B-1.Related work