Skip to content

ricursive: speed up Ripple-65B on two GB10s - #2523

Open
ajensenwaud wants to merge 30 commits into
ashhart:mainfrom
ajensenwaud:ricursive-tp2-dflash2
Open

ajensenwaud wants to merge 30 commits into
ashhart:mainfrom
ajensenwaud:ricursive-tp2-dflash2

Conversation

@ajensenwaud

@ajensenwaud ajensenwaud commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

What this is

The publisher's DFlash2 draft model for Ripple-65B-Preview, on the two-GB10 path of #2522 (--tp 2), behind
lanes.drafter with --drafter <dir>. Stacked on #2522 (and through it on #2231), on main c5a044877; six commits on top
(the drafter b0cb85dd0, its kernel contract d67bceee6, the contract's docs fc8a8314c, the review's fixes
c1811454e and e4f51d606, its changelog line daa016ce1). The
one-GPU path has its own drafter in #2475; the two do not share files.

  • --drafter-bits 0 (the BF16 weights as published) is served; 4 is refused by name (DrafterBitsUnsupported).
    Give both ranks the same --drafter <dir> --drafter-bits 0 (the recipe says so).
  • Maths: the drafter release holds only config and weights; the taps, NoPE layers, 16,384-position reach and pre-norm
    blocks follow inference/server/model.py in the Ripple-65B-Preview release, and the draft model it runs is SGLang
    0.5.19's DFlashDraftModel (python/sglang/srt/models/dflash.py); THIRD_PARTY_NOTICES names both.
  • The drafter (BF16, as released) is cut over both ranks as the target is: heads, FFN, and the fc/o/down inputs; the
    vocab halves' top-k are gathered on rank 0. Rank 1 opens its share when rank 0's plan word says so, from its own
    --drafter.
  • It reads the target's tap rows (the residuals after the release's five tap layers, written by ricursive: serve Ripple-65B on two GB10s with up to 1M tokens of context #2522's tf_rtp2_taps),
    runs 4-tap block convolutions, a NoPE full-attention layer split over keys and merged in order, and the release's
    32-candidate selector.
  • Kernels: ricursive_tp2_draft.cu (tf_rtp2d_*: tap gathers, RMS norms, the two convolution branches, head norms with
    RoPE, K/V puts, bf16 casts, SiLU, embed, split attention, merge, top-k), loaded from the family's own image.
  • Shared code: the image's two build lines, its records' join line, and the contract's registration (two lines in
    contract_family_sets.zig a group, one command in the CUDA runner).

Kernel contract

contract_ricursive_tp2_draft*.zig (tf-cuda-test ricursive-tp2-draft-contract; both Ripple groups also join
kernel-contract). Each of the twelve kernels through gates 1-4, each with a planted control (tf_rtp2d_ctl_*, red at
shapes):

Kernel Gate kind Registrations Control
tf_rtp2d_gather exact (bf16 words) rank 0's and rank 1's tap columns rows read from the ring's next row
tf_rtp2d_embed exact (bf16 widened to fp32) unscaled rows, id vocab - 1 included table read as fp16
tf_rtp2d_f2b exact (nearest even) value rows toward zero
tf_rtp2d_topk exact (32 best a 2,048 slice, ties to the lower id, NaN as -Inf) a rank's 50,176 logits lane ties to the higher id
tf_rtp2d_rms float64 range, fp32 sums every row bf16; block drafts fp16; block drafts bf16 x / rms unrounded
tf_rtp2d_silu float64 range (__expf within 2 + 1.2 |x| ulps) a rank's FFN width silu(g) rounded to bf16
tf_rtp2d_conv_in float64 range, fp32 sums first branch, bf16 rows second branch's weights
tf_rtp2d_conv_out float64 range, fp32 sums second branch plus residual first branch's weights
tf_rtp2d_heads float64 range, fp32 sums 40 query heads roped; 4 key heads roped; query heads unrotated rotated the other way
tf_rtp2d_kv_put float64 range (keys), exact (values) roped; unrotated values toward zero
tf_rtp2d_attn + tf_rtp2d_merge float64 softmax range of the merged output sliding layer (4,096); full layer (16,384) ring keys one row on; merge's running sum never rescaled

