refactor(sampling): migrate sampling family into kernels/sampling/ - #17
Merged
Conversation
ekryski
force-pushed
the
ek/kernel-reorg-sampling
branch
2 times, most recently
from
June 12, 2026 23:21
8bcb1e9 to
dc6e2f0
Compare
Contributor
|
Good consolidation: the five |
Contributor
|
@ekryski clean. Nice catch repointing the dangling |
Moves the logits->token pipeline out of the legacy mlx/ + ffai/ split into
kernels/sampling/ and adds the mt_ prefix to the unprefixed ffai kernels:
- mlx/{softmax,sort} -> kernels/sampling/
- ffai/sampling.rs -> kernels/sampling/categorical_sample.rs
(softmax_categorical_sample -> mt_softmax_categorical_sample; renamed the
file off the family name to avoid module inception)
- ffai/logits_{topk,top_p,min_p,processors} -> kernels/sampling/, with mt_
prefixes (mt_logits_topk_mask, mt_logits_top_p_mask, mt_logits_min_p_mask,
mt_logits_temperature, mt_logits_repetition_penalty)
Generated MSL per kernel is unchanged; only paths + inventory names change.
Updated the softmax_categorical_sample integration-test imports, cross-ref
doc comments (dsv4_indexer_topk, spirv codegen), the plan (sampling done),
and KERNEL_AUDIT rows.
cargo build + clippy clean; all sampling kernel tests + the categorical-sample
integration matrix pass.
TheTom
force-pushed
the
ek/kernel-reorg-sampling
branch
from
June 22, 2026 21:23
dc6e2f0 to
34d6904
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Wave-1 kernel-family port: moves the sampling family (the logits→token
pipeline) out of the legacy
mlx/+ffai/split intokernels/sampling/perdocs/specs/KERNEL_CONSOLIDATION_PLAN.md, and adds themt_prefix to thepreviously-unprefixed
ffai/kernels.Changes
mlx/{softmax,sort}→kernels/sampling/(mt_softmax,mt_sort/mt_merge/mt_sort_segmented).ffai/sampling.rs→kernels/sampling/categorical_sample.rs;softmax_categorical_sample→
mt_softmax_categorical_sample(file renamed off the family name to avoidmodule_inception).ffai/logits_{topk,top_p,min_p,processors}→kernels/sampling/withmt_prefixes (
mt_logits_topk_mask,mt_logits_top_p_mask,mt_logits_min_p_mask,mt_logits_temperature,mt_logits_repetition_penalty).dsv4_*_topk(moe/sdpa expert/indexer routing) andupsample_nearest1d(audio) — they go with their own families.(
dsv4_indexer_topk, the SPIR-V codegen note), the plan (sampling marked done),and the
KERNEL_AUDITrows.Generated MSL per kernel is unchanged — only module paths and inventory names.
Verification
cargo build -p metaltile-std+cargo clippy -p metaltile-std --testsclean.tile test(softmax, sort, the four logitsmasks/processors, categorical sampler).
softmax_categorical_sample_matrixintegration test passes.Note on stacking
Stacked on the norm PR (#16) → conv+rope (#15) → docs (#14); the diff includes
those until they merge. Each family lands as its own PR and consolidates cleanly.