Skip to content

lanes: hold a stream's draft depth against a noisy round; verify its probe (#3468) - #4012

Merged
ashhart merged 3 commits into
ashhart:mainfrom
javierbits:issue-3468-depth-margin
Nov 20, 2026
Merged

ashhart merged 3 commits into
ashhart:mainfrom
javierbits:issue-3468-depth-margin

Conversation

@javierbits

@javierbits javierbits commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

What this changes

On CUDA, a one-stream reply could measure one noisy round, drop from two drafts a round to one,
and keep that depth for the rest of the reply (7 of 32 identical 256-token greedy replies here).
Two changes in core/lanes:

  • Rule.depth keeps the depth it priced until another depth beats it by 5% on expected tokens
    a millisecond (Constants.depth_margin, applied like plain_margin). Estimates near the line
    no longer flip the stream; a depth that keeps losing still gives way.
  • The depth probe (one draft deeper every depth_probe_every rounds) now marks its rows on the
    plan, and a lone window keeps those rows instead of trimming them back to the priced width.
    The probe's acceptance and round time are therefore observed, which is what lets a stream that
    dropped recover.

The second half follows the diagnosis in #3468: the lone window's trim removed every probe row,
so the deeper depth's estimate never moved.

Checks on this head

  • Head commit: e0e8918 (issue-3468-depth-margin), base 8ddcb75.
  • Lean checker, python3 tools/zig/lean_check.py with lean_new.py: 168 findings on 8ddcb75,
    168 on this head, 0 new.
  • zig fmt --check build.zig zig and git diff --check: pass.
  • Tests: zig test -lc --dep sys -Mroot=zig/src/core/lanes/lanes.zig -Msys=zig/src/platform/sys.zig
    gives 448 passed, 1 skipped, 0 failed on this head, and the project step that roots at that
    module, zig build test-shared-lane-regressions-host, exits 0. zig build test on Linux does
    not root at the lanes module, so that step is the one that reaches these tests. The new margin test fails on main at
    depth_noise_test.zig:27 (a noisy round does not take a stream off the depth it holds),
    which is the reported bug.
  • Host suite, zig build test test-golden on 4d3734e (8c3e7b8; every later rebase changed no
    zig/src/core/lanes file): 754/757 build steps, 10680/10763 tests passed, 55/55 goldens equal,
    1 failed: cli_config_test.test.serve --config: expand reads the file, passes other commands through and names what it cannot read. This box's umask is 0002, so the test's temp
    serve.toml is 0664 and the reader refuses a group-writable config; upstream main's own
    zig build test-cuda-host fails the same test here (1617 pass, 8 skip, 1 fail). Inherited,
    not reachable from this change. The missing libtfgrammar.so skips the grammar checks.
  • CI: all nine checks passed on this head e0e8918 (fmt 16s, pytest 9m27s,
    benchmark-clients 2m58s/4m5s, release-paths 3m29s, zig 47m42s, zig-b 41m1s,
    zig-windows 36m18s, zig-macos-dev-tools 13m1s).
  • Not run: Metal device checks, HIP, XPU, Windows.

Receipt

Machine: one NVIDIA GB10 (sm_121, unified memory), driver 580.178.04, CUDA compiler 13.0.88,
Zig 0.17.0, --context 16384 --prompt-cache-gib 0 --no-thinking, greedy unless named,
nvidia/Qwen3.6-35B-A3B-NVFP4@491c2f1e target and drafter, tools/bench_concurrent.py --levels 1 --tokens 256 --reps 32 (16 for the pages cells), --prompts tools/bench_prompts.json,
A-B-B-A with a fresh server each arm. "Low mode" = drafted rows per round below 1.5; a stuck
reply measures 1.05-1.22, the others 1.6-5.1. The binaries were built from 4d3734e
(main 8c3e7b8); every rebase since changed no file under zig/src/core/lanes.

cell main this head tokens
35B pages off, c=1, 32 replies 7 low mode; those replies 122-129 rounds, 99.8-103.4 tok/s 0 low mode; the same replies 84-92 rounds, 114.9-128.0 tok/s equal, every arm
35B pages off, c=1, decode median 2.06 s 2.06 s equal
35B pages on, c=1, 16 replies 0 low mode, decode median 4.84 s 0 low mode, decode median 4.90 s equal, every arm
35B c=4, 8 rounds 28.8 tok/s per stream median 29.8 tok/s per stream median equal as a multiset (completion order differs)
35B sampled c=1 (temperature 0.8), 8 replies 5.28 s decode median 2.17 s decode median equal, ordered
27B DFlash2 c=1, 16 replies 0 low mode (drafts 14-15 a round), decode median 5.81 s 0 low mode, decode median 5.72 s equal, every arm

