radiance 1.2.0

- MXFP4 weights: block-fp8 Qwen3.5/3.6/3.8 dense models serve OCP-MXFP4 linears (e2m1, an E8M0
  exponent per 32) at 4-bit weights against E4M3 activations. New libr4d rows: the decode GEMM
  (M <= 128, split-K with a fused last-arriver reduction) and the prefill GEMM on a fragment-tiled
  activation. Qwen3.8-27B MXFP4 (AMD Quark AWQ) is in the model table.
- Cards without peer-to-peer access serve: every collective has a host-memory twin; --p2p
  auto|on|off.
- Stop strings apply to the answer, not to the reasoning block a reply starts in.
- A prefix hit ends one drafter window before the prompt's end, so a windowed block drafter
  (DFlash2) drafts from the first token of a follow-up turn.
This commit is contained in:
Deadcode committed 2026-10-06 21:36:24 +02:00
1 parent 7001841e45
commit e95d397288
47 files changed
+2611 -219

No files matched your search

+2
View File
@@ -268,6 +268,7 @@ public:
o.draft_acceptance = m.draft_acceptance;
o.prefill_tokens = m.prefill_tokens; o.decode_tokens = m.decode_tokens;
o.draft_tokens = m.draft_tokens; o.draft_accepted = m.draft_accepted;
o.draft_refills = m.draft_refills; o.draft_refill_tokens = m.draft_refill_tokens;
o.linear_hit_rate = m.linear_hit_rate;
o.attn_cached_tokens = m.attn_cached_tokens;
o.linear_cached_tokens = m.linear_cached_tokens;
@@ -311,6 +312,7 @@ public:
std::string push(int32_t t) override { return d_.push(t); }
std::string flush() override { return d_.flush(); }
bool stopped() const override { return d_.stopped(); }
void defer_stops_until(const std::string& m) override { d_.defer_stops_until(m); }
private:
Detokenizer d_;
};
+6
View File
@@ -102,6 +102,9 @@ struct SchedMetrics {
/* The exact pair the ratio is computed from, for the same reason. */
int64_t draft_tokens = 0;
int64_t draft_accepted = 0;
/* Prefix hits ended early for a windowed block drafter, and the tokens they gave back. */
int64_t draft_refills = 0;
int64_t draft_refill_tokens = 0;
/* THE PER-POSITION DRAFT HAZARD. `draft_acceptance` above is pooled over the whole window and
* cannot distinguish a drafter that decays with depth from one whose later rounds are broken:
* both read as one small number. These carry the conditional rate at each position -- of the
@@ -299,6 +302,9 @@ public:
* search text that can no longer contain what it is searching for, and the generation would
* run to max_tokens. Default false, for a decoder that leaves stop handling to us. */
virtual bool stopped() const { return false; }
/* Match the stop strings only after `marker` has been generated (core/text Detokenizer::
* defer_stops_until): the reply starts inside its reasoning block. */
virtual void defer_stops_until(const std::string& /*marker*/) {}
};
class ITokenizer {
+9
View File
@@ -160,6 +160,9 @@ void Metrics::sample(const SchedMetrics& m) {
c_decode_tokens_.inc(std::max(0.0, (double)m.decode_tokens - c_decode_tokens_.get()));
c_draft_tokens_.inc(std::max(0.0, (double)m.draft_tokens - c_draft_tokens_.get()));
c_draft_accepted_.inc(std::max(0.0, (double)m.draft_accepted - c_draft_accepted_.get()));
c_draft_refills_.inc(std::max(0.0, (double)m.draft_refills - c_draft_refills_.get()));
c_draft_refill_tokens_.inc(
std::max(0.0, (double)m.draft_refill_tokens - c_draft_refill_tokens_.get()));
c_attn_cached_.inc(std::max(0.0, (double)m.attn_cached_tokens - c_attn_cached_.get()));
c_linear_cached_.inc(std::max(0.0, (double)m.linear_cached_tokens - c_linear_cached_.get()));
c_checkpoints_.inc(std::max(0.0, (double)m.checkpoints_written - c_checkpoints_.get()));
@@ -345,6 +348,12 @@ std::string Metrics::render() const {
w.counter("radiance:draft_accepted_total",
"Speculative tokens accepted; the pair the acceptance ratio is computed from.",
L, c_draft_accepted_.get());
w.counter("radiance:draft_refills_total",
"Prefix hits ended a drafter window early so a windowed block drafter has context.",
L, c_draft_refills_.get());
w.counter("radiance:draft_refill_tokens_total",
"Cached prompt tokens those hits gave back to be recomputed.",
L, c_draft_refill_tokens_.get());
/* PREFIX CACHING, DECOUPLED (spec §7.3). vllm:gpu_prefix_cache_hit_rate is the ATTENTION one,
* because that is what vLLM's single number has always meant. The linear side hits at a
+1
View File
@@ -144,6 +144,7 @@ private:
* answers "how much between these two scrapes", and only the second survives a comparison
* between two runs that settled into different mixes. */
Counter c_prefill_tokens_, c_decode_tokens_, c_draft_tokens_, c_draft_accepted_;
Counter c_draft_refills_, c_draft_refill_tokens_;
Counter c_attn_cached_, c_linear_cached_, c_checkpoints_;
Counter c_prefix_evict_, c_prefix_ckpt_evict_;
Gauge g_linear_hit_;
+6
View File
@@ -1456,6 +1456,12 @@ int parse_chat_request(const std::string& body, const OaiDeps& d, const OaiLimit
if (std::find(out->stop.begin(), out->stop.end(), s) == out->stop.end())
out->stop.push_back(s);
/* A reply that starts inside the reasoning block: its stop strings are the answer's, so they
* apply only after the block's closer (Detokenizer::defer_stops_until). The chat format says
* whether the rendered prompt leaves the block open and what closes it. */
if (render.think_starts_open && !render.think_close.empty())
out->stops_after = render.think_close;
/* Checked HERE, where the answer is still a 400. The grammar being validated may be the
* caller's, or one the template produced for its own tool-call syntax; either way the first
* moment it can fail is when the automaton is built, and building it on the step path would
+3
View File
@@ -77,6 +77,9 @@ struct OaiRequest {
SamplingParams sp;
int32_t max_tokens = 0;
std::vector<std::string> stop;
/* The reasoning block's closer when the reply starts inside the block, else "": the stop
* strings above then apply only after it (IDetokenizer::defer_stops_until). */
std::string stops_after;
/* Generate past end-of-text, to max_tokens. See Request::ignore_eos. */
bool ignore_eos = false;
int priority = 0;
+25 -2
View File
@@ -30,6 +30,10 @@ struct Server::Generation {
Finish finish = Finish::None;
bool closed = false; /* the server has decided this choice is over */
size_t scanned = 0; /* how far the stop-string scan has reached */
/* OaiRequest::stops_after: where in `text` the reasoning block's closer ends (npos until it
* has been generated) and how far the search for it has reached. */
size_t stops_floor = std::string::npos;
size_t closer_scanned = 0;
size_t stop_cut = std::string::npos;
size_t emitted = 0; /* streaming: text already handed to the delta stream */
bool retired = false; /* reap() has been said for this id, at most once */
@@ -330,6 +334,7 @@ int Server::submit_all(const OaiRequest& r, std::vector<Generation>* gens, ApiEr
*err = err_not_implemented("the tokenizer did not supply an incremental decoder");
return RAD_E_UNSUPPORTED;
}
if (!r.stops_after.empty()) g.detok->defer_stops_until(r.stops_after);
Request rq;
rq.prompt = r.prompts[p].tokens;
@@ -338,7 +343,9 @@ int Server::submit_all(const OaiRequest& r, std::vector<Generation>* gens, ApiEr
* Offsetting is enough: the sampler's stream is seeded, not chained. */
rq.sp.seed = r.sp.seed + (uint64_t)k;
rq.max_tokens = r.max_tokens;
rq.stop = r.stop;
/* With the stop strings deferred past the reasoning block, the scheduler -- which
* cannot tell reasoning from answer -- gets none; the decoder and pump() cut. */
rq.stop = r.stops_after.empty() ? r.stop : std::vector<std::string>{};
rq.ignore_eos = r.ignore_eos;
rq.priority = r.priority;
rq.stream = r.stream;
@@ -429,8 +436,24 @@ bool Server::pump(std::vector<Generation>& gens, const OaiRequest& r) {
* string straddles token boundaries and only the detokenised text can be searched, so the
* authoritative cut is made here. Scanning restarts (maxstop-1) bytes behind the previous
* end so a match spanning two drains is still found. */
if (maxstop && g.stop_cut == std::string::npos && !g.text.empty()) {
/* Stop strings deferred past the reasoning block match only after its closer. The closer
* is searched for incrementally, from (closer length - 1) bytes behind the previous end,
* so a reply that thinks for a long time is not rescanned from its start every drain. */
size_t floor = 0;
if (!r.stops_after.empty()) {
if (g.stops_floor == std::string::npos) {
const size_t n = r.stops_after.size();
const size_t from = g.closer_scanned >= n ? g.closer_scanned - n + 1 : 0;
const size_t m = g.text.find(r.stops_after, from);
g.closer_scanned = g.text.size();
if (m != std::string::npos) g.stops_floor = m + n;
}
floor = g.stops_floor;
}
if (maxstop && floor != std::string::npos && g.stop_cut == std::string::npos &&
!g.text.empty()) {
size_t start = g.scanned >= maxstop ? g.scanned - maxstop + 1 : 0;
if (start < floor) start = floor;
for (const auto& s : r.stop) {
if (s.empty()) continue;
size_t at = g.text.find(s, start);