radiance 1.3.0

- #47: llama-server's request fields, routes and sampler order, and /props (with baKon's model
  entry: max_model_len, root and capabilities on /v1/models, and /v1/models/:id)
- new APIs: Anthropic's Messages API (/v1/messages), OpenAI's Responses API (/v1/responses),
  llama-server's /completion and /infill, logprobs (OpenAI's logprobs and top_logprobs, up to
  20; llama-server's n_probs), OpenAI's legacy `functions`, and X-Api-Key beside the bearer key
- #4: --model takes a Hugging Face repo id (owner/name), fetched before startup into
  ~/.cache/radiance/hf or --download-dir and checked for changes at every start (redxherring)
- #46: --tp 3 --tp-wire wht6 serves -- a three-rank two-shot all-reduce with uneven shards and
  the tiered-int8 wire over it (baKon); scripts/cardclock.py names what holds each card's clock
  under load (baKon)
- CPU-only serving works again; --kernels names the kernel libraries to load; a model the
  loaded libraries cannot fully serve refuses at startup instead of failing its first request;
  --vram-kv-mib and --vram-weights-mib are gone (the split is automatic)
- --embedding-placement ram is the default, and `auto` is gone
- #40: Swift 1.5 recipes; rad-convert reads which shard holds a tensor from the index
- #53: the pinned host pool gets huge pages where shmem THP is off; #57: a crash on video with
  an odd frame width is fixed
This commit is contained in:
Deadcode committed 2026-10-08 18:22:08 +02:00
1 parent 6a2ee986d6
commit 89cee7ce41
107 files changed
+6849 -1091

No files matched your search

+28
View File
@@ -867,6 +867,10 @@ int Engine::step_loop() {
res.n_accepted = so.accepted.data();
res.token = so.token.data();
res.eos = so.eos.data();
if (!so.lp.empty()) {
res.lp = so.lp.data();
res.first_row = so.first_row.data();
}
st = sched_.commit(res);
if (t_on) phase_mark(PH_COMMIT);
if (st < 0) { RAD_ERR("commit: %s", rad_strerror(st)); return fail_loop(st); }
@@ -1000,6 +1004,20 @@ int Engine::collect_pooled(const RadBatch* b, StepOut& so) {
return RAD_OK;
}
/* One sampled row's logprobs into the step's table, which is sized on the first row that asks.
* A ROW WHOSE LOGPROBS CANNOT BE COMPUTED FAILS ITS REQUEST, NOT THE STEP: its numbers are not
* finite (RAD_E_INVAL), so its entry is left at token -1 (TokenLogprobs), which the scheduler
* answers by failing that request with the reason, and every other sequence in the batch goes on.
* A row outside the step, or one that was never staged for logprobs, is the engine's own fault. */
int Engine::row_logprobs(StepOut& so, int32_t row, int32_t token) {
if (so.lp.empty()) so.lp.resize((size_t)so.n_rows);
if (row < 0 || row >= so.n_rows) return RAD_E_STATE;
TokenLogprobs& lp = so.lp[(size_t)row];
const int s = ranks_[0]->sampler.logprobs_for(row, token, &lp);
if (s == RAD_E_INVAL) { lp = TokenLogprobs{}; return RAD_OK; }
return s;
}
/* Wait for the sampled ids and turn them into the three per-sequence arrays the scheduler wants.
* This is the ONE host synchronisation on the step path: the host needs the tokens to commit them
* and to stream them. Everything else in a step is enqueued and never waited on (spec §5.4). */
@@ -1008,6 +1026,7 @@ int Engine::collect_step(const RadBatch* b, StepOut& so) {
so.token.assign(plan.e.size(), 0);
so.accepted.assign(plan.e.size(), 0);
so.eos.assign(plan.e.size(), 0);
so.lp.clear();
if (so.n_rows <= 0) return RAD_OK;
so.rows.resize((size_t)so.n_rows);
@@ -1097,6 +1116,11 @@ int Engine::collect_step(const RadBatch* b, StepOut& so) {
so.accepted[i] = acc;
so.token[i] = out[acc];
so.eos[i] = vocab_ && vocab_->is_eog(so.token[i]) ? 1 : 0;
/* Each emitted token's logprobs from its own row: an accepted draft is the token the
* target drew at its position, so its row is the distribution it came from. */
if (e.req && e.req->sp.n_probs >= 0)
for (int32_t j = 0; j <= acc; ++j)
RAD_TRY(row_logprobs(so, so.first_row[i] + j, out[j]));
/* EVERY token that leaves, in order: the grammar's state has to advance over the
* accepted drafts too, or the next step's mask is built n_accepted tokens behind.
* Bounded by the truncated `acc`, so it sees exactly the tokens the client does. */
@@ -1122,6 +1146,8 @@ int Engine::collect_step(const RadBatch* b, StepOut& so) {
}
so.token[i] = so.rows[(size_t)so.first_row[i]];
so.eos[i] = vocab_ && vocab_->is_eog(so.token[i]) ? 1 : 0;
if (e.req && e.req->sp.n_probs >= 0)
RAD_TRY(row_logprobs(so, so.first_row[i], so.token[i]));
/* The grammar must see the token it just emitted, or the next step's mask is built from a
* state one token behind the sequence. EVERY rank, not just rank 0: each rank builds the
* mask for its own vocabulary shard from its own automaton, so a rank whose grammar did
@@ -2270,6 +2296,8 @@ int Engine::run_server() {
o.default_thinking_budget = cfg_.thinking_token_budget;
o.default_sampling = resolve_sampling_defaults(meta_, file_ != nullptr, cfg_);
o.default_dry_breakers_set = cfg_.sample_dry_seq_breakers.has_value();
/* An embedding model samples nothing, so it has no logprobs to give. */
o.supports_logprobs = !embedding_ && ranks_[0]->sampler.has_logprobs();
/* -1 leaves ServerOptions' own default, which is `auto` (0). That is resolved per request
* against the context, so it needs one to resolve against. */
if (cfg_.default_max_tokens >= 0) o.default_max_tokens = cfg_.default_max_tokens;