The controls sit beside the served kernels in the same image; the twelve served kernels' SASS is identical to the
drafter commit's for nvcc 13.0 and 13.3 on sm_80/86/89/120/121 (60 of 60 functions each, cuobjdump -sass compare at
the image's flags), so the gate-5 records stand unchanged.

On GB10 (sm_121, nvcc 13.3 build of 23f77f300, the same drafter and contract files as this head on main b4db86321):

SUMMARY ricursive_tp2: 10 kernels, 10 pass gates 1-4, 0 fail; 8 controls: 8 red as planted, 0 missed
SUMMARY ricursive_tp2_draft: 18 kernels, 18 pass gates 1-4, 0 fail; 12 controls: 12 red as planted, 0 missed
(filtered) SUMMARY 28 kernels: 28 pass gates 1-4, 0 fail, 0 known findings; 20 controls: 20 red as planted, 0 missed; 0 limit problems; gates 229563 ms, limits 0 ms

The last is tf-cuda-test kernel-contract "cuda ricursive_tp2" (both groups at the full run's seed). Not run on other
GPUs.

Checks

On 56e0aaffb (these commits on main c15d80023; main's moves since are changelog lines, server tool-call ids, qwen27 and deepseek_v41), host, Zig 0.17.0: zig build test-ricursive-tp2-host native ricursive-tp2-cuda compile-cuda-tests test-kernel-contract test-kernel-symbols-host test-native-options-host test-cuda-host test-golden:
every step passed, EXIT 0. tools/zig/lean_check.py 398 problems on the branch and on main, none new; every touched
source file at or under 600 lines; zig fmt --check and git diff --check clean. nvcc 13.3, sm_121: zig build install native compile-cuda-tests ricursive-tp2-cuda EXIT 0 on 0fb762b2f (since then two comment lines and main's
moves). Gate-5 records from cuobjdump -res-usage (13.0 base, 13.3 in pending_133.zig, 13.2 pending).

Measured on the same drafter code on 1.2.3 (two GB10s, 5.0 pack, one stream, greedy, 512 tokens): drafted replies
equal "draft": false token for token; decode 46.6 tok/s on code, 19.2 on chat, 31.7 on an agent tool-call prompt,
against 9.9 plain.

Served (two GB10s, --tp 2, 5.0 pack)

On 0fb762b2f (2026-11-09; since then two comment lines and main's moves), --parallel 2 --drafter <DFlash2> --drafter-bits 0, 512 tokens a reply, prompts code, chat and an agent prompt with tools:

  • Greedy: drafted == "draft": false (shas 6cda6ef3, 82cd27f9, e83a546c both ways).
  • Seeded sampling (temperature 0.7, seed 7): drafted == "draft": false (shas bc152a9b, 8ece1837, bee04af2 both
    ways).
  • Two streams at once (--parallel 2, code and chat), greedy and seeded: every concurrent reply equals its solo reply,
    drafted and plain, and drafted == plain. Aggregate 35.1 tok/s drafted, 19.1 plain (greedy).
  • A resumed prompt with the drafter on: a 31,265-token chat's second turn resumed (30,909 tokens cached; the drafter
    accepted 184 of 346) equals the same turn on a freshly started serve.

Credits: ricursiveAI for the drafter release; turboderp's ExLlamaV3 and @auryn-macmillan for the target's EXL3 packs.

ajensenwaud added a commit to ajensenwaud/TensorFold that referenced this pull request Nov 8, 2026
@ajensenwaud
ajensenwaud force-pushed the ricursive-tp2-dflash2 branch from 449c34b to 4dd1313 Compare November 8, 2026 06:19
ajensenwaud added a commit to ajensenwaud/TensorFold that referenced this pull request Nov 8, 2026
@ajensenwaud
ajensenwaud force-pushed the ricursive-tp2-dflash2 branch from 4dd1313 to 210a6b2 Compare November 8, 2026 11:51
ajensenwaud added a commit to ajensenwaud/TensorFold that referenced this pull request Nov 8, 2026
@ajensenwaud
ajensenwaud force-pushed the ricursive-tp2-dflash2 branch from 210a6b2 to fc874f3 Compare November 8, 2026 16:07
ajensenwaud added a commit to ajensenwaud/TensorFold that referenced this pull request Nov 8, 2026
@ajensenwaud
ajensenwaud force-pushed the ricursive-tp2-dflash2 branch from fc874f3 to 970a311 Compare November 8, 2026 16:20
ajensenwaud added a commit to ajensenwaud/TensorFold that referenced this pull request Nov 8, 2026
@ajensenwaud
ajensenwaud force-pushed the ricursive-tp2-dflash2 branch from 970a311 to a13fee7 Compare November 8, 2026 22:01
@ajensenwaud
ajensenwaud marked this pull request as ready for review November 8, 2026 22:02
ajensenwaud added a commit to ajensenwaud/TensorFold that referenced this pull request Nov 8, 2026
@ajensenwaud
ajensenwaud force-pushed the ricursive-tp2-dflash2 branch from a13fee7 to a666bf0 Compare November 8, 2026 23:26
@ashhart

ashhart commented Nov 9, 2026

Copy link
Copy Markdown
Owner

@ajensenwaud thanks for the drafter; running it through lanes.drafter is the right shape. It waits on #2522 and on the family decision in #2171. When you next touch it: (1) please extend THIRD_PARTY_NOTICES.md to ricursive_tp2_draft.cu, and name the file in the drafter release that its math follows; (2) please refuse --drafter-bits values it doesn't honour by name, as gemma4 does, instead of warning (tp2_native.zig:112); (3) please fix the stale references (ricursive_draft.cu, "on rank 0's device" at tp2_draft_load.zig:1,216,223; tp2_native.zig:18); (4) could you add receipts for drafted = draft:false with seeded sampling, at --parallel 2, and for a resumed prompt with the drafter on, on this head?

ajensenwaud added a commit to ajensenwaud/TensorFold that referenced this pull request Nov 9, 2026
@ajensenwaud
ajensenwaud force-pushed the ricursive-tp2-dflash2 branch from a666bf0 to 56e0aaf Compare November 9, 2026 06:26
ajensenwaud added a commit to ajensenwaud/TensorFold that referenced this pull request Nov 9, 2026
@ajensenwaud
ajensenwaud force-pushed the ricursive-tp2-dflash2 branch from 56e0aaf to daa016c Compare November 9, 2026 06:36
ajensenwaud added a commit to ajensenwaud/TensorFold that referenced this pull request Nov 9, 2026
@ajensenwaud
ajensenwaud force-pushed the ricursive-tp2-dflash2 branch from daa016c to 02c30a1 Compare November 9, 2026 07:55
ajensenwaud added a commit to ajensenwaud/TensorFold that referenced this pull request Nov 9, 2026
@ajensenwaud
ajensenwaud force-pushed the ricursive-tp2-dflash2 branch from 02c30a1 to a060764 Compare November 9, 2026 07:57
@ajensenwaud

Copy link
Copy Markdown
Contributor Author

Thanks, Ash.

  1. THIRD_PARTY_NOTICES now covers tp2_draft*.zig and ricursive_tp2_draft.cu. Because the drafter release ships only a config and weights, the notice names the two files whose arithmetic the code follows:
    • inference/server/model.py in Ripple-65B-Preview, which defines the taps, the layers without RoPE, the 16,384-position reach of the global layer and the pre-norm blocks.
    • The model that file runs, DFlashDraftModel in SGLang 0.5.19 (python/sglang/srt/models/dflash.py), which supplies the grouped convolutions, the block attention and the selector.
    • No SGLang code is copied.
  2. Any --drafter-bits other than 0 is now refused by name (DrafterBitsUnsupported), with a test. The drafter runs only its published BF16 weights, so even the default of 4 is refused; the recipe passes --drafter-bits 0.
  3. The stale references are fixed, and the drafter's own world == 1 paths have gone the same way as the target's.
  4. The receipts were taken on two GB10s with the 5.0 pack at --tp 2 --parallel 2 --drafter-bits 0, 512 tokens per reply:
    • With seeded sampling (temperature 0.7, seed 7), drafted replies match "draft": false on code, chat and a tool-calling agent prompt, as they do under greedy decoding.
    • With two streams running at once, under both greedy and seeded sampling, every reply matches its solo run and its undrafted run.
    • With the drafter on, the second turn of a 31,000-token chat, resumed with 30,909 tokens from the cache, matches the same turn on a freshly started server.

The branch is rebased on main f212eeabd on top of #2522; the full receipts and contract results are in the description.

@ashhart

ashhart commented Nov 10, 2026

Copy link
Copy Markdown
Owner

Thanks @ajensenwaud for the quick answers, and for the seeded, two-stream and resumed receipts.

#2171 now has a yes, landing #2231, #2260, #2302 and #2475 after our 1.2.6 release. This PR is on hold behind #2522. It's a hold, not a no.

The drafter's arithmetic follows SGLang's dflash.py, and our rules don't allow working from another engine's code. That's the same reason #2260's first version was rebuilt. Please rebuild the TP=2 drafter from our own code, starting from #2475's CUDA drafter once it lands and splitting it over the two ranks, with z-lab's dflash/model.py (MIT) and the release's own files as references. #2260 shows where the rest comes from. The NoPE layer is no_rope_layers in the drafter's config.json, and the 16,384-token window is in inference/server/README.md. Built on the folded family from #2522, one Ripple drafter would then serve one GPU and two.

When it's rebuilt, please post the receipts you posted here again: drafted == plain at --tp 2, greedy and seeded, solo and with two streams, and a resumed prompt. We can't promise a date.

  • Synthena (Ash's Agent)

ajensenwaud and others added 9 commits November 23, 2026 18:24
nvcc 13.0 and 13.3 give tf_rtp2_lerp 12 registers on sm_80 to sm_89.
The other kernels' records are unchanged.
At an 8-bit weight the two lerp forms round to the same bf16, so the
start-anchored control stayed green. A full fp32 weight tells them apart.
Follow main 4b997f8
(glm metal dflash2: account tap-stage bytes, fix host build core import, trim comments).
Keep all current dispatches and refusals beside the incoming Ripple entries.
Remove two interior blank lines to restore the 600-line source limit.
… (seven blank lines fewer)

Main's cuda.zig (last 833c695, the MOSS-Image recognizer) is at 590 lines with the special families moved into
open_family.zig; ashhart#2522's ranked registry loop, its ranks refusal and its test put it at 607. Seven blank lines between
adjacent tests at the end of the file go; no code changes.
…does

The blend is now the bf16 sigmoid of the stored lambda, shared with
Metal's blendOf, and a lambda that is not a bf16 value is refused.
Model.load and Ripple.init now release what earlier steps made, and a
failed open stops rank 1's follow loop.
@ashhart

ashhart commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Thanks @ajensenwaud. We've looked at the branch again. It's still a hold, not a no: we want the drafter at two ranks.

What's right: the --drafter-bits refusal, the stale references and the notice coverage are all fixed. Your earlier greedy, seeded, two-stream and resumed receipts are the right set to repeat later.

What's still needed:

  1. The drafter rebuild, as agreed on 13 Nov. The notice still says the drafter's maths follow SGLang's DFlashDraftModel. The plan is unchanged:

  2. The two-rank target's rounding points (THIRD_PARTY_NOTICES.md, the tp2*.zig and ricursive_tp2.cu entry). The notice says these come from a fork's Ripple support for ExLlamaV3. Our rule covers that too: we can't work from another engine's code, even with a notice. We should have said so earlier, sorry.

    • Where they can come from instead: the release's modeling_ricursive.py, plus the one-GPU Ripple CUDA family now on main (zig/src/families/ricursive/cuda_*.zig).
    • Timing: this can happen in the same rebuild.
  3. A refusal check that went missing. In zig/src/native/cuda.zig, openWith no longer calls refusals.family(F, o) after refusals.place; it was dropped in the two-rank target commit.

    • The effect: every CUDA family then opens instead of refusing flags it doesn't serve. For example, --kv-cache fp8 on a family that keeps bf16, --drafter on a family without one, or --tp 2 on a single-rank family; the flag is just silently ignored.
    • Why the tests pass: the refusal tests call refusals.family directly, so they don't catch it.
    • The fix: putting the call back after place.

There's nothing for you to do about main: the branch conflicts with it in four files, and we'll handle that when it's ready. We can't promise a date.

  • Synthena

@ajensenwaud
ajensenwaud force-pushed the ricursive-tp2-dflash2 branch from 51ffb46 to 6db8771 Compare November 24, 2026 08:52
@ajensenwaud

ajensenwaud commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks, Ash. I have rebased the drafter onto #2522's current head, which settles points 2 and 3. Point 1 waits on #2475: once it lands, I will rebuild the drafter from it.

  1. Drafter rebuild. Agreed, and it is the one item left on this PR. When ricursive: Ripple-65B-Preview's DFlash2 drafter on native CUDA #2475 lands, I will rebuild the two-rank drafter from it, with z-lab's dflash/model.py and the release's own files as references, and post the same receipts on the new head.
  2. Target rounding points. The target's activations now round as the release does, in bf16, and the notice credits modeling_ricursive.py alone. The value-residual blend now matches main's blendOf too, after your 23 Nov review of ricursive: serve Ripple-65B on two GB10s with up to 1M tokens of context #2522.
  3. Refusal check. openWith calls refusals.family after refusals.place again. The call went missing only in this branch's older copy of the target, and ricursive: serve Ripple-65B on two GB10s with up to 1M tokens of context #2522's head keeps it. A new test on ricursive: serve Ripple-65B on two GB10s with up to 1M tokens of context #2522 (5fb85fd50) opens every registered CUDA family through cuda.open with each flag it does not serve and expects that family's own refusal. With the call removed, the test fails.

@ashhart

ashhart commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Thanks @ajensenwaud. Confirmed on the new head, which now sits on #2522:

That leaves the drafter rebuild, which waits for #2475 as agreed. Nothing else is needed from you before then.

  • Synthena

ajensenwaud and others added 7 commits November 24, 2026 20:05
The refusal tests called refusals.family directly, so they passed when
openWith stopped calling it. This test goes through cuda.open for every
registered family and fails with the call removed.
The release's DFlash2 draft model (BF16) behind lanes.drafter, cut over both ranks
as the target is (heads, FFN, fc/o/down inputs; the vocab halves' top-k gathered on
rank 0): taps of the target's residuals (the target's tap ring), 4-tap block
convolutions, a NoPE full-attention layer split over keys and merged, and a
32-candidate selector. Rank 1 opens its share when rank 0's plan word says so, from
its own --drafter. Drafted replies equal "draft": false token for token.

Kernels: ricursive_tp2_draft.cu (tf_rtp2d_*), with gate-5 launch records (nvcc 13.0
base, 13.2 pending, 13.3).
…gh gates 1-4, each with a planted control

Exact by host rule: tap gathers, embed, f2b, top-k. Inside float64's range: rms, silu, both convolutions, head
norms, kv_put, and attn with its merge. Controls tf_rtp2d_ctl_* sit beside the served kernels, whose SASS is
unchanged (nvcc 13.0 and 13.3, sm_80/86/89/120/121), so the launch records stand. Both Ripple groups join the
kernel-contract run; ricursive-tp2-draft-contract runs the drafter's alone.
…o one-rank branches, current file names

The drafter runs its BF16 weights as published, so --drafter-bits 0 is served and 4
is refused with DrafterBitsUnsupported (explained), as Gemma 4 refuses what it does
not run, instead of a warning. The world == 1 paths in tp2_draft.zig and
tp2_draft_load.zig (and Cut's one-rank default) go, as the target's did: admission
takes two ranks only. Comments name ricursive_tp2_draft.cu and the drafter's cut over
both ranks, not rank 0's device.
…model its maths follow; --drafter on both ranks

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants