Skip to content

lanes/depth: price full fixed_draft_block head cost in lone roundCost - #4457

Merged
ashhart merged 2 commits into
ashhart:mainfrom
gilby:lanes-fixed-draft-block-cost
Nov 23, 2026
Merged

ashhart merged 2 commits into
ashhart:mainfrom
gilby:lanes-fixed-draft-block-cost

Conversation

@gilby

@gilby gilby commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Fixes adaptive draft-depth pricing for Inkling 2 Mini's fixed-cost DSpark drafter when serving a single stream. Because fixed-block drafters pay the same step cost across small depths, single requests now propose full blocks cleanly.

What this changes

Before: Rule.roundCost multiplied mtp_step_ms * drafts for lone-stream untimed depths even when k.fixed_draft_block was set, under-pricing small drafts and inflating the plain_guard excess floor on larger untimed depths for fixed-block drafters. After: Rule.roundCost uses draftHeadMs, charging mtp_step_ms * most_drafts whenever fixed_draft_block is true and drafts > 0, matching shared-round pricing.

Checks on this head

  • Head commit: ca097f1601
  • python3 tools/pr_check.py --base origin/main --pr 4457: 2 changed files; lean 165 vs 165, 0 new; 0 error(s), 1 warning(s) (depth.zig 561 lines, depth_test.zig 198 lines; warning is advisory Unreleased bullet).
  • Tests run:
    • zig test zig/src/core/lanes/lanes.zig --test-filter fixed_draft_block — All 16 tests passed (0 failed, 0 skipped; fails before the change with roundCost(1) == 23.0 instead of 29.0).
    • zig build test-lane-api-host -Dcpu=apple_m1 — exited 0 (EXIT=0).
    • zig build test-shared-price-learning-host test-environment-host -Dcpu=apple_m1 — exited 0.
    • zig fmt --check build.zig zig and git diff --check origin/main..HEAD — clean.
  • CI: GitHub Actions running on pushed head ca097f1601.
  • Not run, and why: Full GPU serving matrix runs on the lead/inkling2-mini Metal V3 stack (this PR modifies only the pure-Zig lone-stream cost helper when fixed_draft_block == true; fixed_draft_block == false is bit-identical).

Receipt

  • Main against branch: When fixed_draft_block == false (variable-step MTP drafters), draftHeadMs computes the identical mtp_step_ms * drafts expression. When fixed_draft_block == true (DSpark on Inkling 2 Mini on CUDA and Metal #4387), lone-stream depth costing accurately prices small fixed-block drafts instead of mis-pricing drafts = 1.
  • Boxes it reaches: lanes/depth.zig (Rule.roundCost, lone-stream adaptive depth selection).
  • New switch? No.
  • Environment: TensorFold origin/main 52b1362766 → ca097f1601, Zig 0.17.0, macOS 27.x (Apple Silicon).
  • Paths and platforms the change reaches: Host-portable Zig core (lanes), verified via zig test and host test builds on macOS aarch64; no GPU kernels touched.
  • Exactness: Does not alter logits, verification, or acceptance rules (only depth selection cost modeling); token-for-token identical to "draft": false.
  • Decode speed before and after: No regression on default fixed_draft_block == false path; fixes lone-stream depth under-proposal on fixed-block drafters.
  • Prompt speed before and after: n/a — Rule.roundCost is only consulted during decode draft depth selection and cannot reach prompt processing.
  • Licence of any new weights or drafter: 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.
  • No precision traded for speed.
  • 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.

@AIFlowML

Copy link
Copy Markdown
Contributor

I reproduced the pricing regression with Zig 0.17.0 on M5 Max. With only the new test fixture applied to main 2ce240cf0, zig test zig/src/core/lanes/lanes.zig --test-filter fixed_draft_block failed on the lone-round cost: 23 instead of 29 (14 passed, one failed). The clean trial merge of 746c7b2595 passed all 15 tests.

zig build test-lane-api-host test-shared-price-learning-host -Dcpu=apple_m1 -j4 --summary all also passed all eight steps and 756 tests. The reported #3052 overlap trial-merges cleanly at its current head a2ed92677. That was a merge check only. I did not run the XPU or Inkling device benchmarks.

Igor Lessio - AIFLOW LABS

@AIFlowML

Copy link
Copy Markdown
Contributor

I trial-merged 746c7b25 into the new lane conformance branch #4472 at c2bf40a7 (main 25586070b). It merged cleanly. On M5 Max with Zig 0.17.0, the combined tree passed 1,179 tests with one skip, including the new fresh/resumed cache, draft rollback, deterministic replay, and stop-reason checks.

zig build test-shared-lane-regressions-host test-lane-api-host -Dcpu=apple_m1 -j3 --summary all

This covers the combined branches' lane behavior with host fixtures. It leaves the device throughput comparison to the Inkling stack.

Igor Lessio - AIFLOW LABS

@AIFlowML

Copy link
Copy Markdown
Contributor

I checked the red No GPU run against the current base. The three Zig jobs all stop at the Flash Next environment count (expected 24 switches, found 25). Pytest stops at collection because the workflow cannot import yaml. This PR changes only the lane depth code and its test.

I trial-merged exact head 746c7b2595a9b1aa88499ba5dd8aab2c46c326ff into 311749c0 on M5 Max with Zig 0.17.0. The merge was clean, and these checks passed:

  • zig build test-environment-host -Dcpu=apple_m1 -Doptimize=safe -j2 --summary all — 32 passed.
  • zig test zig/src/core/lanes/lanes.zig --test-filter fixed_draft_block — 15 passed.
  • uv run --no-project --with pytest --with PyYAML -- pytest -q tools/test_ci_workflow_conditions.py — one test and four subtests passed. The current workflow already installs PyYAML.

A hosted run on the refreshed base would verify the rest of the matrix. Previous No GPU run

Igor Lessio - AIFLOW LABS

@ashhart
ashhart force-pushed the lanes-fixed-draft-block-cost branch from ca097f1 to 32c722f Compare November 23, 2026 17:47
@ashhart
ashhart merged commit 281d81b into ashhart:main Nov 23, 2026
12 of 23 checks passed
@ashhart

ashhart commented Nov 23, 2026

Copy link
Copy Markdown
Owner

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

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.

3 participants