Add challenge 104: Min-P Sampling (Medium)#277
Open
claude[bot] wants to merge 1 commit into
Open
Conversation
Batched min-p sampling, a logit-filtering primitive used in modern LLM serving stacks (vLLM, TGI, llama.cpp). Per row, the kernel computes softmax probabilities, masks tokens below min_p * max_prob, and renormalizes. Unlike top-k or top-p, no sort is required — the cutoff adapts to how peaked each row is, which makes it a clean exercise in batched per-row reductions.
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.
Summary
[B, V], the kernel computes softmax probabilities, masks tokens whose probability is belowmin_p * max_probin that row, and renormalizes the survivors.What's included
challenge.pywithreference_impl,get_solve_signature, and example/functional/performance test generators (10 functional tests covering edge cases, min_p=0/0.99/in-between, tied maxima, peaked vs uniform distributions, power-of-2 and non-power-of-2 vocabs, realistic 16×32000).challenge.htmlwith description, requirements, worked 2×4 example matchinggenerate_example_test(), and constraints including the performance test sizing bullet.Performance test
B = 64,V = 128,000,min_p = 0.05(~62.5 MB per buffer × 2 buffers; well under the 5× / 16 GB T4 budget).Test plan
pre-commit run --all-filespassesscripts/run_challenge.py ... --action submiton T4 — all tests passed🤖 Generated with Claude Code