The seven replies main held at one draft run 15% to 28% faster on this head with identical
tokens (tools/bench_concurrent.py per-reply decode); the other 25 keep their rounds and rates.
The same A-B-B-A repeated in a slower window (50 tok/s, a shared machine) also gave 7 vs 0 low-mode
replies. This box's decode rate drifts about 2x between runs (another user's cluster rank shares
it), so only the adjacent arms are compared: main's own arms span 51.8-52.7 tok/s on the pages
cell, 48.2-107.3 on the sampled one and 43.7-50.6 on the 27B. The 27B never reaches one draft
(its DFlash2 drafter prices 14-15 rows a round), so that cell checks that the change leaves it
alone rather than a fix.

  • Exactness, with this head's lanes code (binary built from 6b68702; every commit since
    changes no file under zig/src/core/lanes): tools/bench_concurrent.py --levels 1,4 --tokens 256 --reps 3 --temperatures 0 --alone --serial: all four cells (code and chat,
    one and four streams) report failed: 0 for both the alone and the "draft": false
    comparisons.
  • The low-mode count needs no diagnostic patch: the server's completion line carries rounds
    and accepted=A/D, so drafted rows per round is public in every arm's log.
  • New tests: zig/src/core/lanes/depth_noise_test.zig feeds the reported noisy costs (18.1 ms
    for one draft against 20.8 for two, acceptance 0.72/0.54) and shows a stream keeps its depth,
    a depth that keeps losing by more than the margin still gives way, a probe asks one draft past
    the held depth, and a lone window keeps the probed rows. Three lone_copy_price_test pins move
    by 1-2 drafted rows because the rule now holds a depth; their replies, rounds and copy
    behaviour are unchanged and the comments name CUDA lanes: at one stream the depth rule can drop to 1 draft on timing noise and stay there (~92 vs 99.5 tok/s on Qwen3.6-35B-A3B) #3468.
  • Boxes it reaches: CUDA lone lane rounds with timed lone window prices (TF_QWEN_KV_PAGES
    on and off). Metal and CUDA shared rounds use budgets and are unchanged.
  • New switch: none; Constants.depth_margin = 1.05.
  • Prompt speed: n/a; the change picks draft depths only.

Checklist

  • The title and description match the head commit, including the receipt and the stack.
  • New tests fail before the change, pass after it, and skip cleanly without their dependency.
  • Comments and docstrings are one line. No measurements or history in the source.
  • No personal data, machine names, internal hosts or local paths in the diff or its commits.
  • Every token still goes through the lane rounds.
  • Drafted output equals "draft": false, a resumed prompt equals a fresh one, and concurrent equals solo.
  • No precision traded for speed.
  • Decode and prompt processing are no slower than main at one stream and the widest admitted.

@javierbits
javierbits force-pushed the issue-3468-depth-margin branch 4 times, most recently from f33e33d to d37d642 Compare November 19, 2026 18:16
@javierbits
javierbits force-pushed the issue-3468-depth-margin branch from d37d642 to e0e8918 Compare November 19, 2026 19:00
@ashhart

ashhart commented Nov 19, 2026

Copy link
Copy Markdown
Owner

Thanks @javierbits. Every item is in: the margin holds a priced depth against one noisy round while a clearly better depth still wins, the probe rows are marked and kept so a dropped stream can recover, the new test fails on main with the reported bug, and your GB10 receipt shows the stuck replies gone across 32 paired runs. Replies stand unchanged since the target still verifies every row.

CI is green on the head and the code applies cleanly to today's main (only the changelog hunk needs the usual take-both at merge time). This is ready from our side.

  • Synthena

ashhart and others added 3 commits November 20, 2026 08:47
…probe (ashhart#3468)

- Rule.depth keeps the depth it priced until another beats it by depth_margin, like plain_margin, so one noisy round no longer drops a one-stream reply to one draft for the rest of it; a depth that keeps losing still gives way.
- A depth probe's rows are kept by a lone window instead of trimmed back to the priced width, so the deeper depth's acceptance and round time are observed and a dropped stream can recover.
- Host tests feed the reported 18.1/20.8 ms costs and the probe's rows; three lone-copy pins move by 1-2 drafted rows, their replies unchanged.

Fixes ashhart#3468
@ashhart
ashhart force-pushed the issue-3468-depth-margin branch from e0e8918 to bc59e14 Compare November 20, 2026 08:48
@ashhart
ashhart merged commit 30c7f3b into ashhart:main Nov 20, 2026
2 of 11 checks passed
@ashhart

ashhart commented Nov 20, 2026

Copy link
Copy Markdown
Owner

Thank you @javierbits. 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.

@javierbits
javierbits deleted the issue-3468-depth-margin branch November 20, 2026 09:29
@ashhart

ashhart commented Nov 20, 2026

Copy link
Copy Markdown
Owner

Thanks for this one. The 1.3.2 release read found a trade-off on an M3 Ultra with Qwen3.8-27B and DFlash2 drafts: the depth hold makes one stream faster (2K-token prompt decode 85.3 -> 88.3 tok/s, and 74.6 -> 76.8 at a 10K start) but four streams slower. With and without this change, same tokens, two runs each:

4 streams without with
code, sampled 158.8 155.1
chat, sampled 124.9 122.6
chat, greedy 132.2 128.5

With it, the sampled chat sweep is 3.2% under 1.3.1, so 1.3.2 ships without this change; main keeps it. Against 1.3.1, main's four-stream rounds draft more and accept fewer over the same tokens (drafted 6423 vs about 6315, accepted 2502 vs about 2537), which looks like the held depth staying wide when shared rounds are noisy. Would holding the depth only while a stream runs alone keep your one-stream gain? We can run the same comparison on a new head.

  • Synthena

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.

CUDA lanes: at one stream the depth rule can drop to 1 draft on timing noise and stay there (~92 vs 99.5 tok/s on Qwen3.6-35B-A3B)

2 participants