Skip to content

deepseek: bound index scratch before planning and pricing - #1681

Merged
ashhart merged 2 commits into
ashhart:mainfrom
jayleaton:dsv41-up/index-scratch
Nov 1, 2026
Merged

ashhart merged 2 commits into
ashhart:mainfrom
jayleaton:dsv41-up/index-scratch

Conversation

@jayleaton

Copy link
Copy Markdown
Contributor

What this changes

The symbolic prefill planner did not bound the indexer's live scratch before deciding workspace reuse and pricing it. For ragged shapes, and for the materialized two-batch-overlap (TBO) branch, the planned extent could be smaller than what the indexer uses. This bounds live index scratch for regular, K4 and both TBO branches before workspace reuse and pricing. Arithmetic does not change.

This is adapted from JustLateNightAI / Astra's downstream PR (jayleaton/deepseek-v41-tensorfold-spark#78) to the current symbolic planner.

Issue: none open upstream. Stacked on: nothing (based on main 3f0a715c4; the 35 later main commits, to a0d24896f, touch none of its files).

Receipt

  • Environment, with the TensorFold commit, MLX or PyTorch version, machine and GPU, checkpoint and revision: head e07ee9fddba5 on main 3f0a715c4; Zig 0.17.0; host checks on a Linux aarch64 DGX Spark (GB10, CUDA 13.0). Real-pack boot on two GB10s, TP=2 over RoCE, checkpoint jayleaton/DeepSeek-V4.1-Flash-1017-EXL3-2.8bpw revision 859396591c34, TF_EXPERIMENTAL=deepseek.
  • Exactness: n/a; buffer sizing only.
  • Decode speed before and after: n/a.
  • Prompt speed before and after: n/a for speed. The bound reserves more workspace for the indexer: about 128 MiB per rank on the Flash-1017 pack at the served settings, because L.ix.keys no longer shares the prefill workspace there.
  • Host regression (index_scratch_test.zig): it keeps the failing baseline extent receipt, then checks ragged shapes and the materialized TBO counterexample against the new bound.
  • Tests run, with pass, fail and skip counts:
    zig fmt --check build.zig zig                      exit 0
    git diff --check 3f0a715c4..HEAD                    exit 0
    python3 tools/zig/lean_check.py                     base 425 problems, head 425, new 0 (lean_new.py)
    zig build test-cuda-host --summary all              exit 0, 271/271 steps, 3906/3915 tests passed, 9 skipped (with test-server-cpu)
    zig build test-dsv41-shared test-dsv41-state test-dsv41-forward test-dsv41-kv test-dsv41-device-host test-dsv41-draft test-dsv41-cuda-host test-draft-dsv41-host  exit 0, 49/49 steps, 553/555 tests passed, 2 skipped
    control (neg-scratch, fix reverted, tests kept): zig build test-dsv41-forward  exit 1 (fails, as required)
    
  • Real-pack TP=2 boot of main + every PR in this series (and the DeepSeek image path that is not yet proposed), at 83ba53298924: passed. Both ranks reached readiness; the recipe smoke, the canary and a strict tool call passed; MissingTritonVariant 0 in both rank logs; 2048 greedy tokens in 51.1 s with token_sha256 7538b20557b1…, the same as the downstream build of this series.
  • Not run, and why: Metal (CUDA planner).

Checklist

  • 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. (Not measured for this change alone.)
  • No precision traded for speed. If the bits change, the description says which sums change and why.
  • A new or changed GPU kernel is registered with the kernel contract (docs/kernel-contract.md); each backend's SUMMARY line is in the receipt. (No kernel changes.)
  • Prompt processing is no slower than the last release. (Buffer sizing only.)
  • The description says which platforms I ran, Metal M1 to M5 and CUDA, and which I could not.
  • New tests fail before the change, pass after it, and skip cleanly without their dependency. (Control: the planner call sites reverted with the tests kept fails 3 tests in test-dsv41-forward.)
  • Comments and docstrings are one line. No measurements or history in the source.
  • No personal data, machine names, internal hosts or local paths. No AI attribution lines.

jayleaton and others added 2 commits November 1, 2026 02:33
Adapt JustLateNightAI / Astra's PR jayleaton/deepseek-v41-tensorfold-spark#78 to the current symbolic planner. Bound live index scratch for regular, K4 and both TBO branches before workspace reuse and pricing. Preserve the failing baseline extent receipt and test ragged shapes and the materialized TBO counterexample without changing arithmetic.

(cherry picked from commit 2b11053)
@ashhart
ashhart force-pushed the dsv41-up/index-scratch branch from e07ee9f to daa48ba Compare November 1, 2026 02:33
@ashhart
ashhart merged commit 72cc3ea into ashhart:main Nov 1, 2026
9 checks passed
@ashhart

ashhart commented Nov 1, 2026

Copy link
Copy Markdown
Owner

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

@ashhart

ashhart commented Nov 1, 2026

Copy link
Copy Markdown
Owner

Thanks @jayleaton! DeepSeek-V4.1's prefill planner now sizes the indexer's scratch before it plans, in 1.2.1: https://github.com/ashhart/TensorFold/releases/tag/v1.2.1

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