mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #4126] [Engine] Metal: sampling on the decode path (temperature, top-k, top-p, min-p, penalties, Philox seed) #4911
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#4911
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/4126
Author: @mnott
Created: 10/25/2026
Status: 🔄 Open
Base:
main← Head:pr/metal-sampling📝 Commits (2)
ce59fa7feat(metal): sampling on the decode path (CPU sampler over the head's logits: temperature, top-k, top-p, min-p, penalties, Philox seed; a sampled verify window keeps a draft when the sample equals it)b5660dffix(serve): sampled requests carry a Philox seed (request's, else fresh random) so temperature takes effect📊 Changes
5 files changed (+203 additions, -3 deletions)
View changed files
➕
metal/src/engine/sampler_host.cpp(+163 -0)📝
metal/src/engine/stubs.cpp(+0 -1)📝
serve/server.py(+6 -1)📝
serve/test_server.py(+9 -0)📝
src/core/verify.cpp(+25 -1)📄 Description
Problem and result
The Metal decode path only ever took the argmax (
metal/src/engine/window.cppdecoded greedily;sample_tokenswas a stub), sotemperature,top_k,top_p,min_p, the penalties andseedhad no effect on macOS. In agent use the model then repeated itself word for word across turns. With this change Metal samples the way the CUDA engine does: a seed gives a reproducible text, different seeds give different texts, and greedy requests are unchanged.Related discussion
Overview of our related macOS / Metal contributions: #4128. Focused fix of a Metal gap (the CUDA engine already samples).
Approach
serve: a sampled request carries a Philox seed (the request's, else a fresh random one), sotemperaturetakes effect through the API.Validation
Branch head
b5660dfcc92d5964b2527017f37c108e5da2fba1, two commits onv0.2.6. Apple Silicon, 128 GB unified memory, Gyro-M TQ2_0,--spec 2with the MTP draft, same flags for both builds, no environment overrides.Passed:
strataon macOS.v0.2.6.--temperature 1.5 --top-k 50): seed 1 and seed 2 differ; seed 1 twice is identical.Failed:
Not run:
Limits
The sampler runs on the CPU over the head's logits; a GPU sampler could save the logits copy per token.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.