[GH-ISSUE #402] DeepSeek: verify a tree instead of a chain in the DSpark path (EAGLE-4 reports 1.63-1.85x over DSpark/DFlash2, and the drafter is not the difference) #155

Open
opened 2026-10-29 21:21:45 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @precisionailabsllc-collab on GitHub (Oct 23, 2026).
Original GitHub issue: https://github.com/mw00/project-maya/issues/402

What and why

DSpark's verify is a chain: one continuation per position, and an early miss discards every later draft in that
window. EAGLE-4's public deepdive (fal/Fireworks, 2026-10-20) benchmarks against DSpark and DFlash2 and reports
1.63x (Fireworks bench) to 1.85x (their creative bench) more throughput at batch 1 — and the gain is not the
drafter, it is the verification structure:

a single chain commits to one continuation at each position, so an early mismatch prevents later tokens in that
chain from being accepted. Branching gives the verifier alternative continuations to consider.

Their acceptance-length numbers against a chain at equal verification budget: +9.6% (Fireworks dataset),
+12.4% (their text bench), and at a budget of 16 tokens +21.1% / +26.1%. First-token hit rate rises from
72.5% to 85.3% — the gain is concentrated in the early positions, which is exactly where a chain wastes its budget
on later positions that are never reached.

This needs no new drafter. DSpark already produces a distribution at each position, so a tree can be drafted from
it today. What is missing is engine code: src/ds4/ has no tree, branch, dfs or beam anywhere, and the only
drafting controls are chain-shaped (spec window, MAYA_DS4_DSPARK_CUM).

What a minimal version looks like

  1. Drafting — from the drafter's per-position logits, keep the top-k candidates at each level (a regular tree:
    width k, depth d, budget-limited) instead of one token. Reuse the existing confidence cut to decide when to stop.
  2. Verification — one target forward pass over the tree's nodes, with a tree attention mask: a node attends to
    the shared prefix, its ancestors and itself; siblings and other branches are masked. Position ids follow the path
    depth, not the node index.
  3. Acceptance — walk the tree along the accepted path, keep the longest matching prefix, free the KV entries of
    rejected branches, then take the target's next token (or continue the chain as today for temperature 0).
  4. Harness (optional, second step) — a small cost table from a one-off calibration (verify latency against batch,
    context length, candidate count) used to widen/deepen the tree only while the cumulative-probability gain per
    measured token cost stays above a threshold. That is what removes the fixed spec/spec_cum knobs.

Steps 1-3 are the win; step 4 is the tuning.

What I can offer

I run Maya-S and Maya-XS (v1.1.24 + a few of the open PRs) on a Ryzen AI Max+ 395 (gfx1151, 128 GB), and I have a
harness that measures decode through the engine's own accounting with a strict quiet-window guard, plus a quality panel
that scores logits against a reference. If a branch lands, I can report grep-able decode/acceptance numbers at
16K-35K context, and check that greedy tokens are unchanged (a tree must not change the output distribution).

I am also willing to prototype and test whatever shape of tree you would accept — but the mask and the KV-slot
bookkeeping belong in the engine's own hands rather than a patch of mine.

Originally created by @precisionailabsllc-collab on GitHub (Oct 23, 2026). Original GitHub issue: https://github.com/mw00/project-maya/issues/402 ## What and why DSpark's verify is a **chain**: one continuation per position, and an early miss discards every later draft in that window. EAGLE-4's public deepdive (fal/Fireworks, 2026-10-20) benchmarks **against DSpark and DFlash2** and reports **1.63x** (Fireworks bench) to **1.85x** (their creative bench) more throughput at batch 1 — and the gain is not the drafter, it is the **verification structure**: > a single chain commits to one continuation at each position, so an early mismatch prevents later tokens in that > chain from being accepted. Branching gives the verifier alternative continuations to consider. Their acceptance-length numbers against a chain at equal verification budget: **+9.6%** (Fireworks dataset), **+12.4%** (their text bench), and at a budget of 16 tokens **+21.1% / +26.1%**. First-token hit rate rises from **72.5% to 85.3%** — the gain is concentrated in the early positions, which is exactly where a chain wastes its budget on later positions that are never reached. **This needs no new drafter.** DSpark already produces a distribution at each position, so a tree can be drafted from it today. What is missing is engine code: `src/ds4/` has no `tree`, `branch`, `dfs` or `beam` anywhere, and the only drafting controls are chain-shaped (`spec` window, `MAYA_DS4_DSPARK_CUM`). ## What a minimal version looks like 1. **Drafting** — from the drafter's per-position logits, keep the top-k candidates at each level (a regular tree: width k, depth d, budget-limited) instead of one token. Reuse the existing confidence cut to decide when to stop. 2. **Verification** — one target forward pass over the tree's nodes, with a **tree attention mask**: a node attends to the shared prefix, its ancestors and itself; siblings and other branches are masked. Position ids follow the path depth, not the node index. 3. **Acceptance** — walk the tree along the accepted path, keep the longest matching prefix, free the KV entries of rejected branches, then take the target's next token (or continue the chain as today for temperature 0). 4. **Harness (optional, second step)** — a small cost table from a one-off calibration (verify latency against batch, context length, candidate count) used to widen/deepen the tree only while the cumulative-probability gain per measured token cost stays above a threshold. That is what removes the fixed `spec`/`spec_cum` knobs. Steps 1-3 are the win; step 4 is the tuning. ## What I can offer I run Maya-S and Maya-XS (v1.1.24 + a few of the open PRs) on a Ryzen AI Max+ 395 (gfx1151, 128 GB), and I have a harness that measures decode through the engine's own accounting with a strict quiet-window guard, plus a quality panel that scores logits against a reference. If a branch lands, I can report grep-able decode/acceptance numbers at 16K-35K context, and check that greedy tokens are unchanged (a tree must not change the output distribution). I am also willing to prototype and test whatever shape of tree you would accept — but the mask and the KV-slot bookkeeping belong in the engine's own hands rather than a patch of mine.
Author
Owner

