Skip to content

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

Open
ashhart wants to merge 1 commit into
mainfrom
lead/dsv41-metal-choose
Open

ashhart wants to merge 1 commit 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)

…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.

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

Development

Successfully merging this pull request may close these issues.

1 participant