mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #1961] [CLOSED] [Engine] support the official Flash-Next DFlash2 checkpoint #3777
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#3777
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/1961
Author: @j-luwierski
Created: 10/11/2026
Status: ❌ Closed
Base:
main← Head:codex/dflash2-main📝 Commits (10+)
d6760a1dflash: the standalone DFlash artifact contract (GGUF metadata, geometry, CLI)f1bb646dflash: the target feature taps [3,15,23,35,43] (HC-contracted residuals)a5f3800dflash: the standalone block forward, wired into the plain decode loop (greedy)dde0544dflash: a numpy reference forward for the fixture-parity harnesscb6a830dflash: the forward's debug probes behind STRATA_DF_DBG, noise prints removeda989b5bfix(dflash): use the drafter's full-head 256-dim NeoX RoPE9f86b99fix(dflash): initialize the batched attention's identity rows for every query23f0e8ffix(dflash): the host-only dflash_load_test needs the CUDA include path (dflash.hpp -> session.hpp)d5ba449fix(dflash): one definition of dflash_identity_fill (the anonymous-namespace copy made the call ambiguous)9899c66refactor(dflash): split the loader and the device runtime into separate TUs📊 Changes
66 files changed (+7712 additions, -162 deletions)
View changed files
📝
CMakeLists.txt(+53 -0)📝
docs/AI_SETUP.md(+20 -0)📝
docs/DETAILS.md(+5 -0)➕
docs/DFLASH.md(+365 -0)➕
docs/DFLASH2.md(+170 -0)➕
include/strata/core/dflash.hpp(+261 -0)📝
include/strata/core/layer.hpp(+20 -0)📝
include/strata/core/native_head.hpp(+2 -1)📝
include/strata/core/verify.hpp(+19 -0)📝
include/strata/kernels/bf16_gemv.hpp(+8 -0)➕
include/strata/kernels/dflash2.hpp(+18 -0)📝
include/strata/kernels/elementwise.hpp(+20 -0)📝
include/strata/kernels/native_mmvq.hpp(+6 -0)📝
include/strata/kernels/native_rope.hpp(+18 -0)📝
include/strata/kernels/qsa.hpp(+7 -0)📝
include/strata/kernels/qsa_decode_attn.hpp(+8 -0)📝
include/strata/prefill/prefill.hpp(+9 -0)➕
include/strata/spec/dflash_policy.hpp(+63 -0)📝
serve/server.py(+4 -0)📝
serve/test_server.py(+5 -0)...and 46 more files
📄 Description
Problem and result
The official
incoai/Qwen3.8-Flash-Next-DFlash2checkpoint requires five attention layers with 128-wide heads, raw HC-mean target features, dynamic convolution and a predecessor-conditioned selector. This change implements that checkpoint contract and supports original BF16 weights plus Q8_0, Q5_0 and Q4_0 backbone quantizations, using the full shared target output head.Setup offers MTP (default), experimental DFlash2, or no model drafter. DFlash2 selection enables the local CUDA build, pinned download/conversion and artifact-specific calibration. Weights, private KV pools and attention scratch are accounted for before auto-sizing the expert cache, including the configured context length and elastic growth. MTP and DFlash2 cannot be selected together.
Related discussion
Explicit maintainer confirmation of the expanded official-checkpoint/setup scope remains pending. This remains a draft while that scope and missing backend validation are resolved.
Approach
DFlash2 is opt-in behind
STRATA_ENABLE_DFLASH2=ON. The converter validates the checkpoint geometry and preserves all 45 norm, convolution and selector tensors in BF16; the 36 backbone matrices can be quantized. Setup offers BF16, Q8_0 and Q4_0; Q5_0 is also supported by the converter/runtime and included in the measurements below.Prompt and conversation snapshots retain the draft context. Cache controls enforce matching actual expert placement before checking output. The shared runtime includes the infrastructure required for proposal verification, a fix for state publication on the opt-in QFUSE path and a fix for the CPU-only loader-test build dependency. The existing default drafter stays MTP.
Performance: MTP versus DFlash2
Fresh same-source runs on RTX 4070 Ti SUPER 16 GiB, Ryzen 9 5900X, 125.7 GiB RAM, Linux, CUDA 13.4 / SM89. Target: local Qwen3.8-Flash-Next NVFP4 pack, BF16 embeddings, FP8 PLE, shared Q5_K output head, INT8 KV. Context 8192, prefill 256, auto expert cache, allocation reserve 512 MiB. All arms fill available VRAM; smaller draft allocations permit more target experts.
Greedy seed 1234, 96 new tokens, four fixed prompts (27/54/33/2425 input tokens), one warmup per prompt and three measured repeats per speculative arm. MTP at floor 0 is run before and after all four DFlash2 variants. An additional MTP run at setup's floor 0.5 follows those series and is the table reference; this sensitivity check was added after the initial series to avoid comparing only against an untuned zero-floor baseline. Both MTP settings remain in the raw evidence.
DFlash2 uses three proposals (verifier capacity 8, fixed block 3); MTP uses up to three proposals (verifier capacity 4), probability floor 0 in the fixed-budget series, plus the separate MTP setup-floor 0.5 control. The DFlash2 block length is fixed; the study does not independently tune each drafter.
CPU prompt sharing, PCIe sharing, adaptive swaps, suffix/lookup drafting and prompt/conversation snapshots are off. Engines run sequentially, with no build or other benchmark during measurements. Values are medians of native decode throughput; prefill/startup are excluded. Geomean weights all four task medians equally.
Q4_0 has the best observed DFlash2 aggregate, 44.10 versus MTP's 44.04 tok/s (+0.1%). Their per-repeat geometric-mean ranges overlap: treat this as an overall tie. Its clear code advantage is +23.8%; math/prose improve by 1.2%/1.8% in this sample, while the long prompt regresses by 21.1%. Q8_0, Q5_0 and BF16 are slower in aggregate.
Per-repeat geometric means span 43.00–44.10 tok/s for MTP floor 0.5 and 44.07–44.20 tok/s for DFlash2 Q4_0. Bold task cells mean every measured DFlash2 sample exceeded every MTP floor-0.5 sample for that task; percentages are relative to MTP for that column. The bracketing zero-floor MTP's end/start geomean changed by -0.49%. Three samples per DFlash2/default-floor MTP task and six pooled zero-floor MTP samples are too few to establish a general speedup. Non-overlapping observed throughput ranges: bf16/code, Q8_0/code, Q5_0/code, Q4_0/code, Q4_0/math, Q4_0/prose. These are descriptive ranges, not confidence intervals.
The initial runtime column is the engine's load counter, not total process VRAM. MTP subsequently allocates another 275.7 MiB of selected output-head rows, plus index/sampling buffers. DFlash2's counter includes its weights, private KV pools and scratch, and it shares the full target output head without another head-weight copy. Expert slots and GPU-free snapshots show the practical final placement.
Raw runs, ranges, memory and output controls.
Validation
Engine source tested at
af85f5ce3b4411833b5529361ae18ffdadbdce3f, based on maine88ee39d1d6be6e3364183af3b39b62a7ed6f211. Performance evidence commit:86af7286254d1efb148cf0aa8c9a96868d4e9f09; it adds scripts/results without changing engine code. Linux, RTX 4070 Ti SUPER 16 GiB, Ryzen 9 5900X, 125.7 GiB RAM, CUDA 13.4, GCC 14.2, SM89.Passed:
Commands, source/executable hashes, raw IDs and logs are in validation evidence.
Failed:
Four CPU CTests fail with the available dependency/tooling: three require missing Trellis types and one reports an AVX512 allowlist violation. All four reproduce on unmodified main. The full candidate CPU run has 44 passed, one skipped and four failed tests.
Initial CPU-only build and setup golden-fixture failures were corrected and rerun successfully; original failures are retained.
The initial default-path harness rejected a valid early EOS from a truncated prompt. The corrected harness uses the full prompt and compares actual IDs; its failed attempt is retained.
An earlier 256 MiB VRAM-reserve startup failed to fit verifier allocations. That failed attempt and an interrupted fixed-cache experiment are retained in the earlier quantization evidence and excluded from measured medians.
A preliminary performance restart overlapped teardown of the preceding engine and failed the host memory guard. The previous process tree was fully stopped before the final complete series. That failure and the interrupted prefill-512 attempt are retained and excluded from medians.
Not run:
HIP/SYCL compilation and execution (ROCm/
icpxunavailable), Metal, Windows, multi-GPU, concurrent requests and a full 128K-token prompt. The CUDA extension is explicitly restricted to one GPU and serial requests. Shared backend changes still require the missing builds; keep this draft pending targeted validation.Limits
Sampled DFlash2 requests use target-only fallback. Exact cache output checks cover one-proposal split windows and fixed placement; they do not prove byte equality for every arithmetic path. Disk session restoration is unsupported.
Maximum VRAM residency means each drafter can fit a different number of target experts. This measures the practical combined effect of smaller draft weights and a larger expert cache, rather than isolated kernels. Different placements can also change target rounding; matching-placement output controls and raw results are retained. Performance conclusions apply to this hardware and these prompts only.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.