Archived
ops: attention sinks and LiLiCorr's correlator
For NVIDIA's LiLiCorr drafter: - attn_paged_sink: attn_paged with a learned logit a query head beside the keys, in libref, libavx and libr4d (the windowed kernels at h128, gqa 8 and 16) - sample_logprobs without params writes every row (a drafter's candidate logprobs) - lili_cand, lili_attn, lili_factor, lili_walk: the correlator's candidates and features, its attention over the candidate lattice, the factor input and the greedy walk ref_test, avx_check_hand and r4d_emu cases; docs/OPS.md.
This commit is contained in:
1 parent
44490c859a
commit
3b278dcec3
26 files changed
+1904
-55
No files matched your search
@@ -685,9 +685,9 @@ AVX_KERNEL(sample_argmax) {
|
||||
* pass the test after the first few thousand columns.
|
||||
*
|
||||
* The sum is f32 in four accumulators. Its terms are in (0, 1] and a logprob carries only its
|
||||
* relative error, so f32 suffices (libref uses double). */
|
||||
* relative error, so f32 suffices (libref uses double). Without `params` every row is written. */
|
||||
AVX_KERNEL(sample_logprobs) {
|
||||
if (!rad_args_have(a, 3)) return RAD_E_INVAL;
|
||||
if (a->n_t < 3 || !a->t[0].data || !a->t[2].data) return RAD_E_INVAL;
|
||||
const RadTensor *lg = &a->t[0], *pr = &a->t[1], *st = &a->t[2];
|
||||
const int64_t n_vocab = p_int(a, "n_vocab", lg->rank >= 2 ? lg->shape[lg->rank - 1] : 0);
|
||||
const int64_t k = p_int(a, "k", 0);
|
||||
@@ -697,11 +697,11 @@ AVX_KERNEL(sample_logprobs) {
|
||||
const int64_t w = 2 + 2 * k;
|
||||
if (M <= 0 || numel(st) < M * w) return RAD_E_SHAPE;
|
||||
Rows R;
|
||||
AVX_TRY(rows_of_params(pr, M, &R));
|
||||
if (pr->data) AVX_TRY(rows_of_params(pr, M, &R));
|
||||
|
||||
AVX_PARALLEL_FOR_IF(M * n_vocab >= AVX_PAR_MIN)
|
||||
for (int64_t m = 0; m < M; ++m) {
|
||||
if (!(R.p[m].flags & RAD_SP_LOGPROBS)) continue;
|
||||
if (pr->data && !(R.p[m].flags & RAD_SP_LOGPROBS)) continue;
|
||||
float* buf = scratch_f32((size_t)n_vocab + 2 * (size_t)k);
|
||||
const float* v = in_row(lg, rowoff(lg, m, n_vocab), n_vocab, buf);
|
||||
float* tv = buf + n_vocab; /* the set's values, descending */
|
||||
|
||||
Reference in new issue
Block a user