Skip to content

dsv41 metal: vector greedy picks and kept sampling scratch, same picks - #3288

Merged
ashhart merged 6 commits into
mainfrom
lead/dsv41-metal-choose
Nov 21, 2026
Merged

ashhart merged 6 commits into
mainfrom
lead/dsv41-metal-choose

Conversation

@ashhart

@ashhart ashhart commented Nov 14, 2026

Copy link
Copy Markdown
Owner

On Metal, DeepSeek-V4.1 picks a row's token on the host (metal/target.zig, choose). A greedy pick scanned all 129,280 logits one at a time. A sampled pick allocated a float64 copy of the logits and an id list, about 2 MB, on every row before calling the lane core's sampling.choose. A drafted round picks one row per window row, so this adds up.

  • Greedy: finds the first maximum in 16-wide vector steps, then the first index holding it. A row containing a NaN takes the old scalar scan, so ties and NaNs give exactly the id they gave before. A test compares both over 200 random rows of the release's vocabulary with ties, NaNs and all -inf rows planted.
  • Sampled: reuses a float64 buffer and a constant id list kept in the target, then calls the same sampling.choose on the same values, so the draw is unchanged.

On an M5 Ultra (512 GB), release weights, with #2973, #2983 and the FP8 rows change underneath, on the five prose prompts of tools/bench_prompts.json at 512 tokens, one run each:

Before After
Greedy, mean tok/s 63.0 64.7
Sampled (T 1.0, seed 1234), mean tok/s 53.7 55.7

Every reply's text equals main's (10 of 10). zig build test-dsv41-metal -Dcpu=apple_m1 passes on an M5 Max, and lean reports no new problems.

  • Synthena (Ash's Agent)

@ashhart

ashhart commented Nov 14, 2026

Copy link
Copy Markdown
Owner Author

Rebased onto main 2ba55ec as part of the decode stack. It now sits on @gilby's #2973 and #2983 (#3292 needs #2983's expert rows) and lands after them in order: #2973, #2983, #3287, #3288, #3292, #3296, #3376. Measured on an M5 Ultra on the release checkpoint, the whole decode stack (#2973, #2983, #3287, #3288, #3292, #3296, #3376) against main 2ba55ec: 48 of 48 replies equal (greedy, sampled and "draft": false; 16 prompts, 512 tokens). Greedy 73.1 -> 91.8 tok/s, sampled 60.1 -> 74.8, "draft": false 46.4 -> 51.3. test-dsv41-metal passes and the lean check finds nothing new.

  • Synthena (Ash's Agent)

gilby and others added 6 commits November 21, 2026 09:51
…pt between picks

The greedy argmax takes the first maximum in vector steps and keeps the scalar scan for a row holding a NaN, so it
picks the same id; a sampled pick reuses its float64 logits and its ids instead of allocating both every row.
@ashhart
ashhart force-pushed the lead/dsv41-metal-choose branch from 9d31a0f to 80eb8b9 Compare November 21, 2026 09:51
@ashhart
ashhart merged commit 6f34f97 into main Nov 21, 2026
2 of 11 checks passed
@ashhart
ashhart deleted the lead/dsv41-metal-choose branch November 21, 2026 09:51
@ashhart

ashhart commented Nov 21, 2026

Copy link
Copy Markdown
Owner Author

Thank you @gilby. This is merged into main with your commits under your own name, so you're credited as a TensorFold contributor.

ashhart added a commit that referenced this pull request Nov 21, 2026
ashhart added a commit that referenced this pull request Nov 21, 2026
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