libr3d: accept a null params in sample_logprobs, per the canonical schema

The canonical sample_logprobs schema declares params optional (an absent
optional operand arrives as null data, rad_abi.h), and libr4d's kernel
already honours that (no params = every row). libr3d's launcher refused a
null params and its kernel dereferenced it unconditionally, so since the
canonical schema went optional (3b278dc) the engine refuses the whole
libr3d plugin at load: op 'sample_logprobs' has two different schemas.

Mirror libr4d: the kernel's flag test gains a null guard (no params:
every row runs), the launcher no longer refuses null, and the row's spec
marks the operand optional.
This commit is contained in:
Asim Siddiqui committed 2026-11-05 21:18:00 +11:00
1 parent 7f5218ee5f
commit 4bd9c39728
2 files changed
+4 -4

No files matched your search

+2 -2
View File
@@ -525,7 +525,7 @@ static const RadOperandSpec oArgmax[] = { { "logits", RAD_OPD_IN, 0 },
{ "params", RAD_OPD_IN, 0 },
{ "token", RAD_OPD_OUT, 0 } };
static const RadOperandSpec oLogprobs[] = { { "logits", RAD_OPD_IN, 0 },
{ "params", RAD_OPD_IN, 0 },
{ "params", RAD_OPD_IN, 1 },
{ "stats", RAD_OPD_OUT, 0 } };
static const RadOperandSpec oNarrow[] = { { "cand_idx", RAD_OPD_INOUT, 0 },
{ "cand_val", RAD_OPD_INOUT, 0 },
@@ -2572,7 +2572,7 @@ static const RadKernelInfo kKernels[] = {
"one read of the logits plane where the reference reads it three (max, sum, k-list); the sum is "
"SUM exp(v - max) in DOUBLE, the reference's law, and a row's k-list is one insertion list in "
"registers, not an upper_bound per element; stats is [M][2 + 2k], and rows the flag leaves alone "
"are not written",
"are not written (no params at all: every row runs)",
"f32 logits, f32 params, f32 stats; k <= 64 is the pool's depth and above it the shim refuses "
"(RAD_E_UNSUPPORTED); on a row that contains a NaN the reference's list freezes at the first k it "
"saw: once a NaN sits in the k-list's tail, every later real value fails the tail's compare "
+2 -2
View File
@@ -189,7 +189,7 @@ __global__ __launch_bounds__(THR) void sample_logprobs_kernel(
float* __restrict__ st, uint32_t n, uint32_t k, uint32_t lg_ld, uint32_t st_ld,
int32_t voff) {
const uint32_t row = blockIdx.x;
if (!(pr[row].flags & RAD_SP_LOGPROBS)) return;
if (pr && !(pr[row].flags & RAD_SP_LOGPROBS)) return; /* no params: every row */
Acc a;
a.mx = -INFINITY;
@@ -570,7 +570,7 @@ static inline int logits_rows(const RadArgs* a, const RadTensor* lg, long long*
extern "C" int r3d_sample_logprobs(long lg, long params, long stats, int M, int n_vocab, int k,
long long lg_ld, long long stats_ld, int vocab_off,
long stream) {
if (!lg || !params || !stats) return -1;
if (!lg || !stats) return -1;
if (M <= 0 || n_vocab <= 0 || k <= 0) return -2;
if (k > kKMax) return -2;
if (!lg_ld) lg_ld = n_vocab;