libref, libavx: lora_shrink checks group against the stream's grid

The stream states the group through its extent (make_scales' grid_block), and a K no wider than
one group has one group whatever `group` says: a 64-wide row under group 128 read as group 64 and
was refused. Compare the grid -- groups along K -- instead of the number. An a_scale with no
dtype is absent, like one with no data.
This commit is contained in:
baKon committed 2026-10-16 20:52:09 -05:00
1 parent 7864acf50a
commit 94ae86f6fd
3 files changed
+13 -8

No files matched your search

+2 -1
View File
@@ -105,6 +105,7 @@ AVX_KERNEL(lora_shrink) {
return RAD_E_INVAL;
const RadTensor *X = &a->t[0], *SL = &a->t[2], *LA = &a->t[3], *T = &a->t[4];
const RadTensor* XS = rad_arg_in(a, 1);
if (XS && XS->dtype == RAD_DT_INVALID) XS = nullptr; /* absent, as libref */
const int64_t K = p_int(a, "K", 0), R = p_int(a, "R", 0), S = p_int(a, "S", 0);
if (K <= 0 || R <= 0 || S <= 0) return RAD_E_SHAPE;
const int64_t M = band_rows(numel(T) / R, p_int(a, "M", 0));
@@ -115,7 +116,7 @@ AVX_KERNEL(lora_shrink) {
if (T->dtype != RAD_F32) return RAD_E_DTYPE;
const Scales SA = make_scales(XS, M, K);
const int64_t gp = p_int(a, "group", 0);
if (gp > 0 && SA.p && SA.group != gp) return RAD_E_SHAPE;
if (gp > 0 && SA.p && (K + gp - 1) / gp != (K + SA.group - 1) / SA.group) return RAD_E_SHAPE;
const Mat mx = as_mat(X, K), mt = as_mat(T, R);
const Pool3 pa = pool3(LA, R, K);