Skip to content

fix(dsv41): align prompt index blocks without a scratch copy - #8

Closed
sayyidfareed wants to merge 1 commit into
bertholomus:deepseek-v41-zigfrom
sayyidfareed:fix/dsv41-even-index-blocks
Closed

sayyidfareed wants to merge 1 commit into
bertholomus:deepseek-v41-zigfrom
sayyidfareed:fix/dsv41-even-index-blocks

Conversation

@sayyidfareed

@sayyidfareed sayyidfareed commented Oct 11, 2026 •

Copy link
Copy Markdown

What this changes

An odd multi-block indexer stride offsets VIS by 8 modulo 16 and can cause MissingTritonVariant on long prompts. Round only multi-block odd strides down to an even number, preserving single-block/even schedules and the memory bound. All rows remain covered.

This is an independently implemented alternative to #4, not a claim that the issue was unreported: #4 preserves block geometry by copying misaligned VIS into scratch space; this changes block geometry by at most one row and needs no scratch allocation/copy. Neither approach should be merged blindly on top of the other. Source-only comment/format cleanup separates this public revision from the deployed equivalent.

Receipt

  • Environment: native base 4e80f05ecba89a4e90d16375ade2eddbdc0a10c4, Zig 0.17.0, Ubuntu 24.04.5 LTS, kernel 7.0.0-1019-nvidia, NVIDIA driver 580.178.04; Linux ARM64 CUDA environment; two NVIDIA GB10 nodes for historical live tests, SM121, Mia EXL3 2.9 bpw revision 64ba41b6c916a587db06eae2e19b7845f7be6e6b, recipe v0.6.1 kit. Container ARM64 image sha256:1ad8c1382c09861dee9c342b59f6e5e3e65fe7fde4a07b5e379bc985b66902dd.
  • Exact standalone source tested: 954fdb93c5869d0b155ccf2448066b4fe1682dc3; command zig build test -j1 --summary all with a shared Zig cache.
  • Host result: Build Summary: 17/19 steps succeeded (1 failed); 135/136 tests passed (1 failed). Cached groups are additional; this count is executed tests, not an invented full-suite total.
  • Alignment helper failed before and passed after. On the combined deployed build, cold token-ID completions of exactly 72,149 / 72,150 / 72,151 tokens returned BRAVO / ALPHA / CHARLIE with zero cached tokens. Times: 30.25 / 29.81 / 30.70 s. No throughput improvement is claimed.
  • Lean checker: pinned baseline 1,420 findings; this branch 1420; zero new findings. Existing oversized family modules are inherited. zig fmt --check passes changed Zig files.
  • The sole host failure is the independently reproduced upstream direct_io buffered-reference bug, submitted separately; this PR does not suppress it.
  • Exactness: full drafted/plain, resumed/fresh, concurrent/solo and tensor seam gates on this standalone commit remain unrun; historical combined-device checks are not claimed as substitutes.
  • Decode/prefill: no fresh prescribed benchmark matrix for this standalone commit; no prompt-speed non-regression claim.
  • Not run: Metal M1–M5 and a clean-machine release installation. test-golden was attempted on the pinned source but that step does not exist, despite CONTRIBUTING.md naming it.
  • Public recipe and evidence and qualification limits. Draft pending remaining device/release gates and maintainer review.

Checklist

  • Every token still goes through lane rounds; no serial bypass (test-only N/A where applicable).
  • Drafted equals plain, resumed equals fresh, concurrent equals solo (test-only N/A).
  • No precision reduction is introduced; any unverified output equivalence is disclosed above.
  • Prompt processing is no slower than the last release (test-only N/A).
  • Tested and untested platforms are named.
  • Red/green regression evidence is available; other missing device gates remain disclosed.
  • Added comments are single lines; measurements/history remain in receipts.
  • Outgoing commits use the public GitHub noreply identity; no private hosts, paths, credentials or tool attribution.

Merge considerations

Two-way source revert. Preserve both ranks at the same source/runtime identity. This PR has not changed the default deployed upstream recipe.

@bertholomus

Copy link
Copy Markdown
Owner

Thank you @sayyidfareed — the zero-copy idea is elegant, and the alignment/coverage unit test is a nice touch.

We took #4 for this (now merged): it was verified on the served lane against the actual failing prompt lengths and co-verified with the 512/513 kit fix, and it leaves the block schedule untouched. Your approach is a fine trade — it just changes the block geometry by a row, and in maintenance mode we're carrying one fix per problem, not two. Leaving this open as the clean alternative; if a maintainer ever wants the no-scratch version for the same view in the tp4 engine, this is the starting point. Thanks for the honest receipt, including the direct-IO failure you reproduced (now fixed in #9).

@ryan3040

Copy link
Copy Markdown

Length sweep with the rb alignment fix — passes to 364K, exactness verified

Context note: I see #4 has since been merged for this. The numbers below are on this PR's form (the round-down / stride form), kept here as corroborating evidence for the same view; happy to re-run against whichever form ships.

Ran the rb round-down fix (this PR's form, implemented independently at prompt.zig:941 before we found this PR) on the recipe's 2× GB10 TP2 lane, engine at 5e10970, kit v0.6.1 whose aot.json sha256 (092b6d27…) byte-matches the kit named in #4's evidence — so these numbers are comparable with that thread's.

Serve configuration, stated for reproducibility: --context 1048576 --parallel 3. The recipe publishes --parallel 4; the pool is the context window shared across slots, so a single-stream run at 4 slots is a different memory regime — anyone reproducing these numbers needs the slot count. Thinking is ON (server --thinking), so the 8-token completions below are reasoning tokens and count against the same budget.

Single stream, greedy, temperature 0, 8-token completions:

prompt tokens result TTFT (s) prefill (tok/s, cold)
511 PASS 0.48 —
512–513 FAIL — MissingTritonVariant (HTTP 500) — —
514 PASS 0.48 —
25,996 PASS 10.50 ~2,480
115,416 PASS 38.35 ~3,020
144,266 PASS 13.72 cached prefix
158,686 PASS 7.43 cached prefix
240,416 PASS 39.78 ~6,060 (partial cache)
302,916 PASS 32.41 ~9,450 (partial cache)
317,336 PASS 9.12 cached prefix
364,456 PASS ~171.8 (measured) ~2,130
  • 364,456 row: TTFT measured by streaming — the first content chunk arrived at 171.8 s with the client timeout set to 900 s, so it is not a client cutoff. The engine's own time_to_first_token field reports 179.999 for the same request; the streamed measurement is the one to trust.
  • Everything above the 512/513 hole passes, including 364,456 tokens — beyond the highest verified pass we found in the thread (159,624) and the unresolved 165,425 report.
  • 512/513 reproduces with the engine fix in place — consistent with the _topk_sel N=KK=256 gap (kit PR fix(dsv41): make RDMA GID index configurable #13), i.e. genuinely absent kernel rather than alignment.
  • Exactness vs unpatched binary: same prompt (15,045 tokens, thinking on, 64 generated) on old vs new binaries → identical token stream (matching token digests be4fe19e5f4b / 6b86b273ff34 on two probe prompts).
  • Determinism: 3 consecutive runs at 290,036 tokens → identical token digest.
  • Note: TTFT at 364K (~172 s measured) is far beyond typical client idle timeouts — same class as issue fix(dsv41): configure RDMA GID and negotiate endpoint MTU #12's long-prefill streaming gap.

Which of the gates listed as unrun in this PR's description our evidence addresses — and which it does not:

  • Addressed — drafted-equals-plain: yes, for the single-stream greedy case. Old vs new binary are token-identical on two probe prompts (digests above).
  • Partially addressed — resumed-equals-fresh: we did not run that gate. What we have is run-to-run determinism (3 identical digests at 290,036 tokens; runs 2–3 prefix-cached), which is a weaker and different property. Stated as such, not as the gate.
  • Not addressed — concurrent-equals-solo: not run. Our sweep is single-stream throughout.

Cross-references: #4 (merged — alternative fix; the kit-identity basis for comparability), recipe issue #15 / #14 (the missing-variant reports).

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