Archived
libxe2: the thirteen sampler ops
Each is libref's arithmetic on the card. The serial stages (penalties, DRY, the n-gram ban, top-p, min-p, typical, XTC, the pick) run libref's loops unchanged, one work-item a row, so their sums keep libref's order. Temperature and the grammar mask are one work-item an element. argmax, top-k and logprobs scan the vocabulary with one work-group a row, reducing a 64-bit key -- the value's order-preserving bits above the complemented index -- so the largest value wins and ties go to the lower id, libref's rule; top-k is libref's topk_next k times, and a greedy row takes no rounds. DRY's per-token map is replaced by a first-occurrence scan that computes the same maxima. rad-kbench against libref: the whole fixture with libxe2 first, 1101/1101; MiniCPM5-2B's sampler cases 56/56, all at rel_l2 0. With this, every op MiniCPM5-2B bf16 issues with speculation off has a device row in libxe2 (13 model ops, 13 sampler ops). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
This commit is contained in:
1 parent
ed76fc8aaa
commit
d0e797844e
3 files changed
+769
No files matched your search
@@ -96,6 +96,59 @@ const RadKernelInfo kKernels[] = {
|
||||
.shape = "head_dim <= 512, any gqa, causal or not, sliding window, ragged batches",
|
||||
.dtypes = "bf16 query, bf16 or E4M3 cache with per-(seq, head) descales, bf16 out",
|
||||
.domain = RAD_DOMAIN_DEVICE, .launch = xe2::attn_paged },
|
||||
|
||||
{ .name = "xe2_sample_penalties", .op = "sample_penalties", .family = "sample",
|
||||
.computes = "repetition, frequency and presence penalties over the row's history", .shape = "one work-item a row",
|
||||
.dtypes = "f32 logits and candidates, RadSampleParams rows",
|
||||
.domain = RAD_DOMAIN_DEVICE, .launch = xe2::sample_penalties },
|
||||
{ .name = "xe2_sample_dry", .op = "sample_dry", .family = "sample",
|
||||
.computes = "DRY penalty over the row's history", .shape = "one work-item a row; quadratic in the window, as libref",
|
||||
.dtypes = "f32 logits and candidates, RadSampleParams rows",
|
||||
.domain = RAD_DOMAIN_DEVICE, .launch = xe2::sample_dry },
|
||||
{ .name = "xe2_sample_ngram_ban", .op = "sample_ngram_ban", .family = "sample",
|
||||
.computes = "windowed no-repeat-ngram ban, optional whitelist", .shape = "one work-item a row",
|
||||
.dtypes = "f32 logits and candidates, RadSampleParams rows",
|
||||
.domain = RAD_DOMAIN_DEVICE, .launch = xe2::sample_ngram_ban },
|
||||
{ .name = "xe2_sample_temp", .op = "sample_temp", .family = "sample",
|
||||
.computes = "logits divided by the row's temperature", .shape = "one work-item an element",
|
||||
.dtypes = "f32 logits and candidates, RadSampleParams rows",
|
||||
.domain = RAD_DOMAIN_DEVICE, .launch = xe2::sample_temp },
|
||||
{ .name = "xe2_sample_mask", .op = "sample_mask", .family = "sample",
|
||||
.computes = "grammar bitmask: a cleared bit sets -inf", .shape = "one work-item an element",
|
||||
.dtypes = "f32 logits and candidates, RadSampleParams rows",
|
||||
.domain = RAD_DOMAIN_DEVICE, .launch = xe2::sample_mask },
|
||||
{ .name = "xe2_sample_topk", .op = "sample_topk", .family = "sample",
|
||||
.computes = "the row's top_k candidates, descending, ties to the lower id", .shape = "one work-group a row, k reduction rounds",
|
||||
.dtypes = "f32 logits and candidates, RadSampleParams rows",
|
||||
.domain = RAD_DOMAIN_DEVICE, .launch = xe2::sample_topk },
|
||||
{ .name = "xe2_sample_topp", .op = "sample_topp", .family = "sample",
|
||||
.computes = "top-p over the candidate set", .shape = "one work-item a row",
|
||||
.dtypes = "f32 logits and candidates, RadSampleParams rows",
|
||||
.domain = RAD_DOMAIN_DEVICE, .launch = xe2::sample_topp },
|
||||
{ .name = "xe2_sample_minp", .op = "sample_minp", .family = "sample",
|
||||
.computes = "min-p over the candidate set", .shape = "one work-item a row",
|
||||
.dtypes = "f32 logits and candidates, RadSampleParams rows",
|
||||
.domain = RAD_DOMAIN_DEVICE, .launch = xe2::sample_minp },
|
||||
{ .name = "xe2_sample_typical", .op = "sample_typical", .family = "sample",
|
||||
.computes = "locally typical sampling over the candidate set", .shape = "one work-item a row",
|
||||
.dtypes = "f32 logits and candidates, RadSampleParams rows",
|
||||
.domain = RAD_DOMAIN_DEVICE, .launch = xe2::sample_typical },
|
||||
{ .name = "xe2_sample_xtc", .op = "sample_xtc", .family = "sample",
|
||||
.computes = "exclude top choices, seeded coin", .shape = "one work-item a row",
|
||||
.dtypes = "f32 logits and candidates, RadSampleParams rows",
|
||||
.domain = RAD_DOMAIN_DEVICE, .launch = xe2::sample_xtc },
|
||||
{ .name = "xe2_sample_pick", .op = "sample_pick", .family = "sample",
|
||||
.computes = "inverse-CDF draw over the candidates, seeded per row", .shape = "one work-item a row",
|
||||
.dtypes = "f32 logits and candidates, RadSampleParams rows",
|
||||
.domain = RAD_DOMAIN_DEVICE, .launch = xe2::sample_pick },
|
||||
{ .name = "xe2_sample_argmax", .op = "sample_argmax", .family = "sample",
|
||||
.computes = "greedy token, ties to the lower id", .shape = "one work-group a row",
|
||||
.dtypes = "f32 logits and candidates, RadSampleParams rows",
|
||||
.domain = RAD_DOMAIN_DEVICE, .launch = xe2::sample_argmax },
|
||||
{ .name = "xe2_sample_logprobs", .op = "sample_logprobs", .family = "sample",
|
||||
.computes = "max, double normaliser and the top k (id, logit) pairs", .shape = "one work-group a row",
|
||||
.dtypes = "f32 logits and candidates, RadSampleParams rows",
|
||||
.domain = RAD_DOMAIN_DEVICE, .launch = xe2::sample_logprobs },
|
||||
};
|
||||
|
||||
const RadPluginInfo kInfo = {
|
||||
|
||||
Reference in new issue
Block a user