clef: skip the lm_head on rows the head answers

This commit is contained in:
Brandon Bertelsen committed 2026-10-28 03:54:15 -04:00
1 parent 65a9e78acf
commit 6a192ff0d7
6 files changed
+56

No files matched your search

+11
View File
@@ -1212,6 +1212,17 @@ inline RadOperand bcol_at(rad_buf h, int64_t first_row, int64_t pitch,
return o;
}
/* Whether every logits row this step samples belongs to a sequence that carries words for the
* plugin (RadBatch::plugin_words). A head that answers from those words then has no use for the
* lm_head's row: it is sampled once and discarded. One row a sampled sequence; a speculative
* step samples more and answers false. */
inline bool plugin_words_cover_rows(const RadBatch* b) {
if (b->n_out <= 0 || !b->plugin_cu_h) return false;
int64_t n = 0;
for (int64_t s = 0; s < b->n_seq; ++s) n += b->plugin_cu_h[s + 1] > b->plugin_cu_h[s] ? 1 : 0;
return n == b->n_out;
}
/* Rows [first, first + n), seen by the kernel as [n, pitch]; RadOperand::offset is in elements.
*
* Lets one op be issued in slices: an op whose widest kernel stops at M=64 (the delta net's
+11
View File
@@ -651,5 +651,16 @@ inline void ClefHead::step_heads(RadCtx* c, const RadBatch* batch, rad_buf b_log
}
}
/* The zero logits rows a trunk leaves when it skips its lm_head for rows a decision head answers
* (the qwen35 plugins' `op_logits_fill`): declared here, by the plugin that wants the skip, so a
* trunk serving a plain container declares the same graph as before. */
inline rad_op clef_logits_fill(RadBuilder* b, Names& nm, const Geom& g, rad_buf b_logits) {
return rw(b, RAD_OP(b, "fill",
RAD_PARAMS(RAD_RANGE("M", 1, g.max_logit_rows), RAD_INT("n", g.n_vocab),
RAD_STR("dtype", "f32"), RAD_F64("value", 0.0)),
RAD_NOWEIGHTS),
{}, { b_logits });
}
} /* namespace arch */
} /* namespace rad */