Skip to content

dflash_head: read the tree lattice at the launched selector's own lists offset (tree verify accepted nothing since #328) - #369

Merged
AzeezIsh merged 2 commits into
mainfrom
fix/tree-lattice-lists-offset
Nov 25, 2026
Merged

AzeezIsh merged 2 commits into
mainfrom
fix/tree-lattice-lists-offset

Conversation

@AzeezIsh

Copy link
Copy Markdown
Contributor

Summary

This is the root cause behind #368's symptom. After #328's 32-candidate selector (48cfe3c68), the shared selector scratch is sized for K=32 (dflash2_selector_scratch_bytes). But the tree lattice (dflash_head/tree_lattice.rs) still located the rows' merged top-K lists at scratch_bytes − lists_bytes(K=16). The 16-candidate kernel writes them right after its own K=16 slice lists and row tickets (df2_sel_scratch). So the host read the wrong bytes:

dflash2_selector_lists_offset(gamma, max_top_k) now mirrors the kernel layout per build, and the lattice reads by the launched build's own K. dflash2_selector_scratch_bytes is derived from the same function, with an unchanged value.

Results (one GB10, Qwen3.8-27B NVFP4, #333 exact profile at 8 seqs + ATLAS_DFLASH_TREE=16)

main b3732cd5 (#368) this PR
tree-verify drafts accepted per step (mean_na) 0.000 (tok_step=1.000, 10.7 tok/s) 2.4–4.0
8 prompts × 320 tokens at C1 (wall) ~4 min ~67 s
greedy_eq vs serial, C1 / C1 + prefix / C8 8/8 / 8/8 / 8/8 8/8 / 8/8 / 8/8
same with ATLAS_ATTN_SHARED_SCAN=1 vs the switch-on serial 8/8 ×3 8/8 ×3

0 serve errors. This also explains why #333's measured +4% tree gain disappeared after #328 landed.

Still open: ATLAS_DFLASH_TREE at --max-num-seqs 64 OOMs at load. It sizes 15 SSM verify snapshots for all 65 slots, although tree verify runs only at C1.

Test plan

  • merged_lists_follow_each_builds_own_layout (both builds; gamma 8/16/32); dflash2_selector + draft_tree 11/11; fmt; clippy
  • GB10 as above (nq-139-tree-lattice on sparky)

Generated with Devin

…ts offset

#328's 32-candidate selector (48cfe3c) sized the shared selector scratch for
K=32, but tree_lattice still located the merged top-K lists as
scratch_bytes - lists_bytes(K=16). The 16-candidate kernel writes them past its
own K=16 slice lists (df2_sel_scratch), so the host read the wrong bytes: the
tree's candidates were garbage (duplicate siblings, the #368 500) and no draft
was ever accepted. dflash2_selector_lists_offset(gamma, max_top_k) now mirrors
the kernel layout per build, and scratch_bytes is derived from it.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>

@data-angel data-angel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked the layout against the kernel. df2_sel_scratch puts 4 ticket words first, then the gamma × SPLITS × K slice values and ids, then gamma row tickets, then the merged values and ids, all sized by its own DF2_SEL_MAX_TOP_K. That is 16 + 8·gamma·SPLITS·K + 4·gamma bytes, which is what dflash2_selector_lists_offset returns, and the merged ids follow the values contiguously, so the 2·4·gamma·kmax read is right for both builds. DF2_SEL_MAX_SPLITS (16) matches DFLASH2_SELECTOR_MAX_SPLITS, and the other scratch users (rank_split_topk, dspine, dflash2_selector_exact) only size the buffer, so they're unaffected. Sorry #328 caused this.

One blocker: ops/sampling.rs is now 508 lines (main: 500), so this PR's own "File size cap" job fails. Moving dflash2_selector_lists_offset (and dflash2_selector_scratch_bytes with it) into dflash2_selector_build.rs, which is at 115 lines and already holds the test, fixes it without changing anything else.

…uild.rs (sampling.rs back under the 500-line cap)

Generated with [Devin](https://devin.ai)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@AzeezIsh

Copy link
Copy Markdown
Contributor Author

@data-angel Thanks for checking the layout against the kernel. Your fix for the blocker is in aeb857072: dflash2_selector_lists_offset and dflash2_selector_scratch_bytes moved into dflash2_selector_build.rs with their bodies and docs unchanged, plus one import of DFLASH2_SELECTOR_MAX_SPLITS. sampling.rs is 489 lines and dflash2_selector_build.rs 137. The ≤500-line job passes now, and the remaining CI failures (env budget, PR benchmark gate, cargo deny) are main's baseline.

Re-gated on one GB10 (sparky). Qwen3.8-27B NVFP4, the #333 exact profile at 8 sequences, DFlash2 with ATLAS_DFLASH_TREE=16, fresh builds. Main 96b41363d with this PR merged (tree 771c3aa5a), against main's serial run:

main (tree verify) this PR (tree verify)
Accepted drafts per step (mean_na, last 20 requests) 0.000 (tok_step 1.000) 2.0–4.1
greedy_eq C1 / C1 with a shared 4.4K prefix / C8 vs serial 8/8 / 8/8 / 8/8 8/8 / 8/8 / 8/8
C1 decode, prose / code (median of 3, tok/s) 10.59 / 10.59 30.0 / 46.1
Serve errors 0 0

These numbers are from one harness on one box. The main column comes from main + #332 + #397, which has the same tree-lattice code as main. For reference, DFlash2 without tree verify on main decodes prose at 27.75 and code at 45.42 tok/s under the same harness.

Generated with Devin

@AzeezIsh

Copy link
Copy Markdown
Contributor Author

Queued in train #421 (integ/train-inkling-20261125), merged --no-ff in stack order. GB10 gate is running on sparky (job 187); results will be posted on #421.

🤖 Generated with Claude Code

@AzeezIsh
AzeezIsh merged commit 2b7f9db into main Nov 25, 2026
24 of 27 checks passed
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