@precisionailabsllc-collab commented on GitHub (Oct 23, 2026):

A concrete patch sketch, from reading the current code

I filed this as a feature request; since then I read the verify/attention path closely enough to say what a minimal
branch would touch. Posting it in case it saves you the survey — and because one detail makes it smaller than it looks.

What already exists (v1.1.24 anchors)

  • Model::verify() (src/ds4/ds4_model.cu:8466) lays the drafts as a chain — tk[0] = y; tk[i+1] = drafts[i] — and
    calls forward(tk, T, T); then walks while (m < n && h_idx[m] == drafts[m]) ++m for the accepted prefix.
  • forward() (:10415) takes tokens only; positions are implicit p0 + t. No mask parameter anywhere in the
    attention path.
  • WinPlan (:894) already carries a per-token bitmask: unsigned vl — "bit t: token t is inside a picture's span".
    So a per-row property threaded into the plan and the kernels has precedent.
  • The speculative window already keeps rollback state: spec_win (:1004) makes layer() keep
    l.ring_bak (:10725) and l.c_snap (:10756) "to replay the accepted rows if drafts are rejected".
  • Four decode attention kernels exist (ds4_kernels.cu): sparse_attn_kernel (:1226), _packed_ (:1418),
    _wmma_ (:1609), _mma_ (:1807). On gfx1151 the WMMA one runs.

The three changes

1. A parent index in the plan (no new infrastructure).

struct WinPlan {
    unsigned vl = 0;
    int parent[kWin];      // NEW: row t's parent row, -1 = "attends to the prefix only"
    // ... linear windows keep parent[t] = t - 1, so nothing else changes
};

Position ids follow depth, not index: pos[t] = p0 + depth(t) — cheap to compute once per window when the plan is
built, and it is what makes two siblings share a position instead of one attending to the other.

2. forward() takes the plan's parent array (default null = the linear chain).

bool forward(const int* tk, int T, int logits_rows, std::string& err, int seed_rows = -1,
             const int* parent = nullptr);   // null: parent[t] = t - 1, today's behaviour

Every existing caller is unchanged, which keeps the risk contained to the new path.

3. The attention kernels take the same array. Today a row's visibility is "all rows before it in the window", which
is exactly why a second candidate would silently see the first. The mask becomes: a row attends to the prefix rows
(positions before p0) plus its ancestor chain — for a row at depth d, d rows, not pos rows. In the WMMA
kernel this is a predicate on the candidate index, not a new algorithm; the prefix part is untouched, so the sparse
selection, the FP4 KV and the compression all keep working.

Acceptance and the KV side

  • Acceptance walks the tree from the root: at each level take the child whose token equals the target's pick
    (h_idx[t]), stop at the first level with no such child. Same while as today, with a child lookup instead of
    m == i.
  • The ring/compressor state is then compacted to the accepted path: the existing ring_bak / c_snap replay
    path already exists for the rejection case, so this is "replay the accepted rows" with a different row list rather
    than new machinery.
  • Unverified branches are simply not replayed; nothing to free, because they were never committed.

Drafting: the tree is free on this engine

draft_() (:8256) already runs its blocks over T = g.d_block positions in one pass and keeps per-position logits
before sampling one token each. Keeping the top-k of those logits per level is a change inside the drafter's sampler,
not a new model or a second drafter.

What it should be worth

Measured on this machine (Maya-XS, v1.1.24, Ryzen AI Max+ 395): a chain already averages 4.34 tokens per verify
round
(position-1 acceptance 88% over 1,384 rounds). Applying EAGLE-4's branch recovery to that base gives roughly
+6% for a width-2 tree at depth 1, more for deeper trees.

And the cost side is unusually favourable here: verifying more rows costs nearly nothing when decode is
memory-bandwidth-bound. I measured spec=4 and spec=12 at 18.85 and 18.86 tok/s — 3x more rows, no cost, because
they ride the same weight reads. The tree spends the resource this hardware has idle.

