core, abi: scored steps -- rad_declare_scores, RadBatch::score_only, and /v1/systemone's model

A scored request (Request::token_scores, what /v1/systemone asks: the raw logits
at a few candidate ids) does not need the half-gigabyte lm_head read the sampler
would consume. A plugin whose head is the bf16 embedding table declares the
final-normed hidden rows and that table (rad_declare_scores); on a step whose
sampled rows are all scored rows and whose program declared both, the core sets
RadBatch::score_only, the plugin issues everything but the head, and the core
reads the hidden rows and the candidates' table rows back and takes the dot
products in f64 on the host. RadBatch gains one trailing int32 (score_only, 360),
which the pass key mixes; an older plugin never sees it set.

The scheduler issues no step ahead of one that brings a scored row to
max_tokens: that forward pass reads nothing and a max_tokens=1 question would
pay a decode step after its prefill. Scored rows only -- every other decode keeps
the step of overlap it had.

/v1/systemone reports which model answered.

Co-Authored-By: Pi <pi@localhost>
This commit is contained in:
Code000andPi authored and StillDeadcode committed 2026-10-29 16:23:28 +01:00
1 parent 9093bf618e
commit ed1e5caf9d
16 files changed
+214 -8

No files matched your search

+29
View File
@@ -1134,6 +1134,30 @@ int Builder::decl_name_map(const RadNameMap* m) {
/* The buffer the core samples from. A second call is refused rather than winning: a target and
* its drafter declaring into one builder (spec §10) both have logits, and keeping the second would
* sample the draft distribution. The drafter's logits are reached through its scope. */
int Builder::declare_scores(rad_buf hidden, rad_weight table) {
if (finished_) { err(RAD_E_STATE, "declare_scores after declare finished"); return RAD_E_STATE; }
if (hidden == RAD_NULL_HANDLE || (size_t)hidden >= prog_.buffers.size()) {
err(RAD_E_INVAL, "declare_scores: %u is not a declared buffer", (unsigned)hidden);
return RAD_E_INVAL;
}
if (table == RAD_NULL_HANDLE || (size_t)table >= prog_.weights.size()) {
err(RAD_E_INVAL, "declare_scores: %u is not a declared weight", (unsigned)table);
return RAD_E_INVAL;
}
const RadBufDecl& h = prog_.buffers[hidden].decl;
const auto& w = prog_.weights[table];
if (h.dtype != RAD_BF16 || h.rank != 2 || w.decl.dtype != RAD_BF16 || w.decl.rank != 2 ||
w.decl.shape[1] != h.shape[1]) {
err(RAD_E_INVAL, "declare_scores: the hidden rows ('%s') and the table ('%s') must be bf16 "
"[rows, n_embd] and [n_vocab, n_embd]", prog_.buffers[hidden].name.c_str(),
w.name.c_str());
return RAD_E_INVAL;
}
prog_.score_hidden = hidden;
prog_.score_table = table;
return RAD_OK;
}
int Builder::declare_logits(rad_buf b) {
if (finished_) { err(RAD_E_STATE, "declare_logits after declare finished"); return RAD_E_STATE; }
if (b == RAD_NULL_HANDLE || (size_t)b >= prog_.buffers.size()) {
@@ -2630,6 +2654,11 @@ int rad_declare_logits(RadBuilder* b, rad_buf logits) {
return B(b)->declare_logits(logits);
}
int rad_declare_scores(RadBuilder* b, rad_buf hidden, rad_weight table) {
if (!b) return RAD_E_INVAL;
return B(b)->declare_scores(hidden, table);
}
int rad_declare_pooled(RadBuilder* b, rad_buf pooled) {
if (!b) return RAD_E_INVAL;
return B(b)->declare_pooled(pooled);