mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #3869] [Engine] --draft dflash2 when serving, on one card and on a layer split (opt-in) #4808
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#4808
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/3869
Author: @stuchapin909
Created: 10/23/2026
Status: 🔄 Open
Base:
main← Head:pr/dflash2-serve-split📝 Commits (1)
5f436deengine: --draft dflash2 when serving, on one card and on a layer split (opt-in)📊 Changes
8 files changed (+425 additions, -115 deletions)
View changed files
📝
docs/MULTI_GPU.md(+35 -0)📝
include/strata/core/verify.hpp(+10 -3)📝
include/strata/prefill/prefill.hpp(+6 -1)📝
src/core/verify.cpp(+16 -5)📝
src/prefill/prefill.cpp(+49 -11)📝
src/program/generate.cpp(+306 -94)📝
strata_control/drafting.py(+1 -1)📝
tests/terminal/test_drafting.py(+2 -0)📄 Description
Problem and result
--draft dflash2(merged in f-023-df2) runs only in the CLI on one card: with--serveor a layer split the engine prints "it is for one card and the CLI run" and drafts with the MTP. The 0.2.3 notes say the app will offer DFlash2 "once the engine serves it". This adds that, opt-in:--serve --draft dflash2 --draft-model PACKnow drafts with DFlash2 on one card and on a layer split of two or more cards, with or without--pipeline-windows 2. Without--draft dflash2nothing changes.Result on 2x RTX 3090 (the hardware the maintainers do not have): it works, the text is the target model's, and it is not faster here. DFlash2 decodes 1.8% slower than the MTP on a two-card split, mean of 5 prompt types x 6 runs; on one card 4% slower (one round). So the MTP stays the default and this PR changes no default. Measurements below.
Related discussion
Approach
Verifier::set_taps(layers, shared_map, ext_dev)); the last stage'srecord_windowcopies those rows into its owntap_devat the start of its part of the window. The odd (pipelined) verifiers get their own mapped buffer. Prompt reading does the same per chunk: a frontPrefillwrites its taps into pinned host hand-off buffers (double-buffered with the existinghand_buf_) and the next stage uploads them before its layers run.df2.load(..., last_st->dev)), sodf2.draft(ver.tap_dev(), ...)reads device memory on its own card.--serveloops. The serial decode loop drafts withdf2.draftin place ofmtp.draft(with the PLE row prefetch the MTP path does). In the pipelined loop, when a window is accepted whole, the drafter drafts from the verified window's taps and the next guessed window is built from that block (make_b); after a partial accept it drafts from the accepted rows. Prompt windows and merged first windows feeddf2.context.--draft dflash2: <reason> (start without --draft dflash2 for the MTP)instead of claiming a fallback. The CLI run is unchanged: it still loads the MTP beside DFlash2 and falls back to it, as in main.use_df2(false unless--draft dflash2loaded).use_df2is now declared outside#if defined(STRATA_HAVE_DFLASH2)so the Metal / SYCL builds, which compile without the drafter, still seefalse. The MTP pipelined chain launch keeps its order (before the front-stage commits).strata_control/drafting.fallback_notereads it asNOT_HERE, with a test.ENGINE_SERVES_DFLASH2staysFalse: Control and engine ship separately, so flipping it belongs with the release whose engine has this.docs/MULTI_GPU.mdsection "DFlash2 drafting when serving",--helpline for--draft.Validation
All on: 2x RTX 3090 24 GB (driver 617.42, CUDA 13.0.88, sm_86 local build), i9-9920X, 96 GB RAM, Windows 11 Pro 26300. Model Qwen3.8-Flash-Next GSQ-RCO IQ3_S, native pack,
--layer-split 25, GPU order [1,0],--spec 4 --spec-min-p 0.5 --max-context 131072 --kv k8v4 --kv-resident 32768 --vram-reserve-mib 700 --remote-expert-opt --adapt-async 1 --pipeline-windows 2 --trim-stage-weights --host-core last --conversation-cache-mib 8192 --conversation-cache-slots 4, envSTRATA_SIDE_MIXER=2 STRATA_ADAPT_LAG=2 STRATA_ATTN_DAILY=1 STRATA_QSA_ROWS=1 STRATA_B6_MMVQ_ROWS=1. Drafter:incoai/Qwen3.8-Flash-Next-DFlash2packed Q8 withtools/dflash2_pack.py(760 MB). Revision: this branch on7ddc17a3. Baseline: the released 0.1.48 engine component (0.1.48-windows-x86_64-cuda-cuda13; no engine source changed between v0.2.3.1 and7ddc17a3).Passed:
cmake --build build --target strata(CUDA 13.0, Ninja, MSVC 2022 BuildTools, sm_86): builds and links.python -m unittest tests.terminal.test_drafting: 39 of 40 pass, including the newfallback_notecase. The one error (TheDownloadPlanListsIt.test_the_plan_line_and_the_part,KeyError: 'dflash2') fails the same way on a clean7ddc17a3checkout on this PC (the DFlash2 pack is already downloaded here).Speed, interleaved A/B, 3 rounds x (0.1.48 release with MTP, this build with MTP, this build with DFlash2); each a fresh server start, one warm-up request, then 5 prompts twice, greedy except one sampled at 0.7, thinking off. Decode tok/s from the engine log ("N generated in X ms"), mean (min-max) of 6 runs:
Acceptance (accepted / drafted, all runs): MTP 64 / 83 / 64 / 83 / 61%, DFlash2 65 / 84 / 65 / 83 / 59%. With the MTP, this build is within noise of the release.
One card,
--serve(GPU 1 only, same args without the split), 1 round x 2 passes: DFlash2 76.0 tok/s mean vs MTP 79.5 (this build). Starts, serves 10 requests, no errors.Start-up line on the split:
strata serve: DFlash2 drafter on CUDA1 (...q8.pack, graphs captured in 5 ms; the MTP layer is not loaded).Greedy text (
docs/MULTI_GPU.md"Same text" settings:STRATA_IQ_MT_MIN=1 --pcie-frac 0 --adapt-every 0, otherwise the config above), 2 rounds x 3 arms x 4 greedy prompts x cold/warm. With this config the release engine does not reproduce its own greedy text across restarts: 0.1.48 vs 0.1.48 matched in 4 of 16 answers (the JSON prompt every time; chat, code and reasoning split at a near-tie, e.g. code at character 1106 in both arms). This build with MTP matched a 0.1.48 answer in 7 of 16, with DFlash2 in 7 of 16. So no sign of a text change, but this is not a bit-for-bit proof: that needs a config where the release repeats itself, which I did not find in the time I had.CLI run, one card, final binary (
--tokens-file bench/results/2026-10-07-community-arc-b65-v01402/benchy-short.ids --max-new 300, same pack and drafter,--max-context 8192):--draft dflash2prints "DFlash2 drafter on (...), the MTP layer stays as the fallback", 56.6 tok/s, 76% of drafts accepted; MTP 60.3 tok/s, 73%. Both exit 0.Two-card
--serve, final binary, 1 round: starts with the DFlash2 line above and serves all 10 requests (the A/B table was measured on the build before the last commit, whose serve path is the same; the last change only restored the CLI's MTP fallback and the--helptext).Metal build: this branch plus the one-line runner bump from #3870,
metal-build.ymlonmacos-26in my fork; "Build and link the engine" passed (build and link only, not run on a Mac): https://github.com/stuchapin909/Strata/actions/runs/39993333283. Themetal-linkfailure shown on this PR is the repo-widemacos-14SDK issue (MTLGPUFamilyMetal4/mathModeinmetal/src/mtl_rt.mm) that #3870 fixes.Failed:
Not run:
generate.cpp,verify.cpp,prefill.cppand both headers are compiled by those backends. I checked by script that every DFlash2 symbol outside the class members is inside#if defined(STRATA_HAVE_DFLASH2), but that is not a build.--serveor the CLI, to see the error exit and the fallback line.--batch, three or more stages, AMD gfx12 (where--pipeline-windows 2is the default), long prompts (all prompts here are under 150 tokens), tool-call prompts, conversation-cache restores with DFlash2 (see Limits).verify_parity,spec_verify_parity,verify_batch_parityare not built in this tree).Limits
--draft-cap/--draft-conffor the split.ENGINE_SERVES_DFLASH2is leftFalse, so the app andstrata launch --drafting dflash2still pick the MTP; the engine flag works when passed directly in a config'sargs.AI-assisted: a Gemini agent wrote the first version; I (with Claude Code) reviewed it, fixed three issues (a Metal/SYCL build break from
use_df2scoped inside the DFlash2#if, a reordered MTP chain launch on the default pipelined path, and a broken MTP fallback in both serve and CLI), and produced every measurement above on my machine.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.