feat(dflash): native gpt-oss DFlash speculative decoding (engine-integrated, greedy, resident) - #135
Closed
drunkcoding wants to merge 14 commits into
Closed
feat(dflash): native gpt-oss DFlash speculative decoding (engine-integrated, greedy, resident)#135drunkcoding wants to merge 14 commits into
drunkcoding wants to merge 14 commits into
Conversation
added 14 commits
August 5, 2026 22:42
… (spec-off identical)
…pture for spec-decode
…reconstructible sliding-window KV rollback
Contributor
Author
|
Closing as superseded by #139 (already merged into #139 ( Verification that this branch is a strict subset:
The merge 'conflict' was git seeing two independent copies of the same feature line (common ancestor predates all DFlash work → add/add conflicts). Resolving it would either be a no-op or revert #139's newer work. No merge/rebase needed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Native gpt-oss DFlash speculative decoding (engine-integrated, greedy, resident)
Implements the RFC (PR #131) natively: replaces the passthrough
DFlashSpeculator.generate()with a native draft → verify → rollback loop wired intoGenerationEnginevia a flag-gated strategy seam. Builds on the existingfeat/dflash-spec-decodescaffold; drafter loaded viatrust_remote_code.What's included (13 commits)
_generate_standard+SpecDecodeStrategyprotocol inengine/generation_loop.py— spec-off path is a verbatim extraction, byte-identical._native_model_forward_rich(on-device(logits, hidden, past_kv)) +extract_context_feature(5-layer[1,9,17,25,33]) inentrypoints/big_modeling.py.build_block/acceptance_length/committed_tokensinspec_decode/_dflash_ops.py.embed_tokens/lm_headby reference.DFlashSpeculator.generate()— bonus emitted-not-cached, full-logits verify, non-causal drafter, dual-cache rollback, suffix-only hidden refresh.max_new_tokensboundary, accept 0/9, batch==1 guard.MoE.generate(..., speculative_draft=...)→ routes greedy/batch-1 through the native strategy; no drafter ⇒ standard path (byte-identical).docs/dflash.md, example.Notable deviation from the RFC (Oracle-reviewed)
The RFC assumed
DynamicCache.crop()for KV rollback. This is invalid for gpt-oss's sliding-window attention (transformers 5.12DynamicSlidingWindowLayerevicts prefix KV and refuses to crop once the window is saturated). Replaced with a snapshot-before-verify + rebuild-after-accept rollback for sliding layers (crop()retained for full-attention layers). Requiresblock_size ≤ sliding_window − 1(real gpt-oss: 10 ≤ 128 ✓); the tiny test fixture window was raised 8 → 128 accordingly.Testing
pytest tests/python/dflash -q→ 103 passed, 2 skipped.test_native_e2e.py— native DFlash == plain greedy, token-identical (engine path, ≥64 tokens, multi-prompt).test_spec_off_regression.py— spec-off byte-identical to the committed baseline.test_gpu_120b.pyskips cleanly; run withMOE_DFLASH_GPU=1+ cached checkpoints (TP=2 SM120) for agreement-rate / acceptance-length / tok-s.ruff(CI-pinned 0.6.9): clean.generation_loop.pynon-spec path only extracted, not altered.Scope (v1)
Greedy + resident + batch==1 + sync path. Deferred: sampled speculative decoding, async serving, and expert-offload/prefetch coupling (offload remains a tunable knob via
device_memory_ratio, not coupled to the spec loop in v1).🤖 Generated with opencode