Archived
radiance 2.1.0
New models. Recursive Flint (39.8B, about 2.5B active) by everplays (#422): `arch/flint`, as an IQ8R container with rotated int8 experts or a four-bit one, with a sink-aware WMMA prefill attention and the fused attention prologue at `rotary_dim` 0. Meta Muse Glimmer 30B by launch80_assets (#423): bf16, an int4 trunk or IQ8R, its windowed vision tower, its DFlash drafter, the ATEM tool dialect and context extension. Ling-3.0-tiny by RikshaDriver (#441): served from its GGUF releases or as IQ8R on `bailing_hybrid`, with six more libr3d kernels. Block FP8, MXFP4 and NVFP4 conversions of the three are not served. IQ8R containers of all three (round to nearest, no calibration) are on Hugging Face under StillDeadcode: flint-iq8r, muse-glimmer-30b-iq8r-dflash and ling-3.0-tiny-iq8r. They were checked for sane answers on two R9700; nothing was benchmarked, and Muse Glimmer's pictures, video and tool calls were not tried. Speech. Breeze-TTS-2 clones a voice from a reference recording and its transcript, with an optional delivery direction, by farcryjohn (#436). The published Breeze container needs converting again with the updated recipe before it can. Tools. A model entry with `diagnose: DIR` runs a fixed workload on the engine instead of serving and writes a report: step times, tokens a step, draft acceptance, TTFT and prefill rates by category, concurrency and prompt length, and with `diagnose-baseline` a token-for-token comparison against an earlier report (docs/DIAGNOSE.md), by Code000 (#418). Scheduler. `mixed-step-target-ms` holds a mixed prefill and decode step to a service time, off by default, by tnhnyzc (#413). `scheduler.stuck-exit` (60s by default, 0 never) ends the process when the device has advanced nothing for that long, so a restart policy brings a hung server back (#409, #415, #428). Fixed. Draft trees with the int8 KV cache, which stopped Gemma 4 31B with DFlash2 on its first request (#454, diagnosed by aelfwyne). The expert loan held at zero by a few leftover cache blocks after long sessions (#455, diagnosed by thekk1). The mapped tier's pages kept in the page cache across a load and a restore, by C_Tamas (#421). Replayed tool calls with blank arguments, and arguments that are not JSON refused naming the call, by dschmitz (#444). The dashboard's card temperature reads the junction sensor, by dschmitz (#453). The VRAM shortfall report says what the KL mode needs, by baKon (#448). The out-of-tree plugin test builds its plugins in parallel and takes its toolchain from the tree. Plugin ABI 40: out-of-tree plugins need to be rebuilt. Thanks to @everplays, @launch80_assets, @RikshaDriver, @farcryjohn, @Code000, @tnhnyzc, @C_Tamas, @dschmitz, @baKon, @aelfwyne and @thekk1.
This commit is contained in:
1 parent
ddcb9c69bb
commit
2a2b756371
166 files changed
+20749
-327
No files matched your search
@@ -46,6 +46,50 @@ inline int64_t ldi(const RadTensor* t, int64_t i) {
|
||||
} /* namespace */
|
||||
|
||||
/* ------------------------------------------------------------------ conv1d */
|
||||
int ref_elu(const RadArgs* a, RadStream) {
|
||||
if (!have(a, 2)) return RAD_E_INVAL;
|
||||
const RadTensor *x = &a->t[0], *y = &a->t[1];
|
||||
if (numel(y) <= 0 || numel(x) < numel(y)) return RAD_E_SHAPE;
|
||||
REF_PAR_FOR(numel(y))
|
||||
for (int64_t i = 0; i < numel(y); ++i) {
|
||||
const float v = ldt(x, offlin(x, i));
|
||||
stt(y, offlin(y, i), v >= 0 ? v : std::expm1(v));
|
||||
}
|
||||
return RAD_OK;
|
||||
}
|
||||
|
||||
/* Mimi's Euclidean RVQ, not the cosine quantiser used by drama-3. Projections belong to
|
||||
* the enclosing split quantiser; each step subtracts its centroid in the projected space. */
|
||||
int ref_vq_euclidean(const RadArgs* a, RadStream) {
|
||||
if (!have(a, 3)) return RAD_E_INVAL;
|
||||
const RadTensor *x = &a->t[0], *cb = &a->t[1], *codes = &a->t[2];
|
||||
const int64_t n = p_int(a, "n", 0), bins = p_int(a, "bins", 0);
|
||||
if (n <= 0 || bins <= 0 || numel(cb) != bins * n || codes->dtype != RAD_I32)
|
||||
return RAD_E_SHAPE;
|
||||
const int64_t rows = rows_of(x, n);
|
||||
if (rows < 1 || numel(codes) < rows) return RAD_E_SHAPE;
|
||||
REF_PAR_FOR(rows * bins * n)
|
||||
for (int64_t r = 0; r < rows; ++r) {
|
||||
float best = INFINITY;
|
||||
int64_t pick = 0;
|
||||
for (int64_t k = 0; k < bins; ++k) {
|
||||
float d = 0;
|
||||
for (int64_t j = 0; j < n; ++j) {
|
||||
const float delta = ldt(x, rowoff(x, r, n) + j * laststride(x)) -
|
||||
ldt(cb, rowoff(cb, k, n) + j * laststride(cb));
|
||||
d += delta * delta;
|
||||
}
|
||||
if (d < best) { best = d; pick = k; }
|
||||
}
|
||||
st_int(codes->dtype, codes->data, offlin(codes, r), pick);
|
||||
for (int64_t j = 0; j < n; ++j) {
|
||||
const int64_t at = rowoff(x, r, n) + j * laststride(x);
|
||||
stt(x, at, ldt(x, at) - ldt(cb, rowoff(cb, pick, n) + j * laststride(cb)));
|
||||
}
|
||||
}
|
||||
return RAD_OK;
|
||||
}
|
||||
|
||||
/* A 1-D convolution over sequences of rows, channels innermost: x [rows, cin], y [rows, cout],
|
||||
* `cu_seqlens` bounding each sequence (row indices of both operands, as every sequenced op reads
|
||||
* them), outside of which the input reads zero (each sequence is padded on its own). w is
|
||||
|
||||
@@ -316,6 +316,178 @@ int ref_grid_embed_cpe(const RadArgs* a, RadStream) {
|
||||
return RAD_OK;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ grid_embed_pad */
|
||||
/* The same learned table and operands as grid_embed's, resampled in the half-pixel-centre form
|
||||
* (align_corners=False) with grid_sample's padding_mode="zeros": taps whose UNCLAMPED index falls
|
||||
* outside [0, side-1) contribute nothing rather than reading the edge. Per axis,
|
||||
* src = (i + 0.5) * side / size - 0.5; floor(src) and floor(src) + 1, each carrying the linear hat
|
||||
* weight (1 - |src - tap|)+ masked to zero off the table. For grids no larger than the table the
|
||||
* mask never fires and the op agrees with grid_embed_aa's centre positions (not grid_embed's
|
||||
* corners-aligned ones); it differs from them only when a grid upsamples past the table, which is
|
||||
* the common case for Muse. The four products are summed in f32 in grid_embed's order (top-left,
|
||||
* top-right, bottom-left, bottom-right), rounded to x's dtype, then added and rounded again. */
|
||||
int ref_grid_embed_pad(const RadArgs* a, RadStream) {
|
||||
if (!have(a, 3)) return RAD_E_INVAL;
|
||||
const RadTensor *x = &a->t[0], *tab = &a->t[1], *crd = &a->t[2];
|
||||
const int64_t n = p_int(a, "n", tab->rank ? tab->shape[tab->rank - 1] : 0);
|
||||
const int64_t side = p_int(a, "side", 0);
|
||||
if (n <= 0 || side <= 0 || numel(tab) < side * side * n) return RAD_E_SHAPE;
|
||||
const int64_t rows = rows_of(x, n);
|
||||
if (rows <= 0 || crd->rank != 2 || crd->shape[0] < 4 || crd->shape[1] < rows)
|
||||
return RAD_E_SHAPE;
|
||||
const int64_t cs = crd->stride[0], ms = crd->stride[1];
|
||||
const int64_t ts = laststride(tab);
|
||||
|
||||
REF_PAR_FOR(rows * n * 4)
|
||||
for (int64_t r = 0; r < rows; ++r) {
|
||||
const int64_t gr = ld_int(crd->dtype, crd->data, 0 * cs + r * ms);
|
||||
const int64_t gc = ld_int(crd->dtype, crd->data, 1 * cs + r * ms);
|
||||
const int64_t gh = ld_int(crd->dtype, crd->data, 2 * cs + r * ms);
|
||||
const int64_t gw = ld_int(crd->dtype, crd->data, 3 * cs + r * ms);
|
||||
int64_t th[2], tw[2];
|
||||
float wh[2], ww[2];
|
||||
auto axis = [&](int64_t idx, int64_t size, int64_t* t, float* w) {
|
||||
if (size < 1) size = 1;
|
||||
const float src = (float)side / (float)size * ((float)idx + 0.5f) - 0.5f;
|
||||
const float fl = std::floor(src);
|
||||
for (int k = 0; k < 2; ++k) {
|
||||
const int64_t raw = (int64_t)fl + k;
|
||||
t[k] = raw < 0 ? 0 : (raw > side - 1 ? side - 1 : raw);
|
||||
const float d = std::fabs(src - fl - (float)k);
|
||||
const float u = 1.0f - d > 0.0f ? 1.0f - d : 0.0f;
|
||||
w[k] = raw >= 0 && raw <= side - 1 ? u : 0.0f;
|
||||
}
|
||||
};
|
||||
axis(gr, gh, th, wh);
|
||||
axis(gc, gw, tw, ww);
|
||||
const int64_t xb = rowoff(x, r, n), xs = laststride(x);
|
||||
for (int64_t i = 0; i < n; ++i) {
|
||||
float acc = 0.0f;
|
||||
for (int ki = 0; ki < 2; ++ki)
|
||||
for (int kj = 0; kj < 2; ++kj)
|
||||
acc += ldt(tab, rowoff(tab, th[ki] * side + tw[kj], n) + i * ts) *
|
||||
(wh[ki] * ww[kj]);
|
||||
const float pe = round_dt(x->dtype, acc);
|
||||
stt(x, xb + i * xs, ldt(x, xb + i * xs) + pe);
|
||||
}
|
||||
}
|
||||
return RAD_OK;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ window_order */
|
||||
/* The window-attention permutation of one encoder pass, computed entirely from the on-device
|
||||
* coordinate planes: HF's get_vision_window_index as a gather-index computation. Windows partition
|
||||
* each segment (one segment == one frame): window row = row/window, window col = col/window,
|
||||
* windows scanned window-row-major and ragged at the segment's right and bottom edges; within a
|
||||
* window patches keep raster order, and windows never span segments.
|
||||
*
|
||||
* `crd` is [4, P] i32 -- row, column, segment height, segment width per patch -- and `cu` is [S+1]
|
||||
* i32, the per-frame segment boundaries in patches. Outputs, all i32: `idx` [P], slot -> source
|
||||
* patch (the gather index); `inv` [P], source patch -> slot; `pos` [2, P], each slot's rope
|
||||
* positions (col + 1, row + 1) -- Muse's rotary wants the axes swapped and offset by one relative
|
||||
* to the coordinate planes (HF's position_ids.flip(-1) + 1) -- laid out component-major like the
|
||||
* planes; and `cuw` [P+1], the cumulative window boundaries in the permuted order, n_windows + 1
|
||||
* entries used, the rest holding the total. `M` is the patches this pass covers, 1..P: slots past
|
||||
* M are the identity, so a caller may reuse buffers sized for a bigger pass. `window` <= 0 makes
|
||||
* the permutation the identity and cuw = cu. */
|
||||
int ref_window_order(const RadArgs* a, RadStream) {
|
||||
if (!have(a, 6)) return RAD_E_INVAL;
|
||||
const RadTensor *crd = &a->t[0], *cu = &a->t[1];
|
||||
RadTensor *idx = const_cast<RadTensor*>(&a->t[2]), *inv = const_cast<RadTensor*>(&a->t[3]),
|
||||
*pos = const_cast<RadTensor*>(&a->t[4]), *cuw = const_cast<RadTensor*>(&a->t[5]);
|
||||
const int64_t M = p_int(a, "M", 0);
|
||||
const int64_t win = p_int(a, "window", 0);
|
||||
if (M <= 0 || crd->rank != 2 || crd->shape[0] < 4 || crd->shape[1] < M) return RAD_E_SHAPE;
|
||||
if (numel(cu) < 2 || numel(idx) < M || numel(inv) < M || numel(pos) < 2 * M ||
|
||||
numel(cuw) < M + 1)
|
||||
return RAD_E_SHAPE;
|
||||
const int64_t P = crd->shape[1];
|
||||
const int64_t cs = crd->stride[0], ms = crd->stride[1];
|
||||
auto gx = [&](int c, int64_t p) {
|
||||
return ld_int(crd->dtype, crd->data, (int64_t)c * cs + p * ms);
|
||||
};
|
||||
|
||||
/* The identity: every slot its own patch, cuw = cu, the tail padded with the last boundary. */
|
||||
auto identity = [&]() {
|
||||
for (int64_t p = 0; p < P; ++p) {
|
||||
st_int(idx->dtype, idx->data, p, p);
|
||||
st_int(inv->dtype, inv->data, p, p);
|
||||
if (p < M) {
|
||||
st_int(pos->dtype, pos->data, p, gx(1, p) + 1);
|
||||
st_int(pos->dtype, pos->data, P + p, gx(0, p) + 1);
|
||||
} else {
|
||||
st_int(pos->dtype, pos->data, p, 1);
|
||||
st_int(pos->dtype, pos->data, P + p, 1);
|
||||
}
|
||||
}
|
||||
int64_t last = 0;
|
||||
const int64_t k = numel(cu) < M + 1 ? numel(cu) : M + 1;
|
||||
for (int64_t i = 0; i < k; ++i) {
|
||||
last = ld_int(cu->dtype, cu->data, i);
|
||||
st_int(cuw->dtype, cuw->data, i, last);
|
||||
}
|
||||
for (int64_t i = k; i < M + 1; ++i) st_int(cuw->dtype, cuw->data, i, last);
|
||||
};
|
||||
if (win <= 0) {
|
||||
identity();
|
||||
return RAD_OK;
|
||||
}
|
||||
|
||||
/* Slot arithmetic: patch p's segment, its window and its rank in the window follow from the
|
||||
* coordinates alone, so a first walk writes the window boundaries and a second scatters. */
|
||||
std::vector<int64_t> seg(M), seg_nw, seg_first_win;
|
||||
std::vector<int64_t> wbase((size_t)M); /* each window's base slot; windows <= M */
|
||||
int64_t s = 0, slot = 0, nwin = 0;
|
||||
const int64_t S = numel(cu) - 1;
|
||||
while (s < S) {
|
||||
const int64_t start = ld_int(cu->dtype, cu->data, s);
|
||||
if (start >= M) break;
|
||||
int64_t end = ld_int(cu->dtype, cu->data, s + 1);
|
||||
if (end > M) end = M;
|
||||
const int64_t gh = start < end ? gx(2, start) : 1;
|
||||
const int64_t gw = start < end ? gx(3, start) : 1;
|
||||
const int64_t nh = (gh + win - 1) / win, nw = (gw + win - 1) / win;
|
||||
seg_first_win.push_back(nwin);
|
||||
seg_nw.push_back(nw);
|
||||
for (int64_t p = start; p < end; ++p) seg[p] = (int64_t)seg_first_win.size() - 1;
|
||||
for (int64_t wr = 0; wr < nh; ++wr)
|
||||
for (int64_t wc = 0; wc < nw; ++wc) {
|
||||
const int64_t rows_in = std::min(win, gh - wr * win);
|
||||
const int64_t cols_in = std::min(win, gw - wc * win);
|
||||
st_int(cuw->dtype, cuw->data, nwin, slot);
|
||||
wbase[(size_t)nwin] = slot;
|
||||
++nwin;
|
||||
slot += rows_in * cols_in;
|
||||
}
|
||||
++s;
|
||||
}
|
||||
st_int(cuw->dtype, cuw->data, nwin, slot);
|
||||
for (int64_t i = nwin + 1; i < M + 1; ++i) st_int(cuw->dtype, cuw->data, i, slot);
|
||||
|
||||
for (int64_t p = 0; p < P; ++p) {
|
||||
if (p >= M) {
|
||||
st_int(idx->dtype, idx->data, p, p);
|
||||
st_int(inv->dtype, inv->data, p, p);
|
||||
st_int(pos->dtype, pos->data, p, 1);
|
||||
st_int(pos->dtype, pos->data, P + p, 1);
|
||||
continue;
|
||||
}
|
||||
const int64_t r = gx(0, p), c = gx(1, p);
|
||||
const int64_t gw = gx(3, p);
|
||||
int64_t wr = r / win, wc = c / win;
|
||||
if (wr < 0) wr = 0;
|
||||
if (wc < 0) wc = 0;
|
||||
const int64_t cols_in = std::min(win, gw - wc * win);
|
||||
const int64_t wid = seg_first_win[(size_t)seg[p]] + wr * seg_nw[(size_t)seg[p]] + wc;
|
||||
const int64_t at = wbase[(size_t)wid] + (r - wr * win) * cols_in + (c - wc * win);
|
||||
st_int(idx->dtype, idx->data, at, p);
|
||||
st_int(inv->dtype, inv->data, p, at);
|
||||
st_int(pos->dtype, pos->data, at, c + 1);
|
||||
st_int(pos->dtype, pos->data, P + at, r + 1);
|
||||
}
|
||||
return RAD_OK;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ add / mul */
|
||||
/* Elementwise over the output's extent. `b` may be a single row of exactly `n` elements, which
|
||||
* broadcasts along rows (a bias add); nothing else broadcasts, so a shape bug cannot pass as a
|
||||
|
||||
@@ -72,8 +72,10 @@ int ref_hc_project (const RadArgs*, RadStream);
|
||||
int ref_mtp_enter (const RadArgs*, RadStream);
|
||||
int ref_layernorm (const RadArgs*, RadStream);
|
||||
int ref_grid_embed (const RadArgs*, RadStream);
|
||||
int ref_grid_embed_pad (const RadArgs*, RadStream);
|
||||
int ref_grid_embed_aa (const RadArgs*, RadStream);
|
||||
int ref_grid_embed_cpe (const RadArgs*, RadStream);
|
||||
int ref_window_order (const RadArgs*, RadStream);
|
||||
int ref_lili_cand (const RadArgs*, RadStream);
|
||||
int ref_lili_attn (const RadArgs*, RadStream);
|
||||
int ref_lili_factor (const RadArgs*, RadStream);
|
||||
@@ -232,6 +234,10 @@ int ref_vsa_select(const RadArgs*, RadStream);
|
||||
int ref_attn_vsa(const RadArgs*, RadStream);
|
||||
/* ref_audio.cpp */
|
||||
int ref_conv1d(const RadArgs*, RadStream);
|
||||
int ref_elu(const RadArgs*, RadStream);
|
||||
int ref_vq_euclidean(const RadArgs*, RadStream);
|
||||
int ref_elu_shape(const RadParam*, int, int, RadOpdDesc*);
|
||||
int ref_vq_euclidean_shape(const RadParam*, int, int, RadOpdDesc*);
|
||||
int ref_conv_t1d(const RadArgs*, RadStream);
|
||||
int ref_snake(const RadArgs*, RadStream);
|
||||
int ref_snake_aa(const RadArgs*, RadStream);
|
||||
@@ -362,8 +368,10 @@ REF_SHAPE_FN(ref_hc_project);
|
||||
REF_SHAPE_FN(ref_mtp_enter);
|
||||
REF_SHAPE_FN(ref_layernorm);
|
||||
REF_SHAPE_FN(ref_grid_embed);
|
||||
REF_SHAPE_FN(ref_grid_embed_pad);
|
||||
REF_SHAPE_FN(ref_grid_embed_aa);
|
||||
REF_SHAPE_FN(ref_grid_embed_cpe);
|
||||
REF_SHAPE_FN(ref_window_order);
|
||||
REF_SHAPE_FN(ref_lili_cand);
|
||||
REF_SHAPE_FN(ref_lili_attn);
|
||||
REF_SHAPE_FN(ref_lili_factor);
|
||||
|
||||
+39
-4
@@ -172,6 +172,10 @@ static const RadOperandSpec oLayernorm[] = { OPD("x"), WGT("w"), WGT_O("b"), OUT
|
||||
/* A learned position table resampled to each row's grid and added in (a vision tower's). */
|
||||
static const RadParamSpec pGridEmbed[] = { P_INT("M"), P_INT("n"), P_INT("side"), P_STR("dtype") };
|
||||
static const RadOperandSpec oGridEmbed[] = { INOUT("x"), WGT("table"), OPD("coord") };
|
||||
/* window_order: the window permutation of one pass, from the coordinate planes alone. */
|
||||
static const RadParamSpec pWindowOrder[] = { P_INT("M"), P_INT("window") };
|
||||
static const RadOperandSpec oWindowOrder[] = { OPD("crd"), OPD_O("cu"), OUT("idx"), OUT("inv"),
|
||||
OUT("pos"), OUT("cuw") };
|
||||
/* grid_embed_cpe adds the rows a segment carries ahead of its patches (n_prefix, `prefix`). */
|
||||
static const RadParamSpec pGridEmbedCpe[] = { P_INT("M"), P_INT("n"), P_INT("side"), P_STR("dtype"),
|
||||
P_INTO("n_prefix") };
|
||||
@@ -1095,6 +1099,8 @@ static const RadParamSpec pVqEncode[] = { P_INT("M"), P_INT("n"), P_INT("dim"),
|
||||
P_STR("dtype") };
|
||||
static const RadOperandSpec oVqEncode[] = { INOUT("x"), WGT("in_w"), WGT("in_b"), WGT("cb"),
|
||||
WGT("out_w"), WGT("out_b"), OUT("codes") };
|
||||
static const RadParamSpec pVqEuclidean[] = { P_INT("M"), P_INT("n"), P_INT("bins"), P_STR("dtype") };
|
||||
static const RadOperandSpec oVqEuclidean[] = { INOUT("x"), WGT("cb"), OUT("codes") };
|
||||
static const RadParamSpec pFrameMix[] = { P_INT("M"), P_INT("n_embd"), P_INT("L"), P_INT("stride"),
|
||||
P_INTO("rep"), P_STR("dtype") };
|
||||
static const RadOperandSpec oFrameMix[] = { OPD("hid"), WGT("logits"), WGT("scale"), OPD("lane"),
|
||||
@@ -1227,6 +1233,23 @@ static const RadOpSchema kSchemas[] = {
|
||||
"`coord` is [4, M] -- row, column, grid height, grid width -- and the position is sampled "
|
||||
"bilinearly with the grid's corners on the table's corners (align_corners), edge taps clamped. "
|
||||
"The taps are summed in f32 and rounded to x's dtype, then added to x and rounded again." },
|
||||
{ "grid_embed_pad", ARR(pGridEmbed), ARR(oGridEmbed),
|
||||
"x[m] += the table resampled at row m's grid position in the half-pixel-centre form "
|
||||
"(align_corners=False) with grid_sample's padding_mode=\"zeros\": per axis taps at floor(src) "
|
||||
"and floor(src) + 1 of src = (i + 0.5) * side / size - 0.5, each carrying the hat weight "
|
||||
"(1 - |src - tap|)+, and a tap whose UNCLAMPED index falls outside the table contributes zero "
|
||||
"rather than reading an edge. Same operands and tap order as `grid_embed`; equal to it whenever "
|
||||
"the grid fits the table, different only when a grid upsamples past it (Muse's case)." },
|
||||
{ "window_order", ARR(pWindowOrder), ARR(oWindowOrder),
|
||||
"The window-attention permutation of one encoder pass (HF's get_vision_window_index) computed "
|
||||
"from the coordinates alone: `crd` [4, P] i32 is row, column, segment height, segment width per "
|
||||
"patch and `cu` [S+1] i32 the per-frame segment boundaries. Windows of `window` patches "
|
||||
"partition each segment, window-row-major, ragged at the segment's right and bottom edges, "
|
||||
"patches raster within a window and windows never across segments. Outputs i32: `idx` [P], "
|
||||
"slot -> source patch (the gather index); `inv` [P], the inverse; `pos` [2, P], each slot's rope "
|
||||
"positions (col + 1, row + 1), component-major like the planes; `cuw` [P+1], the cumulative "
|
||||
"window boundaries in the permuted order, n_windows + 1 entries used. `M` bands the pass; slots "
|
||||
"past M are the identity. `window` <= 0 is the identity permutation, cuw = cu." },
|
||||
{ "grid_embed_aa", ARR(pGridEmbed), ARR(oGridEmbed),
|
||||
"x += the side x side table resampled as torch's F.interpolate(bilinear, align_corners=False, "
|
||||
"antialias=True) resamples it to the row's grid -- SigLIP2's position embedding: per axis a "
|
||||
@@ -2093,8 +2116,8 @@ static const RadOpSchema kSchemas[] = {
|
||||
"a 1-D convolution over the sequences `cu_seqlens` bounds, channels innermost: x [rows, cin], "
|
||||
"y [rows, cout], PyTorch's [cout, cin, k] weight and an optional bias, dilation `dil` and padding "
|
||||
"dil (k - 1) / 2 a side (k odd), or dil (k - 1) on the left with `causal` 1, zeros outside each "
|
||||
"sequence; `res` added after the bias, then `act` none, tanh or clamp (to [-1, 1]). bf16 only "
|
||||
"with `stride` > 1: one sequence [0, rows of x], an explicit `pad` and any k, output row m "
|
||||
"sequence; `res` added after the bias, then `act` none, tanh or clamp (to [-1, 1]). With "
|
||||
"`stride` > 1 and an explicit `pad` (bf16 only): one sequence [0, rows of x], any k, output row m "
|
||||
"reading x[m * stride + tap * dil - pad] — PyTorch's zero-padded strided conv exactly." },
|
||||
{ "conv_t1d", ARR(pConvT1d), ARR(oConvT1d),
|
||||
"a transposed 1-D convolution of kernel `k` >= stride (2 stride by default), padding `pad` "
|
||||
@@ -2123,7 +2146,10 @@ static const RadOpSchema kSchemas[] = {
|
||||
{ "vq_encode", ARR(pVqEncode), ARR(oVqEncode),
|
||||
"one residual vector quantiser step: e = in_w x + in_b, the code the row of cb of greatest "
|
||||
"cosine with e (the lower index on a tie), then x -= out_w cb[code] + out_b; f32, x rounded "
|
||||
"once." },
|
||||
"once." },
|
||||
{ "vq_euclidean", ARR(pVqEuclidean), ARR(oVqEuclidean),
|
||||
"nearest Euclidean centroid (lower index on ties), codes written and centroid subtracted from x." },
|
||||
{ "elu", ARR(pMnD), ARR(oUnary), "y = x >= 0 ? x : expm1(x), alpha 1." },
|
||||
{ "frame_mix_store", ARR(pFrameMix), ARR(oFrameMix),
|
||||
"a frame's conditioning row: the softmax(logits)-weighted sum of hid's L planes times scale, "
|
||||
"stored at dst[lane * stride + frame - 1] for frame >= 1 and status[lane] >= 0." },
|
||||
@@ -2356,6 +2382,12 @@ SIMPLE("ref_layernorm", "layernorm", "norm", "layer norm with gain and bias", DT
|
||||
ref_layernorm),
|
||||
SIMPLE("ref_grid_embed", "grid_embed", "elem",
|
||||
"bilinear resample of a learned position grid, added in", DT_FLOAT, ref_grid_embed),
|
||||
SIMPLE("ref_grid_embed_pad", "grid_embed_pad", "elem",
|
||||
"half-pixel bilinear resample of a position grid, zero-padded taps, added in", DT_FLOAT,
|
||||
ref_grid_embed_pad),
|
||||
SIMPLE("ref_window_order", "window_order", "elem",
|
||||
"the window-attention permutation of one pass, from its coordinates", DT_ANY,
|
||||
ref_window_order),
|
||||
SIMPLE("ref_grid_embed_aa", "grid_embed_aa", "elem",
|
||||
"antialiased half-pixel bilinear resample of a position grid, added in", DT_FLOAT,
|
||||
ref_grid_embed_aa),
|
||||
@@ -2805,7 +2837,10 @@ SIMPLE("ref_cfg_topk_sample", "cfg_topk_sample", "sample", "a guided top-k pick
|
||||
SIMPLE("ref_rvq_embed", "rvq_embed", "elem", "a frame's embedding from its residual codes",
|
||||
DT_FLOAT, ref_rvq_embed),
|
||||
SIMPLE("ref_vq_encode", "vq_encode", "elem",
|
||||
"a residual quantiser's step: the nearest code by cosine", DT_FLOAT, ref_vq_encode),
|
||||
"a residual quantiser's step: the nearest code by cosine", DT_FLOAT, ref_vq_encode),
|
||||
SIMPLE("ref_vq_euclidean", "vq_euclidean", "elem", "Euclidean residual quantiser", DT_FLOAT,
|
||||
ref_vq_euclidean),
|
||||
SIMPLE("ref_elu", "elu", "elem", "ELU, alpha 1", DT_FLOAT, ref_elu),
|
||||
SIMPLE("ref_frame_mix_store", "frame_mix_store", "elem", "a frame's conditioning row into its lane",
|
||||
DT_FLOAT, ref_frame_mix_store),
|
||||
SIMPLE("ref_end_status", "end_status", "elem", "a frame's status from its first pick", DT_ANY,
|
||||
|
||||
@@ -510,6 +510,22 @@ int ref_grid_embed_aa_shape(const RadParam* p, int n_p, int operand, RadOpdDesc*
|
||||
return o.finish("grid_embed_aa", operand, out);
|
||||
}
|
||||
|
||||
/* grid_embed_pad's: the same operands and drawing as grid_embed's. */
|
||||
int ref_grid_embed_pad_shape(const RadParam* p, int n_p, int operand, RadOpdDesc* out) {
|
||||
const uint32_t D = act_dt(p, n_p);
|
||||
const int64_t M = gi(p, n_p, "M", 0), n = gi(p, n_p, "n", 0), side = gi(p, n_p, "side", 0);
|
||||
if (M <= 0 || n <= 0 || side <= 0) return RAD_E_UNSUPPORTED;
|
||||
Opd o;
|
||||
o.t(D, { M, n }); /* x, INOUT */
|
||||
o.t(D, { side * side, n }); /* table */
|
||||
o.t_idx({ 4, M }, side, -1, 0);
|
||||
return o.finish("grid_embed_pad", operand, out);
|
||||
}
|
||||
|
||||
/* window_order declines: its `crd` rows, segment grids and `cu` boundaries must describe whole
|
||||
* raster grids, and an index draw cannot; avx_check_hand.cpp and the unit tests build them. */
|
||||
int ref_window_order_shape(const RadParam*, int, int, RadOpdDesc*) { return RAD_E_UNSUPPORTED; }
|
||||
|
||||
/* grid_embed's operands plus the prefix rows; coordinates drawn over the table's side. */
|
||||
int ref_grid_embed_cpe_shape(const RadParam* p, int n_p, int operand, RadOpdDesc* out) {
|
||||
const uint32_t D = act_dt(p, n_p);
|
||||
@@ -3896,6 +3912,25 @@ int ref_resample_nearest_shape(const RadParam* p, int n_p, int operand, RadOpdDe
|
||||
return o.finish("resample_nearest", operand, out);
|
||||
}
|
||||
|
||||
int ref_elu_shape(const RadParam* p, int n_p, int operand, RadOpdDesc* out) {
|
||||
const int64_t M = gi(p, n_p, "M", 0), n = gi(p, n_p, "n", 0);
|
||||
if (M <= 0 || n <= 0) return RAD_E_UNSUPPORTED;
|
||||
Opd o;
|
||||
o.t(act_dt(p, n_p), {M, n});
|
||||
o.t(act_dt(p, n_p), {M, n});
|
||||
return o.finish("elu", operand, out);
|
||||
}
|
||||
|
||||
int ref_vq_euclidean_shape(const RadParam* p, int n_p, int operand, RadOpdDesc* out) {
|
||||
const int64_t M = gi(p, n_p, "M", 0), n = gi(p, n_p, "n", 0), bins = gi(p, n_p, "bins", 0);
|
||||
if (M <= 0 || n <= 0 || bins <= 0) return RAD_E_UNSUPPORTED;
|
||||
Opd o;
|
||||
o.t(act_dt(p, n_p), {M, n});
|
||||
o.t(act_dt(p, n_p), {bins, n});
|
||||
o.t_idx({M}, bins, -1, 0);
|
||||
return o.finish("vq_euclidean", operand, out);
|
||||
}
|
||||
|
||||
int ref_fourier_embed_shape(const RadParam* p, int n_p, int operand, RadOpdDesc* out) {
|
||||
const int64_t M = gi(p, n_p, "M", 0), n = gi(p, n_p, "n", 0);
|
||||
if (M <= 0 || n <= 0 || (n & 1)) return RAD_E_UNSUPPORTED;
|
||||
|
||||
Reference in new issue
Block a user