libref, libavx, libr4d: cfg_topk_sample's top_p and ras_pick -- Fish Audio's nucleus over the whole candidate set, cut before the top-k, and its repetition-aware choice between two draws

This commit is contained in:
zivius committed 2026-10-20 23:07:16 +02:00
1 parent 8a993b7de9
commit 0c35fc8070
14 files changed
+384 -23

No files matched your search

+12 -1
View File
@@ -900,7 +900,8 @@ static const RadOperandSpec oSnakeAa[] = { OPD("x"), WGT("alpha"), WGT("beta"),
static const RadParamSpec pCfgTopk[] = { P_INT("M"), P_INT("n_vocab"), P_INT("k"), P_INT("rep"),
P_INTO("cond_k"), P_F64("cfg"), P_F64O("temp"),
P_INT("stream"), P_STR("dtype"), P_INTO("sup_lo"),
P_INTO("sup_hi"), P_F64O("penalty") };
P_INTO("sup_hi"), P_F64O("penalty"),
P_F64O("top_p") };
static const RadOperandSpec oCfgTopk[] = { OPD("logits"), OPD("seed"), OPD("frame"), OUT("ids"),
OPD_O("cfg"), OPD_O("lane"), INOUT_O("hist") };
static const RadParamSpec pRvqEmbed[] = { P_INT("M"), P_INT("n_embd"), P_INT("n_codes"),
@@ -913,6 +914,10 @@ static const RadOperandSpec oFrameMix[] = { OPD("hid"), WGT("logits"), WGT("scal
OPD("frame"), OPD("status"), INOUT("dst") };
static const RadParamSpec pEndStatus[] = { P_INT("M"), P_INT("end"), P_INT("rep") };
static const RadOperandSpec oEndStatus[] = { OPD("ids"), OPD("lane"), INOUT("status") };
static const RadParamSpec pRasPick[] = { P_INT("M"), P_INT("win"), P_INT("lo"), P_INT("hi"),
P_INTO("rep"), P_INTO("clear") };
static const RadOperandSpec oRasPick[] = { OPD("first"), OPD("alt"), OPD("lane"), INOUT("hist"),
OUT("ids") };
static const RadParamSpec pFrameStore[] = { P_INT("M"), P_INT("n_codes"), P_INT("stride"),
P_INTO("rep"), P_INTO("skip") };
static const RadOperandSpec oFrameStore[] = { OPD("codes"), OPD("lane"), OPD("frame"),
@@ -1769,6 +1774,10 @@ static const RadOpSchema kSchemas[] = {
"stored at dst[lane * stride + frame - 1] for frame >= 1 and status[lane] >= 0." },
{ "end_status", ARR(pEndStatus), ARR(oEndStatus),
"status[lane[i]] = ids[rep i] == end ? -1 : ids[rep i]." },
{ "ras_pick", ARR(pRasPick), ARR(oRasPick),
"repetition-aware sampling: ids[rep i] = alt[rep i] where first[rep i] is in [lo, hi) and in "
"the lane's window of its last `win` picks (hist [lanes, win], -1 empty, cleared first with "
"`clear` 1), else first[rep i]; the pick then enters the window." },
{ "frame_store", ARR(pFrameStore), ARR(oFrameStore),
"a frame's codes into its lane's history: dst[(lane n_codes + k) stride + frame - skip] = "
"codes[k, rep i] when frame >= skip and status[lane] >= 0." },
@@ -2340,6 +2349,8 @@ SIMPLE("ref_frame_mix_store", "frame_mix_store", "elem", "a frame's conditioning
DT_FLOAT, ref_frame_mix_store),
SIMPLE("ref_end_status", "end_status", "elem", "a frame's status from its first pick", DT_ANY,
ref_end_status),
SIMPLE("ref_ras_pick", "ras_pick", "elem", "a repetition-aware choice between two draws a lane",
DT_ANY, ref_ras_pick),
SIMPLE("ref_frame_store", "frame_store", "elem", "a frame's codes into its lane's history", DT_ANY,
ref_frame_store),
SIMPLE("ref_resample_nearest", "resample_nearest", "elem", "rows resampled nearest-neighbour",