mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #3322] [CLOSED] [Engine] support the official Flash-Next DFlash2 checkpoint #4567
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#4567
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/3322
Author: @j-luwierski
Created: 10/20/2026
Status: ❌ Closed
Base:
main← Head:codex/dflash2-main📝 Commits (10+)
814d886dflash: the standalone DFlash artifact contract (GGUF metadata, geometry, CLI)155211cdflash: the target feature taps [3,15,23,35,43] (HC-contracted residuals)2b17354dflash: the standalone block forward, wired into the plain decode loop (greedy)6ae809fdflash: a numpy reference forward for the fixture-parity harness8adb9bcdflash: the forward's debug probes behind STRATA_DF_DBG, noise prints removed54e1402fix(dflash): use the drafter's full-head 256-dim NeoX RoPE47b925afix(dflash): initialize the batched attention's identity rows for every query9294eeefix(dflash): the host-only dflash_load_test needs the CUDA include path (dflash.hpp -> session.hpp)4199104fix(dflash): one definition of dflash_identity_fill (the anonymous-namespace copy made the call ambiguous)e63c241refactor(dflash): split the loader and the device runtime into separate TUs📊 Changes
953 files changed (+218800 additions, -285 deletions)
View changed files
📝
CMakeLists.txt(+63 -0)➕
bench/results/2026-10-19-dflash2-pr-performance/Q4_0-command.json(+79 -0)➕
bench/results/2026-10-19-dflash2-pr-performance/Q4_0-progress.log(+16 -0)➕
bench/results/2026-10-19-dflash2-pr-performance/Q4_0.json(+248 -0)➕
bench/results/2026-10-19-dflash2-pr-performance/Q4_0.log(+83 -0)➕
bench/results/2026-10-19-dflash2-pr-performance/Q5_0-command.json(+79 -0)➕
bench/results/2026-10-19-dflash2-pr-performance/Q5_0-progress.log(+17 -0)➕
bench/results/2026-10-19-dflash2-pr-performance/Q5_0.json(+264 -0)➕
bench/results/2026-10-19-dflash2-pr-performance/Q5_0.log(+86 -0)➕
bench/results/2026-10-19-dflash2-pr-performance/Q8_0-command.json(+79 -0)➕
bench/results/2026-10-19-dflash2-pr-performance/Q8_0-progress.log(+17 -0)➕
bench/results/2026-10-19-dflash2-pr-performance/Q8_0.json(+264 -0)➕
bench/results/2026-10-19-dflash2-pr-performance/Q8_0.log(+86 -0)➕
bench/results/2026-10-19-dflash2-pr-performance/README.md(+54 -0)➕
bench/results/2026-10-19-dflash2-pr-performance/analyze.py(+86 -0)➕
bench/results/2026-10-19-dflash2-pr-performance/ar-command.json(+75 -0)➕
bench/results/2026-10-19-dflash2-pr-performance/ar-progress.log(+8 -0)➕
bench/results/2026-10-19-dflash2-pr-performance/ar.json(+152 -0)➕
bench/results/2026-10-19-dflash2-pr-performance/ar.log(+61 -0)➕
bench/results/2026-10-19-dflash2-pr-performance/artifacts.json(+60 -0)...and 80 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. This PR resolves the Qwen3.8-Flash-Next speculative-decoding gap tracked in issue #3304 by adding opt-in DFlash2 support and setup integration. The measured results do not establish the suggested 1.5–2× gain across workloads; performance depends on target, prompts, hardware and configuration, as detailed below.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.
Current implementation and speed comparison — measured 2026-10-23
The official DFlash2 path and opt-in runtime optimizations are implemented. The suggested +32.23% long-prompt decode advantage has not been reached. The new 256K code run measures +14.84% decode speed over MTP; full request time is 0.72% slower because prompt processing dominates.
The short-context rows are the three-repeat small-page-on audit from 2026-10-22. The 256K row is a paired run from 2026-10-23. Hardware: RTX 4070 Ti SUPER 16 GiB, Ryzen 9 5900X, 125.7 GiB RAM, Linux, CUDA 13.4 / SM89. Target: local Flash-Next NVFP4, BF16 embeddings, FP8 PLE, full shared Q8_0 head and INT8 KV. Native decode tok/s excludes startup and prompt processing.
For the first three rows, ranges are observed min–max, not confidence intervals. Small-page off → on changed DFlash2 speed from 48.952 → 49.077 tok/s (+0.26%) for short code, 40.759 → 40.915 (+0.38%) for padded code and 50.622 → 51.135 (+1.01%) for cache. DFlash2 accepted/offered counts were 70/85, 58/87 and 66/78. These results are fixture-specific measurements from one machine.
256K code run: decode and full-request cost
The paired run used the same 261,747-token prompt, target model, executable, expert profile, 96-token greedy output and seed in both arms. All 96 output token IDs matched.
Each method ran once because processing the prompt took about 17 minutes per arm; the 256K tok/s values have no statistical interval. Full request time is not a prompt-only measurement. DFlash2 saved 0.356 seconds during decode, while its whole request took 7.280 seconds longer. The +32.23% target would require 46.149 tok/s at this MTP rate. Shared settings: 2,700 actual expert slots, 11 workers, verifier capacity 8, prefill 512, short-read 64 and 480 MiB reserve; prompt cache, adaptive swaps and PCIe sharing were disabled. Method settings were held fixed: DFlash2 block 7 /
spec_min_p=0.7; MTP max T=4 /spec_min_p=0.5. No launch-parameter sweep was performed.Full 256K report, exact prompt IDs and provenance, commands, raw measurements and logs · Machine-readable summary · 2026-10-22 raw commands and output controls
The short and padded-code target continuations diverge at output index 11, and the cache task uses different content. These rows do not isolate context length from continuation difficulty. The older +32.23% short-code result used a different profile and is historical; do not combine it with these measurements.
How to enable the pushed optimization options
Use a build containing this PR (implementation
dbaa12db, evidence follow-up3aef66c3) and a compatible DFlash2 artifact. These are engine environment variables, not new command-line flags. Set them before starting the engine, then restart the engine after changes; several switches are read only at startup or first use. Selecting MTP does not activate DFlash2-specific kernels.For a source CUDA build, enable the extension in the normal CUDA configuration:
Keep the existing model paths and DFlash2 launch arguments. Set the desired options in the same shell that starts the engine/server; an already-running process does not inherit later shell changes.
STRATA_DFLASH2_SMALL_PAGE_ATTENTIONSTRATA_DFLASH2_PROMPT_TAIL--prompt-cache 0; reference/parity/debug paths keep full processing. Improves prompt processing only, not token acceptance.STRATA_DFLASH2_PARALLEL_PROJECTIONSSTRATA_DFLASH2_REGISTER_TOPKSTRATA_DFLASH2_SERIAL_TOPK=1when testing it.STRATA_DFLASH2_FUSED_CONVSTRATA_DFLASH2_LATTICE_SELECTORSTRATA_DFLASH_HEAD_IL+STRATA_MMVQ_IL_Q8_HEADFor the small-page-on arm of the speed table, use the two shared-head options in both MTP and DFlash2 comparisons, and enable only the new small-page option on the DFlash2 arm:
Optional, independently testable additions for the existing DFlash2 command:
PowerShell equivalent (syntax reference; Windows execution has not been validated):
The table is not a measurement of all options enabled together. Parallel projections, prompt-tail, register top-k, fused convolution and lattice selector are separate experiments; do not infer an additive speedup. To restore these opt-in paths to their defaults, unset the corresponding variables (or set them to 0) and restart. In Bash use
unset STRATA_DFLASH2_PARALLEL_PROJECTIONS; in PowerShell useRemove-Item Env:STRATA_DFLASH2_PARALLEL_PROJECTIONS, and likewise for each enabled option.The rejected
STRATA_DFLASH2_PARALLEL_CONTEXT,STRATA_DFLASH2_WARP_ATTENTION_MAXandSTRATA_DFLASH2_BF16_STREAM_MEANprototypes are not present in production and must not be advertised as usable optimization options.Prompt-processing and acceptance findings
A separate 7227-token code fixture measures prompt-tail processing at 16897.4 → 16759.0 ms (−0.82%), with identical output IDs and 20/28 acceptance. Decode medians are 713.4 and 713.9 ms: no steady-state win. Prompt-time changes on the 2427/2425-token fixtures are negligible. This evidence is separate from the decode-speed table.
The joint diagnostic capture records native BF16 proposals and their exact target features at 95 anchor positions per task. The published BF16 PyTorch drafter, consuming those same features, chooses the same first proposal at all 285 positions: 90/95 correct for short code, 81/95 for padded code and 83/95 for cache. Later proposals can differ; this is not full bitwise PyTorch parity or validation of native target features against the upstream teacher. Reference/native correct-prefix sums are 256/258 for padded code and 348/348 for cache. Simply reproducing reference BF16 arithmetic does not recover the missing acceptance on these fixtures.
Context deduplication, two-pass self-conditioning and causal per-request selector feedback did not consistently improve acceptance. Extra context K/V parallelism and warp-maximum reduction did not establish a speed benefit and were removed. Their patches, results and limitations remain as negative evidence. No weights were fine-tuned in these experiments.
Latest validation
Passed: CUDA builds with DFlash2 enabled and disabled;
dflash_load_test,dflash_policy_test; default/enableddflash2_parity --bench; 30 before/default/enabled attention outputs bit-identical, including four-cell pages, unaligned fallback and physical rings; independent FP64 attention oracle; long NumPy stage oracle for all five layers/live KV/final normalization/selector within documented tolerances; fresh native output controls, complete joint feature/proposal capture and Python syntax compilation of the modified stage oracle.Diagnostic prototypes were removed and production rebuilt. SHA256
42a56c9a217ddb47c58fa6f42ad331c77ae2c296a532d84c53b3610fedb4a3f2matches the executable used for the latest table.Failed / rejected: the follow-up algorithm and scheduling experiments did not meet their acceptance/performance goals. Initial incomplete captures were retained and excluded from final findings. Earlier test failures remain documented below and in their original reports.
Not run on the latest head: HIP/SYCL compilation/execution (compilers unavailable), Metal, Windows, other target families, multi-GPU, vision, concurrent requests, a held-out long-prompt suite or full 128K prompt sweep. Earlier validation at another revision is not claimed as a latest-head rerun. This PR remains a draft pending scope agreement and missing backend validation.
Historical performance and validation reports
These links preserve previous tables and their original settings. They are not the current speed table:
Historical validation — original revisions
Earlier checkpoint validation used engine source 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:
c7bebe215a6feb754e08dfbc02a3ac12d38fa55f: CUDA extension ON/OFF builds; three ON and two OFF CTests; native fixed-block default/explicit-zero checks; 192/192 target-only fixture IDs match all threshold/block repeats at matching 3279 expert slots. Same-day MTP fixture IDs also match.Commands, source/executable hashes, raw IDs and logs are in validation evidence.
Failed:
One follow-up output-control startup provided 3275 rather than the requested 3279 slots; the placement assertion stopped before any request. The successful unmeasured controls use a 480 MiB reserve to retain exactly 3279 actual slots. Performance runs keep 512 MiB. The failed startup is retained in the follow-up evidence.
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. Cache equality checks cover tested arithmetic paths and matching placement, not every configuration. Disk session restoration is unsupported. The CUDA extension is restricted to one GPU and serial requests. The latest table uses equal actual expert placement; older auto-cache reports allowed different placement, so their results must not be mixed. Performance conclusions apply to the measured hardware and prompts. No universal speedup or +32% long-prompt result is claimed.
Additional setup checkpoint (2026-10-20)
Setup now offers the pinned Turbo-Brilliance DFlash2 fine-tune with
--dflash2-head turbo-brilliance; the official checkpoint remains the default. This fine-tune was trained for DavidAU's Turbo-Brilliance GSQ-RCO IQ3_S target. Setup downloads its BF16model.safetensors, converts it to GGUF and keeps it in a separate cache. The repository'st3000-q8-dv.ggufis a separate plain-DFlash artifact and is not used by this CUDA DFlash2 path.Validation: pinned revision and SHA-256 checked; config and all 81 BF16 tensor shapes matched the converter using ranged reads of the checkpoint header (the full 1.2 GB weights were not downloaded). Setup choice, cache/conversion, quantizer and calibration-key tests pass. The CUDA DFlash2 conversion of this fine-tune has not been performance-benchmarked; the upstream Apple M4 timings are for the separate plain-DFlash GGUF.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.