Repository navigation
ricursive: the publisher's DFlash2 drafter for Ripple-65B (stacked on #2231) - #2260
Conversation
|
Thanks @BobClawblaw. Drafted equal to plain, the plain path's 53 hashes unchanged and ten planted controls red is a careful first drafter PR. Two things. The family itself still needs a decision on #2171, so this waits on that. And the drafter follows "SGLang's |
|
Thanks, and a fair catch: it's SGLang's own code. ricursiveAI's drafter release holds only
I'll redo the drafter and its float64 references from those, rerun drafted == plain, the kernel contract and the plain-path A/B, add z-lab to the notices for |
45685de to
904eb81
Compare
|
The rebuild is in ( On the full model: drafted == plain 12/12 and 12/12 under structured output, seeded sampling 9/9, soak 60/60, concurrent 12/12; speed and acceptance unchanged (48% of drafted tokens kept with one stream, 56% with two). Contract 75/75 with 25 controls red; the body has the details. Still a draft until #2171 is decided. |
|
Thanks @BobClawblaw for saying plainly where the first version came from, and for rebuilding it. The drafter now names only z-lab's A few things before it leaves draft. The family itself still waits on #2171.
With the stack on today's main, |
904eb81 to
df17d13
Compare
|
Thanks @ashhart. All six are answered on the new head,
Checks on this head (each exit 0): The suite ran on the same tree before its rebase over main's last two commits, a changelog line and |
|
/atc exchange 46d290cb7bf5b9c4f378215ac437fba71d39758355c048d08965f3db29e98aa2 |
|
/atc exchange a6621e0cf0281aea16665a2b398086be7563bcfde69edf6552af92206879e1c3 |
df17d13 to
938b8ae
Compare
|
Thanks @BobClawblaw for the restack and the new rows. The drafter now takes its NoPE layer from its
|
938b8ae to
37c31c2
Compare
|
Thanks @ashhart. The first question turned up a mistake in the bf16 numbers, now corrected.
Head: |
37c31c2 to
8843987
Compare
|
Hi @BobClawblaw, a heads-up from the CUDA side, since #2475 is stacked on this PR. So the CUDA drafter can read the drafter's config without Metal, #2475 moves the backend-independent part of If you change the parse here before the stack lands, I'll carry the change into |
…er's packed weights and the selector walk The drafter's config parse moves from dflash2_config.zig to dflash2_spec.zig, which needs no Metal, so the CUDA build shares it; dflash2_config.zig re-exports it. ashhart#2260's refusal of a clamped MLP (ffn_clamp_threshold) moves with it, and max_streams stays in dflash2_config.zig. cuda_dflash2_weights.zig reads the release through that parse and packs its projections for the lane matmul; cuda_dflash2_select.zig is the host walk over each row's top-32 candidates, as rc_df_walk.
…rafted replies equal plain ones The drafter runs dflash2.zig's op order over the target's taps, streams batched in 16-row blocks, and serves through the lane core's Drafted wrapper. --drafter's config.json goes through ashhart#2260's qualified parse and the CUDA kernels' gate before any stream, so its bytes are admitted with the streams'; a drafter that leaves no room for one stream is refused by name. ripple-drafted checks drafted == plain at 1, 2 and 8 streams. The config read and the gate move to cuda_dflash2_config.zig, unchanged, with a test that a clamped MLP (ffn_clamp_threshold) is refused as ashhart#2260 refuses it. THIRD_PARTY_NOTICES lists the CUDA drafter files beside dflash2.zig and dflash2.metal.
…, as ashhart#2260 does The drafter refusal from the embedded ashhart#2260 copy refused o.lanes > max_streams, so a server whose --parallel was left at its default of eight refused --drafter. As ashhart#2260 now does, the count comes from streams(o.lanes, o.lanes_fixed): a named count past max_streams is refused, and an unnamed one takes max_streams. lanes_n then sizes the Metal streams and the lane host; without --drafter it is o.lanes, as before. max_streams and streams() live in dflash2_spec.zig, shared with CUDA, so the rule is checked on the host; the CUDA module's test block now reaches that file. test-ricursive-cuda-host: streams(8, false) is max_streams, a named 1 or 2 is kept, and a named 3 or 8 is refused.
…art#2260 does loadDrafter's error branch called model.deinit() and returned the error, while the errdefer one line above frees the model again on that same error: a double free whenever the drafter's files fail to read or load past the config. As ashhart#2260 does, the call is now a plain try: an error leaves the model to the errdefer alone, and only the refusal path (null with a problem), which errdefer does not see, frees it itself. This is Metal's native entry point (native/ricursive.zig), which compiles only on macOS: no host test here; it needs the lead's M5 compile.
|
Thanks. Both are fixed in two commits on top of your restack (63b0305), so your rebase is kept. Logprobs with On the M5 Ultra, the NVFP4 release served with the drafter from this build answered every request with HTTP 200:
With drafting on and off, the tokens, logprobs and top-3 lists are identical, greedy and sampled. The greedy replies ended at their stop token, which The recipe (da98c95). The same doc's "Not done" paragraph said logprobs were refused by name. That was no longer true (the host has advertised them since the family landed), so it now states the check above. Other checks on this head: On the 21 Nov question about the order of #4296 and this PR: #2231 has landed and your restack put this PR straight on main, so it no longer waits on #2231. The order is yours to set. |
|
Thanks @BobClawblaw. The
|
…er's packed weights and the selector walk The drafter's config parse moves from dflash2_config.zig to dflash2_spec.zig, which needs no Metal, so the CUDA build shares it; dflash2_config.zig re-exports it. ashhart#2260's refusal of a clamped MLP (ffn_clamp_threshold) moves with it, and max_streams stays in dflash2_config.zig. cuda_dflash2_weights.zig reads the release through that parse and packs its projections for the lane matmul; cuda_dflash2_select.zig is the host walk over each row's top-32 candidates, as rc_df_walk.
…rafted replies equal plain ones The drafter runs dflash2.zig's op order over the target's taps, streams batched in 16-row blocks, and serves through the lane core's Drafted wrapper. --drafter's config.json goes through ashhart#2260's qualified parse and the CUDA kernels' gate before any stream, so its bytes are admitted with the streams'; a drafter that leaves no room for one stream is refused by name. ripple-drafted checks drafted == plain at 1, 2 and 8 streams. The config read and the gate move to cuda_dflash2_config.zig, unchanged, with a test that a clamped MLP (ffn_clamp_threshold) is refused as ashhart#2260 refuses it. THIRD_PARTY_NOTICES lists the CUDA drafter files beside dflash2.zig and dflash2.metal.
|
Thanks. Both are fixed in one commit on top of the logprobs fix (2b182da). Everything is inside the family's folder and 1. One charge a stream, held from admission to release. On the streamed prompt pass, the wrapper still opens the drafter before the target's pass. Ripple's drafter no longer allocates the ring at open: New tests (
With 2. The context bound includes the first ring. On the M5 Ultra, the NVFP4 release served with the drafter from this build (
Checks on this head: |
|
Thanks @BobClawblaw, both memory-plan points are fixed, and the tests pin them well. One charge per stream:
The two-stream, draft-off and allocation-order tests cover exactly what we asked. The context bound: the bound now includes the first stream's ring, for automatic sizing and an explicit There's one small overlap with main, in the third-party notices, and we'll resolve it on our side. Nothing more is needed from you on the code. The remaining step is a device run with the drafter on Ripple. We don't have that checkpoint on our test machines yet, so your drafted against plain numbers on this head would decide it: one and two streams, greedy and sampled, with token hashes for each. Thanks again for the careful follow-through.
|
…er's packed weights and the selector walk The drafter's config parse moves from dflash2_config.zig to dflash2_spec.zig, which needs no Metal, so the CUDA build shares it; dflash2_config.zig re-exports it. ashhart#2260's refusal of a clamped MLP (ffn_clamp_threshold) moves with it, and max_streams stays in dflash2_config.zig. cuda_dflash2_weights.zig reads the release through that parse and packs its projections for the lane matmul; cuda_dflash2_select.zig is the host walk over each row's top-32 candidates, as rc_df_walk.
…rafted replies equal plain ones The drafter runs dflash2.zig's op order over the target's taps, streams batched in 16-row blocks, and serves through the lane core's Drafted wrapper. --drafter's config.json goes through ashhart#2260's qualified parse and the CUDA kernels' gate before any stream, so its bytes are admitted with the streams'; a drafter that leaves no room for one stream is refused by name. ripple-drafted checks drafted == plain at 1, 2 and 8 streams. The config read and the gate move to cuda_dflash2_config.zig, unchanged, with a test that a clamped MLP (ffn_clamp_threshold) is refused as ashhart#2260 refuses it. THIRD_PARTY_NOTICES lists the CUDA drafter files beside dflash2.zig and dflash2.metal.
|
Thanks. Here is the drafted-against-plain run on this head (2b182da), on an M5 Ultra with the NVFP4 release and the publisher's DFlash2 drafter. How it was run. The same binary was served twice, both times with
In every row, all three columns have the same token hash, and the reply texts' hashes are equal too. Each reply has one logprob row per token except its stop token. Two streams gave the same tokens as one. Neither server logged an error or a With drafting on, prompt 0's requests finished 2.3-2.5 times faster than plain, and prompt 1's 1.2-1.6 times faster. Prompt 1's prose drafts less well (36-41% of drafted tokens accepted, against 85-95% for the code). Startup said |
|
Thanks @BobClawblaw, that settles it. In all eight cases (greedy and sampled, one and two streams, both prompts), the plain server, the drafter server with drafting off and with drafting on give the same token hashes, and two streams match one. The speed-up is clear too: 2.3-2.5x on the code prompt and 1.2-1.6x on the prose. Nothing more is needed from you. Main moved again today, so the branch now overlaps it in the third-party notices and
|
2b182da to
f0a3108
Compare
The drafted wrapper offers the target's first-token row only when asked, and the host left it off while advertising logprobs, so a logprobs request on a --drafter server failed at its first token even with drafting off. The host now builds the wrapper through dflash2_config.wrap, which asks for it, as the Flint host does. A host test runs a logprobs stream through that wrapper with drafting on and off, greedy and sampled, against the plain target, row for row (lanes exports its drafted fixture for it).
…er's logprobs check
…n to release, and the context fits the first ring
f0a3108 to
88d1cf3
Compare
|
Thank you @BobClawblaw. This is merged into main with your commits under your own name, so you're listed as a TensorFold contributor. It ships in the next release, credited to you in the changelog and the release notes. |
…er's packed weights and the selector walk The drafter's config parse moves from dflash2_config.zig to dflash2_spec.zig, which needs no Metal, so the CUDA build shares it; dflash2_config.zig re-exports it. ashhart#2260's refusal of a clamped MLP (ffn_clamp_threshold) moves with it, and max_streams stays in dflash2_config.zig. cuda_dflash2_weights.zig reads the release through that parse and packs its projections for the lane matmul; cuda_dflash2_select.zig is the host walk over each row's top-32 candidates, as rc_df_walk.
…rafted replies equal plain ones The drafter runs dflash2.zig's op order over the target's taps, streams batched in 16-row blocks, and serves through the lane core's Drafted wrapper. --drafter's config.json goes through ashhart#2260's qualified parse and the CUDA kernels' gate before any stream, so its bytes are admitted with the streams'; a drafter that leaves no room for one stream is refused by name. ripple-drafted checks drafted == plain at 1, 2 and 8 streams. The config read and the gate move to cuda_dflash2_config.zig, unchanged, with a test that a clamped MLP (ffn_clamp_threshold) is refused as ashhart#2260 refuses it. THIRD_PARTY_NOTICES lists the CUDA drafter files beside dflash2.zig and dflash2.metal.
What this changes
Adds the publisher's DFlash2 drafter for Ripple-65B on the native Metal engine:
ricursiveAI/Ripple-65B-Preview-DFlash2at35609b3be3dd08a822b3ba1257c1ea5dd6f87632(7.5 GiB, bf16), read in place as published.serve ... --drafter DIRon aricursivecheckpoint now drafts with it. Before,--drafterwas refused for this family.0847e954b, on mainff742df35), one commit. It needs ricursive: Ripple-65B-Preview on native Metal (NVFP4 and bf16 releases) #2231 first.atc overlap --json(atc 0.9.4, on this stack's head): the same as ricursive: Ripple-65B-Preview on native Metal (NVFP4 and bf16 releases) #2231's (ricursive: Ripple-65B-Preview on native CUDA (NVFP4) #2302 stacked on an earlier ricursive: Ripple-65B-Preview on native Metal (NVFP4 and bf16 releases) #2231;qwen27: serve the 27B pair, refuse what a pair cannot keep, and die with the peer #1434, qwen27: add the pair acceptance and supervision scripts #1436 and qwen27: document two-Mac 27B serving and the row split's exactness #1437 in
zig/src/tensorfold.zig); every other overlap it could check is clean or unknown.Whichever lands second rebases.
Things to say up front
The harness checks this on the full model (below).
rounds tie plain ones except on lists, where they are faster, and at seven they are slower on every kind (table in the
doc). So with
--drafterthe server opens two streams when--parallelis not named, and refuses a named--parallelabove 2 by name.over 4,096 keys, and the fifth (NoPE) over the release's 16,384-key draft window. Its 7.7 GiB (weights and rings)
comes out of the cache budget: 127.5 GiB instead of 135.2, seven 262,144-token streams instead of eight.
DFlash2DraftModelin z-lab/dflash'sdflash/model.pyat07ebd93db9f472af339b644bb70221ad8428328a(MIT): the taps'fcand norm, the layer order, the grouped dynamiccausal convolutions and the candidate selector, at its rounding points. z-lab imports its norms, rotary and MLP from transformers' Qwen3 module; ours follow the
release's own
RicursiveRMSNorm,RicursiveRotaryEmbeddingandRicursiveMLP(modeling_ricursive.py) instead. TheNoPE layer is
no_rope_layersin the drafter'sconfig.json, and the 16,384-token draft window is frominference/server/README.mdin Ripple-65B-Preview at240d5966. The first push followed SGLang'sdflash.py; this one was rechecked step by step against these twosources alone and changed where they differ (the convolution's and the selector's rounding). Both are in
THIRD_PARTY_NOTICES.md.dflash2_config.zigaccepts only this release's geometry beside Ripple-65B and refusesanything else by name.
Shared code
native/metal.zig:ricursiveis added to the--drafterfamily list and its refusal text.kernels/metal/sources.zig: one embed line.Everything else is in the family's folder (
families/ricursive/,kernels/metal/ricursive/dflash2.metal,native/ricursive.zig) and its contract files. On the plain path,forward.zigwrites the five taps only when adrafter asked for them. The A/B below shows plain Ripple unchanged.
Checks on this head
dae346404(on mainff742df35, ricursive: Ripple-65B-Preview on native Metal (NVFP4 and bf16 releases) #2231 at0847e954b;16251cfd0restacked, unchanged bygit range-diff):e2045e1f1with Synthena's 10 Nov items(the two-stream default when
--parallelisn't named, with a host test; tests for the hidden, vocab, tap, NoPE andlayer_typesrefusals, each failing without its rule; the tap point credited to z-lab'sextract_context_feature,and the drafter's config fixture named, in the notices; the four- and seven-stream wording in the comment, the
refusal, the recipe and the CHANGELOG; the recipe tables' commits; the drafter-load error path left to the
errdefer), restacked with ricursive: Ripple-65B-Preview on native Metal (NVFP4 and bf16 releases) #2231's rebase. Before it,25d92c5e5was restacked unchanged bygit range-diff. (Before it,8843987e8was rebased, its patch unchanged but forTHIRD_PARTY_NOTICES.md, where ricursive: Ripple-65B-Preview on native Metal (NVFP4 and bf16 releases) #2231's reworded entry is the line above this one.)16251cfd0, after the rebase ontofb8fdf3d8(this head's code is the same: main's two commits sincetouch only
CHANGELOG.mdanddocs/optimization-ledger.md; fmt,git diff --checkandcheck-release-pathsrerunhere) (each exit 0):
zig fmt --check,git diff --check,test-golden,test-kernel-contract,test-server-security test-pull-security,check-release-paths,fuzz-cortheon,dev-toolsandzig build test(whole, now that main's build: the FSR CLI host test gets the server's shared json module #2782 gives
fsr_cli_testsitsjsonmodule; before it, that one compile failed on this Macfor untouched main too, see ricursive: Ripple-65B-Preview on native Metal (NVFP4 and bf16 releases) #2231).
tf-kernel-contract --only ricursiveon25d92c5e5, whose Metal kernel sources and contract records for this familythis head carries unchanged (not rerun for this push): 75 kernels pass gates 1-4, 0 fail, 0 known findings; 25 controls red as planted, 0 missed; 0 limit problems (gates 839 s).
25d92c5e5's binary, the same code as this head's (the recipe harness's structured plan, Ornithstopped): NVFP4 release
structured 18/18 obey, drafted == plain 12/12, a bad regex 400; tools 5/5; bf16 release structured 18/18 obey, drafted == plain 12/12, a bad regex 400; tools 5/5.
659b92858(this head's drafter commit before the CHANGELOG-onlyrebase; NVFP4 release,
--context 32768, the drafter):--parallel 3with--drafteris refused with the new textbefore anything loads; with no
--parallelthe server reportsmax_batch_size: 2; greedy drafted replies equal"draft": falseon 3 of 3 prompts (19 to 110 tokens); two concurrent drafted replies equal their solo runs, 2 of 2.native/metal.zig): Qwen3.8-27B MLX 4-bit with--drafter z-lab/Qwen3.8-27B-DFlash2, sevengreedy requests (plain, thinking on and off, a system prompt, three turns, a tool call, a long prompt) from main
14dea6c6a's binary and25d92c5e5's, the same code as this head's: the sametoken_sha, token ids, text andreasoning on all seven (the tool call's
random
call_id aside); the same seven without the drafter too.the soak and resumed turns were run beside the NVFP4 release in earlier rounds and are unchanged by this rebase
(the drafter's files are the same patch). M1 to M4 Macs are refused at load, as for ricursive: Ripple-65B-Preview on native Metal (NVFP4 and bf16 releases) #2231.
Receipt
ricursiveAI/Ripple-65B-Preview-NVFP4at99eea4477a001a41b86914e41feb4b2ed86105e5, drafter at the revision above.b7ff7854f(this head's drafter code before the rebase; since then onlycomments changed,
--parallelabove 2 is refused, and two streams open when it isn't named), the same results as on925ae9563:--context 262144 --parallel 2, greedy 256-token replies, no other modelbusy. Drafted on
a869c4f32(this drafter's code before the--parallelcap); "before" is ricursive: Ripple-65B-Preview on native Metal (NVFP4 and bf16 releases) #2231 at3a5954f38, measured on the same day.The speedup is 1.5-2.7× with one stream and 1.2-2.16× with two. A round keeps 2.65 tokens with one stream (48% of
drafted tokens accepted) and 2.65 with two (56%). Time to first token is 0.53-0.65 s with one stream.
--parallel 7, one binary with and without--drafter(e1d719275, this drafter'scode before the cap); tok/s for all streams, prose / code / structured / list:
So with
--drafterthe server opens two streams unless--parallelis named, and refuses a named value above 2.ricursiveAI/Ripple-65B-Previewat240d5966), onb7ff7854f, plain and drafted fromthat one binary,
--parallel 2: drafted == plain 12/12.2.1-4.8× plain with one stream; a round keeps 2.93 tokens. Two drafted streams do not run together beside the bf16
release on a 256 GB M5 Ultra: the server starts under macOS memory pressure (22% free; the plain server 27%), and the
engine then admits a stream only when none runs, so a second request waits for the first reply (queued 5.4-14.0 s).
The two-stream drafted cells measured one stream at a time and are left out; so is a concurrency check there.
3a5954f38against45685de42, this PR before the z-lab rebuild, which changed onlydrafter-only kernels, tests, notices and docs; both without
--drafter): all 53 replies of the speed plan (rulers and aresumed turn) have the same hashes in the same order; one stream 10.2/10.2/10.3/10.2 tok/s and 98.2 ms a round on both,
two streams 106.0 ms a round against 106.1.
Kernel contract
dflash2.metal: the target's tap; the drafter's norms, embed, q/k prep, convolution, SiLU,attention, top-k and walk. Each has float64 references (
zig/tests/contract/metal_ricursive_dflash2*.zig).ricursive_records.zig.130 blocks.
tf-kernel-contract --only ricursive, M5 Ultra, exit 0, on this tree before its last rebase (see above):