What I can and cannot do

I am happy to prototype the host side against a design you endorse — the tree builder over the drafter's per-position
logits, the acceptance walk, and the ring compaction with a row list — and to report decode/acceptance numbers at
16K-35K context plus a greedy token-identity check. The mask predicate inside the four attention kernels is the part
that should stay in your hands: it is where a wrong answer would be silent rather than slow.

<!-- gh-comment-id:6355285439 --> @precisionailabsllc-collab commented on GitHub (Oct 23, 2026): ## A concrete patch sketch, from reading the current code I filed this as a feature request; since then I read the verify/attention path closely enough to say what a minimal branch would touch. Posting it in case it saves you the survey — and because one detail makes it smaller than it looks. ### What already exists (v1.1.24 anchors) - `Model::verify()` (`src/ds4/ds4_model.cu:8466`) lays the drafts as a chain — `tk[0] = y; tk[i+1] = drafts[i]` — and calls `forward(tk, T, T)`; then walks `while (m < n && h_idx[m] == drafts[m]) ++m` for the accepted prefix. - `forward()` (`:10415`) takes **tokens only**; positions are implicit `p0 + t`. No mask parameter anywhere in the attention path. - `WinPlan` (`:894`) already carries a **per-token bitmask**: `unsigned vl` — "bit t: token t is inside a picture's span". So a per-row property threaded into the plan and the kernels has precedent. - The speculative window already keeps **rollback state**: `spec_win` (`:1004`) makes `layer()` keep `l.ring_bak` (`:10725`) and `l.c_snap` (`:10756`) "to replay the accepted rows if drafts are rejected". - Four decode attention kernels exist (`ds4_kernels.cu`): `sparse_attn_kernel` (:1226), `_packed_` (:1418), `_wmma_` (:1609), `_mma_` (:1807). On gfx1151 the WMMA one runs. ### The three changes **1. A parent index in the plan (no new infrastructure).** ```c struct WinPlan { unsigned vl = 0; int parent[kWin]; // NEW: row t's parent row, -1 = "attends to the prefix only" // ... linear windows keep parent[t] = t - 1, so nothing else changes }; ``` Position ids follow depth, not index: `pos[t] = p0 + depth(t)` — cheap to compute once per window when the plan is built, and it is what makes two siblings share a position instead of one attending to the other. **2. `forward()` takes the plan's parent array (default null = the linear chain).** ```c bool forward(const int* tk, int T, int logits_rows, std::string& err, int seed_rows = -1, const int* parent = nullptr); // null: parent[t] = t - 1, today's behaviour ``` Every existing caller is unchanged, which keeps the risk contained to the new path. **3. The attention kernels take the same array.** Today a row's visibility is "all rows before it in the window", which is exactly why a second candidate would silently see the first. The mask becomes: a row attends to the prefix rows (positions before `p0`) **plus its ancestor chain** — for a row at depth `d`, `d` rows, not `pos` rows. In the WMMA kernel this is a predicate on the candidate index, not a new algorithm; the prefix part is untouched, so the sparse selection, the FP4 KV and the compression all keep working. ### Acceptance and the KV side - Acceptance walks the tree from the root: at each level take the child whose token equals the target's pick (`h_idx[t]`), stop at the first level with no such child. Same `while` as today, with a child lookup instead of `m == i`. - The ring/compressor state is then compacted to the **accepted path**: the existing `ring_bak` / `c_snap` replay path already exists for the rejection case, so this is "replay the accepted rows" with a different row list rather than new machinery. - Unverified branches are simply not replayed; nothing to free, because they were never committed. ### Drafting: the tree is free on this engine `draft_()` (`:8256`) already runs its blocks over `T = g.d_block` positions in one pass and keeps per-position logits before sampling one token each. Keeping the top-k of those logits per level is a change *inside the drafter's sampler*, not a new model or a second drafter. ### What it should be worth Measured on this machine (Maya-XS, v1.1.24, Ryzen AI Max+ 395): a chain already averages **4.34 tokens per verify round** (position-1 acceptance 88% over 1,384 rounds). Applying EAGLE-4's branch recovery to that base gives roughly **+6%** for a width-2 tree at depth 1, more for deeper trees. And the cost side is unusually favourable here: verifying more rows costs nearly nothing when decode is memory-bandwidth-bound. I measured `spec=4` and `spec=12` at 18.85 and 18.86 tok/s — **3x more rows, no cost**, because they ride the same weight reads. The tree spends the resource this hardware has idle. ### What I can and cannot do I am happy to prototype the host side against a design you endorse — the tree builder over the drafter's per-position logits, the acceptance walk, and the ring compaction with a row list — and to report decode/acceptance numbers at 16K-35K context plus a greedy token-identity check. The mask predicate inside the four attention kernels is the part that should stay in your hands: it is where a wrong answer would be silent rather than slow.
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
mw00/project-maya#155
No description provided.