feat(qwen3): add DFlash2 Phase 1 path selector - #1027
Conversation
Part of pegainfer-project#930 Signed-off-by: RicardoMin <17879681016@163.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 29ab0bef35
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Signed-off-by: RicardoMin <17879681016@163.com>
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9ce2357568
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| .expect("failed to load native DFlash2 selector checkpoint"), | ||
| ); | ||
| let speculative = generate(&engine, prompt_tokens.clone(), 0, NATIVE_GENERATED_TOKENS); | ||
| let result = check_lossless( |
There was a problem hiding this comment.
Verify selector outputs, not only final losslessness
When the selector returns any incorrect but in-vocabulary sequence—for example from broken row mapping or codebook scoring—the target verifier rejects those drafts and still produces the plain greedy continuation, so this check_lossless assertion passes while the new selector has zero useful acceptance. Fresh evidence since the earlier review is that the newly added native gate inspects only final verified tokens and never compares selected IDs with a reference implementation or checks acceptance; add such a comparison so the core feature is actually validated.
AGENTS.md reference: AGENTS.md:L121-L123
Useful? React with 👍 / 👎.
Phase1 of #930
Summary
This PR implements Phase 1 of DFlash2 for Qwen3: a proposer-side top-16 path selector layered on the existing batched DFlash backbone.
The selector keeps the existing draft/verify boundary unchanged. For each draft position, it extracts the deterministic top-16 candidates and performs a bounded greedy path walk using the selector's low-rank predecessor/successor scoring.
Changes
The target verification path, KV commit/rollback transaction, acceptance logic, and CUDA Graph shapes are unchanged.
Verification
Environment:
sm_89Qwen3-4BQwen3-4B-DFlash-b16cargo fmt --all -- --checkgit diff --checkcargo check --release -p pegainfer-qwen3 --testscargo build --release -p pegainfer-server --bin pegainfercargo test --release -p pegainfer-qwen3 --libdflash_speculative_gateThe greedy gate covers existing DFlash losslessness and regression cases including graph-shape transitions, heterogeneous batches, and insufficient draft headroom.
Supplementary shared-path checks
These checks use the existing legacy DFlash path and are included as supplementary regression evidence only:
For the sampled checks, the gate is zero Benjamini-Hochberg rejections at the configured FDR threshold. The reported maximum total-variation values are diagnostic effect sizes from sparse high-vocabulary samples, not pass/fail criteria.
Scope and Limitations
The only available native
Qwen3-4B-DFlash2checkpoint also declares Phase 2 capabilities:conv_kernel_size=2conv_group_size=16Phase 1 detects these capabilities and rejects the checkpoint before draft-weight upload with: