Skip to content

perf(lanes): a stream count whose rounds run over twice the table gets its plain price in its first rounds - #4993

Draft
AbrahamCete wants to merge 2 commits into
ashhart:mainfrom
AbrahamCete:perf/lanes-early-shared-price
Draft

AbrahamCete wants to merge 2 commits into
ashhart:mainfrom
AbrahamCete:perf/lanes-early-shared-price

Conversation

@AbrahamCete

Copy link
Copy Markdown
Contributor

What this changes

A stream count's plain price came from trials on its rounds 64 and 128, and until then shared rounds drafted by the load-time table. At long context a drafted row also walks its stream's cache, which the table does not hold, so those rounds ran at 0.63 to 0.87 of "draft": false. Now a count with no plain price whose round takes at least twice its load-time forward takes its warm-up and kept trial in its next two rounds. Counts that stay under twice the table keep rounds 64 and 128, and a drafted point no drafted round refreshed for stale rounds stops pricing rows.

Two existing tests changed their expected values, because their fakes run drafted rows over twice the table, which is the case this changes:

  • shared_price_test "cheaper plain wins": at 9 ms a row against a 10 ms table, the trials now follow the first drafted round (rounds 3 and 4) instead of 64 and 128. Its 0.5 ms case keeps 64 and 128.
  • lone_copy_price_test "shared rounds' copies stay as on main": at 40 ms a row against a ~5.4 ms table, the two-stream count is priced in its first rounds, and its copy rows drop from 1,644 to 372, for both head settings.

Checks on this head

  • Head commit: 0c6a236. The receipts below were measured on 73b0d2cc2 over base 42bbc8e. The head's change differs from it only in comment lines, and main's commits since 42bbc8e change none of shared_price.zig, depth.zig, shared_round.zig, windows.zig, allocate.zig or hip_lanes.zig.
  • Lean checker on the base (3795e60) and on this head: 165 and 165, 0 new. python3 tools/pr_check.py --base 3795e6054: 0 errors, 1 advisory warning ("pass --pr NUMBER to check its Unreleased line"; the changelog line is yours).
  • Tests run:
    • lanes module (zig test on zig/src/core/lanes/lanes.zig): 519 passed, 1 skipped, 0 failed. The three new tests failed first against an empty observeTable (no price at round 3), then passed.
    • zig build test-lane-api-host test-lane-lone-host test-lane-invariance-host test-glm-window-prices-host test-qwen27-shared-allocation-host test-qwen35-shared-host test-qwen35-rules-host test-qwen35-rounds-host test-cuda-host: each passed.
    • zig build test test-golden: 4,377 of 4,428 passed, 50 skipped, 1 failed: fabric/tp/stage_hip_test "every staged call on HIP memory equals the reference, whole and in parts", which fails the same way on main 3795e60 on this machine (zig build test-tp), so it is inherited.
    • zig fmt --check build.zig zig and git diff --check: clean.
  • CI: not run yet on this head; opened as a draft.
  • Not run, and why: Metal and CUDA hardware; I have neither. The change is in the shared lane core, so it reaches them; their host suites above pass.

Receipt

  • Main against branch: three cells on gfx1151, base 42bbc8e, head 73b0d2cc2, a fresh server per run, runs alternated base, head, head, base under a protocol fixed before the first run.
    • Your HIP: sampled chat at 4 streams on Qwen3.6-35B-A3B is 6% faster with --mtp-drafts 0, because the depth rule underprices sampled drafted rounds #2605 cell (Qwen3.6-35B-A3B, default drafts against --mtp-drafts 0, 1 and 4 streams, greedy and sampled, chat and code, 256 tokens): 34 runs, all 24 metrics within noise. The sampled code cell at four streams with drafts: steady 187.12 against 186.38 tok/s (0.996, noise floor 1.10%). At this size the four-stream trials stay at rounds 64 and 128 on both builds.

    • lanes: at long context a stream count's first 128 shared rounds draft by load-time prices; on gfx1151 four streams run at 0.54-0.86x of "draft": false until the plain price lands (the early-price follow-up of #2687) #3939's long-context cells (Qwen3.6-35B-A3B, four streams, greedy, two mirrored rounds a size). First drafted batch, steady tok/s, base runs against head runs:

      context base head head/base
      2,048 159.5, 157.1, 150.5, 158.4 156.5, 158.0, 158.2, 146.9 0.990, within noise
      8,192 115.7, 116.7, 112.6, 114.4 110.6, 112.9, 112.9, 115.5 0.984, within noise
      32,768 83.7, 89.1, 83.6, 86.5 105.5, 105.6, 107.1, 107.0 1.240
      65,536 52.1, 49.2, 52.1, 49.7 73.7, 73.2, 75.6, 75.3 1.466
      131,072 28.0, 28.1, 28.6, 28.6 45.4, 45.9, 45.5, 45.4 1.608

      From 32,768 up the head's four-stream trials are rounds 2 and 3 and it is priced from round 4; the base's are on round 64, priced from 61 to 75. "draft": false batches are level at every size (batch 1 steady 45.41 against 45.49 at 131,072). The second drafted batch is level, since main has its price by then. A drafts-only server gives 1.21 and 1.25 in its first two batches at 32,768, and 1.48, 1.48 and 1.08 in its first three at 65,536, then level.

    • Your lanes: shared rounds price the drafter's fixed work once, not on every verification row #3755 case (Qwen3.8-27B with its DFlash2 drafter, 8 streams, chat and code, greedy and sampled): six of seven metrics within noise. Greedy code read SLOWER in that run (aggregate 0.985, floor 0.57%), so I ran it alone over 33 mirrored rounds (134 runs): aggregate 62.05 against 62.28 and steady 65.21 against 65.46 tok/s (1.004), within noise. Servers of either build land in one of two states (steady about 65 or 67.5 tok/s, the faster with more drafted rows a round): the base in 5 of 67 runs, the head in 11 of 67 (Fisher p = 0.18). Within each state the builds are level (1.0003 normal, 1.0012 fast). The change does not engage in this cell: on every server of both builds the 8-stream count's trials are on rounds 64 and 128 and it is priced from 129.

  • What this does and does not do: it removes a start-up penalty, once per stream count and sampling mode in a server's life, which lasts about a minute of rounds at 131,072. Once priced, drafts at long context are level with "draft": false here, not ahead (first drafted batch against draft false, aggregate: 0.995 at 32,768, 0.96 at 65,536, 0.98 at 131,072, where main gives 0.87, 0.72 and 0.63). Getting ahead is a separate question: a replay of the allocator on these price logs points at copy windows priced at a fixed 0.94 landing chance on HIP Qwen.
  • Boxes it reaches: every family that sets plain_guard, on every backend; I ran gfx1151 only.
  • New switch: none.
  • Environment: TensorFold base 42bbc8e, head 73b0d2cc2; Zig 0.17.0; HIP 7.1.52801; Ryzen AI Max+ 395 (gfx1151), Linux 7.0.0-44, ReleaseFast; checkpoints Qwen3.6-35B-A3B-MLX-4bit-MTP and Qwen3.8-27B-MLX-4bit with the Qwen3.8-27B-DFlash2 drafter, local copies with no recorded hub revision (config.json sha256 a822a9e48b0a, 14b65a0ee065 and 873e3556509b).
  • Paths and platforms: the shared-round trial schedule and row price in zig/src/core/lanes, called from depth.zig's observeSharedPrice for every plain_guard engine; HIP run, CUDA and Metal not run.
  • Exactness: head against base token hashes on every request of every cell: 120 of 120 request keys in the HIP: sampled chat at 4 streams on Qwen3.6-35B-A3B is 6% faster with --mtp-drafts 0, because the depth rule underprices sampled drafted rounds #2605 cell, hip_parity IDENTICAL on 13 of 13 long-context rounds (24 of 24 requests each), 96 of 96 keys in the 27B cell, and 24 of 24 over its 33-round rerun. Same-build repeats give one hash per key, and different prompts give different hashes.
  • Decode speed before and after: the cells above, from tools/bench_concurrent.py (the HIP: sampled chat at 4 streams on Qwen3.6-35B-A3B is 6% faster with --mtp-drafts 0, because the depth rule underprices sampled drafted rounds #2605 and 27B cells) and the issue's long-context script; tools/bench_openai.py was not run, since one stream is the case this cannot reach (the lone stream reads within noise in the HIP: sampled chat at 4 streams on Qwen3.6-35B-A3B is 6% faster with --mtp-drafts 0, because the depth rule underprices sampled drafted rounds #2605 and long-context cells).
  • Prompt speed: n/a, the change only schedules decode rounds' plain trials; the prompt fill reads within noise in the long-context cells, but for one unjudged one-round reading (+0.27% against a 0.26% floor).
  • Licence: n/a.

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. No AI attribution lines.
  • Every token still goes through the lane rounds. No serial path, and nothing that needs drafts off.
  • Drafted output equals "draft": false, a resumed prompt equals a fresh one, and concurrent equals solo. On the device I checked default drafts against --mtp-drafts 0 (equal on all 60 keys of the HIP: sampled chat at 4 streams on Qwen3.6-35B-A3B is 6% faster with --mtp-drafts 0, because the depth rule underprices sampled drafted rounds #2605 cell) and head against base everywhere; resumed against fresh and concurrent against solo only through the host suites above.
  • No precision traded for speed. No bits change.
  • Decode and prompt processing are no slower than main at one stream and the widest admitted; with --drafter, no slower than without it, greedy and sampled. No slower than main at one and four streams (35B-A3B) and with the drafter at eight (27B); drafter against no drafter not measured.

A count's row price is fitted from its drafted point, and outside fixed
blocks that point never expired. Once plain wins, no drafted round comes
to correct the fit, so a high row price stays: at 131K on gfx1151 a
count's row price stuck at 21 ms against the 16.7 ms its rounds measure,
and the count stopped drafting.

`price` now ignores a drafted point that no drafted round refreshed for
`stale` rounds, as `blockPrice` already does, and `observeHead` replaces
such a point instead of blending onto it, for every kind. The `block`
parameter it no longer needs is dropped.

Two tests that required zero drafted rounds after plain wins now allow at
most one re-probe a `stale` window; tokens stay exact against the
plain-only oracle.

Refs ashhart#3939
…trials next

A stream count's plain price comes from all-plain trials: the first on its
round 64, dropped as a warm-up, and the kept one on round 128. Until then
the allocator prices drafted rows by the load-time table. At long context a
row also walks its stream's cache, which the table does not hold: on
gfx1151 with Qwen3.6-35B-A3B at 32K to 131K, rounds of 4 to 32 rows take
1.9 to 6.6 times the table's forward, and four streams run at 0.54 to
0.86 of `"draft": false` until the price lands (ashhart#3939).

`observeTable` marks a count that has no plain price when one of its rounds
takes at least `over_table` (2) times its load-time forward, head steps
excluded. A marked count takes its warm-up and its kept trial in its next
two rounds, then waits as before. A count whose rounds stay under twice
the table keeps the trials on rounds 64 and 128. A selected trial that
never completes leaves the count on the `every` spacing.

Two tests used fakes whose drafted rows cost 3 and 24 times the table,
where the trials now come in the first rounds:
- shared_price_test's "cheaper plain wins" case at 9 ms a row now expects
  the warm-up and kept trial on rounds 3 and 4; its 0.5 ms case keeps
  rounds 64 and 128.
- lone_copy_price_test's shared-rounds pin: the two-stream count is priced
  within its first rounds, and its copy rows drop from 1,644 to 372.

drafted_chances_test passes unchanged.

Refs ashhart#3939

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

1 participant