From d0f639bd0620e7ba2cb3672af07b252ebca2005f Mon Sep 17 00:00:00 2001 From: Deadcode Date: Mon, 5 Oct 2026 20:50:29 +0200 Subject: [PATCH] radiance 1.0.13 - Faster prefill on models with an MTP head (Qwen3.8-Flash-Next, Qwen3.6-35B-A3B). Every prefill chunk but a prompt's last runs the head only to leave its K and V behind, and the head no longer runs its expert layer and lm_head for nothing on those chunks. Flash-Next on two R9700: +1.4% at 8K tokens, +3.2% at 26K, +5.9% at 78K; text and decode unchanged. From Code000's opt33. - A request log at the info level: one line when a request is admitted (endpoint, peer, message and tool counts, prompt tokens, max_tokens), one when it ends (finish reason, cached prompt, generated and reasoning tokens, time to first token, decode rate), and every refusal with its status and peer -- a wrong API key included. No prompt text at info. (baKon) - deploy/grafana: a dashboard for /metrics on Prometheus or VictoriaMetrics. (keptn42) - Three-rank tensor parallelism for Qwen3.8-Flash-Next: the all-reduce and all-gather at three ranks, the vocabulary split by 128-row blocks where the world does not divide it, and tools/pad_tp.py to pad the checkpoint's head counts to a world of three -- docs/TP3.md. (baKon) --- .gitignore | 1 + CMakeLists.txt | 2 +- NOTICE | 6 ++- arch/common/rad_block_mtp_fp8.h | 12 ++++-- arch/common/rad_block_mtp_hc.h | 14 +++++-- arch/qwen4exp_fp8/qwen4exp_fp8.cpp | 6 ++- core/server/admin.cpp | 38 ++++++++++--------- core/server/dashboard.cpp | 5 ++- core/server/http.cpp | 4 ++ core/server/oai.cpp | 18 +++++++-- core/server/server.cpp | 60 ++++++++++++++++++------------ core/server/server.h | 2 +- deploy/grafana/README.md | 4 ++ docs/OPS.md | 5 ++- docs/TP3.md | 4 +- tools/pad_tp.py | 2 +- 16 files changed, 121 insertions(+), 62 deletions(-) diff --git a/.gitignore b/.gitignore index 6f389cdb..fad0db0a 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ compile_commands.json *.so *.rad /sync-jarvis.sh +__pycache__/ diff --git a/CMakeLists.txt b/CMakeLists.txt index d38fd738..2a95b629 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.21) # VERSION is what /version reports and what a client checks compatibility against. It is NOT the # ABI version -- that lives in abi/rad_abi.h and is read out of the header below, because # a plugin contract and a server release do not move together. -project(radiance VERSION 1.0.12 LANGUAGES C CXX) +project(radiance VERSION 1.0.13 LANGUAGES C CXX) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) diff --git a/NOTICE b/NOTICE index 74d9af1b..d52a7378 100644 --- a/NOTICE +++ b/NOTICE @@ -4,8 +4,10 @@ Copyright 2026 Deadcode and the radiance contributors Written by Deadcode, with contributions from tcclaviger (the N-rank all-reduce kernels), ggz14 (the MXFP4 GEMM and the GDN kernels' overflow guards), goodman-b (four-rank tensor parallelism for Qwen3.8-Flash-Next), keptn42 (the four-rank all-reduce served in place, the fused four-rank -writes, the n-gram table in RAM and the four-class expert split), mechkbfan (the token -embedding in the pinned host pool) and Code000 (the n-gram gather on the card). +writes, the n-gram table in RAM, the four-class expert split and the Grafana dashboard), +mechkbfan (the token embedding in the pinned host pool), Code000 (the n-gram gather on the card +and the MTP head's history-pass skip) and baKon (three-rank tensor parallelism and the request +log). This product includes software from the following projects, each under the MIT License. The license text is in the file named beside each. diff --git a/arch/common/rad_block_mtp_fp8.h b/arch/common/rad_block_mtp_fp8.h index 44d13b04..dac7f122 100644 --- a/arch/common/rad_block_mtp_fp8.h +++ b/arch/common/rad_block_mtp_fp8.h @@ -436,16 +436,22 @@ inline void MtpBlockFP8::step(RadCtx* c, const RadBatch* batch) const { RAD_ISSUE(c, op_fc, brows(w.c, T), RAD_W(w_fc), brows(w.x, T)); attn.step(c, batch); + + /* A HISTORY PASS THAT DRAFTS NOTHING ENDS HERE. It exists to leave K and V behind, and the + * attention above has stored them. The feed-forward, the norm and the lm_head compute the + * head's output, which only a drafting row reads -- and every prefill chunk but a prompt's + * last drafts nothing. `n_draft_out` is the batch's and the same on every rank, so a + * collective the feed-forward would run is skipped on all of them. */ + if (r < 0 && batch->n_draft_out <= 0) return; + mlp.step(c, batch); RAD_ISSUE(c, op_norm, brows(w.x, T), RAD_W(w_norm), brows(w.hout, T)); - /* A history pass that drafts nothing exists only to leave K and V behind. One that does - * brings round 1's rows to the front first. */ + /* A history pass that drafts brings round 1's rows to the front first. */ int64_t L = T; /* the rows the lm_head runs over */ if (r < 0) { L = batch->n_draft_out; - if (L <= 0) return; RAD_ISSUE_N(c, op_dsel, L, RAD_B(w.hout), praw(batch->draft_out_ids, RAD_I32, L), brows(w.x, L)); RAD_ISSUE_N(c, op_dback, L, brows(w.x, L), brows(w.hout, L)); diff --git a/arch/common/rad_block_mtp_hc.h b/arch/common/rad_block_mtp_hc.h index 75e068c3..ef87de7c 100644 --- a/arch/common/rad_block_mtp_hc.h +++ b/arch/common/rad_block_mtp_hc.h @@ -528,6 +528,16 @@ inline void MtpHcBlock::step(RadCtx* c, const RadBatch* batch) const { * when the attention runs. */ qsa.step(c, attn.w.h, batch); attn.step(c, batch); + + /* A HISTORY PASS THAT DRAFTS NOTHING ENDS HERE. It exists to leave the head's state behind -- + * the K and V the attention just stored and the indexer's block keys and tail -- and both are + * written above. Everything below computes the head's stream, which only a drafting row + * reads: the experts, the two connections around them and the lm_head. Every prefill chunk + * but a prompt's last is such a pass, so on those the head costs its attention alone. + * `n_draft_out` is the batch's and the same on every rank, so the collectives skipped here + * are skipped on all of them. */ + if (r < 0 && batch->n_draft_out <= 0) return; + hc_attn.write(c, T, 0, T); hc_mlp.read(c, T, 0, T); @@ -536,12 +546,10 @@ inline void MtpHcBlock::step(RadCtx* c, const RadBatch* batch) const { /* THE CARRY, and only where a round after this one will read it. The last round of a group * is followed by a trunk step. A history pass that drafts takes round 1's rows out of its own - * -- into the carry, and back to the front of `hw` for the mixer below -- and one that does - * not exists only to leave K and V behind. */ + * -- into the carry, and back to the front of `hw` for the mixer below. */ int64_t L = T; /* the rows the lm_head runs over */ if (r < 0) { L = batch->n_draft_out; - if (L <= 0) return; RAD_ISSUE_N(c, op_dsel, L, RAD_B(w.hw), praw(batch->draft_out_ids, RAD_I32, L), brows(w.hin, L)); RAD_ISSUE_N(c, op_dback, L, brows(w.hin, L), brows(w.hw, L)); diff --git a/arch/qwen4exp_fp8/qwen4exp_fp8.cpp b/arch/qwen4exp_fp8/qwen4exp_fp8.cpp index 76b3cbf0..7ae4b287 100644 --- a/arch/qwen4exp_fp8/qwen4exp_fp8.cpp +++ b/arch/qwen4exp_fp8/qwen4exp_fp8.cpp @@ -413,8 +413,10 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c /* ---- the routed feed-forward. * - * n_ff is `moe_intermediate_size` and geom_from already divided it by world_size -- and that - * division is exactly what the header's tensor-parallel section is about. */ + * n_ff is `moe_intermediate_size`: divided by world_size when the world divides it, and left + * whole when it does not (geom_from's `arch_splits_ff`). Either way it is only the starting + * point -- at more than one rank the split below decides the rank's width, by whole fp8 + * blocks and parity, which is what the header's tensor-parallel section is about. */ { MoeFP8::Config& mc = m.moecfg; mc.n_expert = meta_int2(meta, "qwen4exp.expert_count", "num_experts", 0); diff --git a/core/server/admin.cpp b/core/server/admin.cpp index 1d2c331a..96ce4c6b 100644 --- a/core/server/admin.cpp +++ b/core/server/admin.cpp @@ -131,11 +131,12 @@ HttpResponse Server::handle_load(const HttpRequest&) { * finds out what this endpoint's token ids do to a subsequent /v1/completions. */ HttpResponse Server::handle_tokenize(const HttpRequest& req) { if (!deps_.tok) - return error_response(err_not_implemented("the server has no tokenizer attached")); + return error_response(err_not_implemented("the server has no tokenizer attached"), + req.peer); json b; ApiError err; - if (!parse_object(req.body, opt_.max_ctx, &b, &err)) return error_response(err); + if (!parse_object(req.body, opt_.max_ctx, &b, &err)) return error_response(err, req.peer); const bool want_strs = get_bool_or(b, "return_token_strs", false); std::vector toks; @@ -143,15 +144,15 @@ HttpResponse Server::handle_tokenize(const HttpRequest& req) { auto msgs = b.find("messages"); auto prom = b.find("prompt"); if (msgs != b.end() && prom != b.end()) - return error_response(err_bad("prompt", "send `prompt` or `messages`, not both")); + return error_response(err_bad("prompt", "send `prompt` or `messages`, not both"), req.peer); if (msgs != b.end()) { if (!deps_.chat) return error_response(err_not_implemented( "tokenising `messages` requires a chat template; this model was not loaded with " - "one. Send `prompt` with the text you want tokenised")); + "one. Send `prompt` with the text you want tokenised"), req.peer); if (!msgs->is_array() || msgs->empty()) - return error_response(err_bad("messages", "must be a non-empty array")); + return error_response(err_bad("messages", "must be a non-empty array"), req.peer); ChatRenderOptions opt; opt.add_generation_prompt = get_bool_or(b, "add_generation_prompt", true); @@ -170,13 +171,14 @@ HttpResponse Server::handle_tokenize(const HttpRequest& req) { if (deps_.chat->apply(*msgs, tools, opt, &render, &why) < 0) return error_response(err_bad("messages", why.empty() ? "the chat template could not render this request" - : why)); + : why), req.peer); toks = deps_.tok->encode(render.prompt, get_bool_or(b, "add_special_tokens", false), /*parse_special=*/true); } else { if (prom == b.end() || !prom->is_string()) - return error_response(err_bad("prompt", "must be a string, or send `messages`")); + return error_response(err_bad("prompt", "must be a string, or send `messages`"), + req.peer); /* Encoded as /v1/completions encodes it, so the count is the count that endpoint sees. */ toks = deps_.tok->encode(prom->get(), get_bool_or(b, "add_special_tokens", true), @@ -203,25 +205,26 @@ HttpResponse Server::handle_tokenize(const HttpRequest& req) { * a token array would arrive as. The name is odd and it is the name clients read. */ HttpResponse Server::handle_detokenize(const HttpRequest& req) { if (!deps_.tok) - return error_response(err_not_implemented("the server has no tokenizer attached")); + return error_response(err_not_implemented("the server has no tokenizer attached"), + req.peer); json b; ApiError err; - if (!parse_object(req.body, opt_.max_ctx, &b, &err)) return error_response(err); + if (!parse_object(req.body, opt_.max_ctx, &b, &err)) return error_response(err, req.peer); auto t = b.find("tokens"); if (t == b.end() || !t->is_array()) - return error_response(err_bad("tokens", "must be an array of integers")); + return error_response(err_bad("tokens", "must be an array of integers"), req.peer); std::vector toks; toks.reserve(t->size()); for (const auto& v : *t) { if (!v.is_number_integer()) - return error_response(err_bad("tokens", "must be an array of integers")); + return error_response(err_bad("tokens", "must be an array of integers"), req.peer); int32_t id = 0; if (!token_id(v, &id)) return error_response(err_bad("tokens", "a token id must be in [0, 2147483647], " - "got " + v.dump())); + "got " + v.dump()), req.peer); toks.push_back(id); } @@ -236,9 +239,10 @@ HttpResponse Server::handle_detokenize(const HttpRequest& req) { * container carries a normalised vocabulary and not the JSON it was built from. So this answers * the questions that config is actually READ for -- how big is the vocabulary, which ids end a * generation, is a chat template available -- and says nothing it would have to invent. */ -HttpResponse Server::handle_tokenizer_info(const HttpRequest&) { +HttpResponse Server::handle_tokenizer_info(const HttpRequest& req) { if (!deps_.tok) - return error_response(err_not_implemented("the server has no tokenizer attached")); + return error_response(err_not_implemented("the server has no tokenizer attached"), + req.peer); const ITokenizer::VocabInfo v = deps_.tok->vocab_info(); json o; @@ -356,15 +360,15 @@ HttpResponse Server::handle_server_info(const HttpRequest&) { /* 501 when there is no prefix cache to reset, and that is the point: vLLM answers 200 with an * empty body whether or not anything happened, so a benchmark that thinks it started cold has no * way to find out it did not. This says how many entries went. */ -HttpResponse Server::handle_reset_prefix_cache(const HttpRequest&) { +HttpResponse Server::handle_reset_prefix_cache(const HttpRequest& req) { if (!deps_.sched) - return error_response(err_not_implemented("the server has no engine attached")); + return error_response(err_not_implemented("the server has no engine attached"), req.peer); const int64_t n = deps_.sched->reset_prefix_cache(); if (n < 0) return error_response(err_not_implemented( "this engine has no prefix cache (started with --no-prefix-cache, or the model " - "declares no cacheable KV group)")); + "declares no cacheable KV group)"), req.peer); json o; o["entries_dropped"] = n; diff --git a/core/server/dashboard.cpp b/core/server/dashboard.cpp index 8edf61b7..eae0d808 100644 --- a/core/server/dashboard.cpp +++ b/core/server/dashboard.cpp @@ -361,10 +361,11 @@ HttpResponse Server::handle_stats(const HttpRequest&) { * This is the same walk (dump_graph_json shares every helper with the text one) served from the * process that is actually running, which is where the question is usually asked. Static after * declare, so it is rendered once and handed over. */ -HttpResponse Server::handle_graph(const HttpRequest&) { +HttpResponse Server::handle_graph(const HttpRequest& req) { if (!opt_.graph_json) return error_response(err_not_implemented( - "the server was not given a declared graph; this build has no engine attached")); + "the server was not given a declared graph; this build has no engine attached"), + req.peer); HttpResponse r; r.status = 200; r.body = opt_.graph_json(); diff --git a/core/server/http.cpp b/core/server/http.cpp index fe05b1af..9bb1a8c1 100644 --- a/core/server/http.cpp +++ b/core/server/http.cpp @@ -367,6 +367,10 @@ int HttpTransport::serve(const Router& router, const TransportOptions& o) { std::string got = hreq.get_header_value("Authorization"); const std::string want = "Bearer " + api_key; if (got != want) { + /* Said like every other refusal (Server::error_response), which this one never + * reaches: the gate answers before the router does. */ + RAD_INFO("req refused from %s:%d -> 401 authentication_error: invalid api key", + hreq.remote_addr.c_str(), hreq.remote_port); hres.status = 401; hres.set_content(error_body("authentication_error", "invalid api key"), "application/json"); diff --git a/core/server/oai.cpp b/core/server/oai.cpp index 7f624d44..083c42b7 100644 --- a/core/server/oai.cpp +++ b/core/server/oai.cpp @@ -1279,14 +1279,26 @@ int parse_chat_request(const std::string& body, const OaiDeps& d, const OaiLimit if (!it->is_object() || !it->contains("role") || it->at("role") != "user") continue; const auto cit = it->find("content"); if (cit == it->end()) break; + /* At most 160 bytes are kept, so no more than that is copied out of a message that + * may be a whole document, and the cut lands on a UTF-8 lead byte: a log line split + * inside a character is not valid text. */ + constexpr size_t kKeep = 160; std::string t; - if (cit->is_string()) t = cit->get(); + auto take = [&t](const std::string& s) { + if (t.size() <= kKeep) t.append(s, 0, kKeep + 1 - t.size()); + }; + if (cit->is_string()) take(cit->get_ref()); else if (cit->is_array()) for (const auto& part : *cit) if (part.is_object() && part.value("type", "") == "text") - t += part.value("text", ""); + take(part.value("text", "")); for (char& c : t) if (c == '\n' || c == '\r' || c == '\t') c = ' '; - if (t.size() > 160) { t.resize(157); t += "..."; } + if (t.size() > kKeep) { + size_t cut = kKeep - 3; + while (cut > 0 && ((unsigned char)t[cut] & 0xC0) == 0x80) --cut; + t.resize(cut); + t += "..."; + } out->last_user = std::move(t); break; } diff --git a/core/server/server.cpp b/core/server/server.cpp index e4f4bbbe..fdc11901 100644 --- a/core/server/server.cpp +++ b/core/server/server.cpp @@ -250,17 +250,23 @@ void Server::sweep_abandoned() { /* ------------------------------------------------------------------ errors */ +/* " from " for the request log, or nothing in-process, where no transport names a + * peer. */ +static std::string from_peer(const std::string& peer) { + return peer.empty() ? std::string() : " from " + peer; +} + HttpResponse Server::error_response(const ApiError& e, const std::string& peer) { metrics_.observe_http(e.status); /* A refusal is the line the operator is looking for when a client says "rejected": the * status, the type, the message, and who asked. 4xx is the client's doing and said at info; * 5xx is ours and said as a warning. */ if (e.status >= 500) - RAD_WARN("req %s%s%s -> %d %s: %s", peer.empty() ? "" : "from ", peer.c_str(), - peer.empty() ? "refused" : "", e.status, e.type.c_str(), e.message.c_str()); + RAD_WARN("req refused%s -> %d %s: %s", from_peer(peer).c_str(), e.status, e.type.c_str(), + e.message.c_str()); else - RAD_INFO("req %s%s%s -> %d %s: %s", peer.empty() ? "" : "from ", peer.c_str(), - peer.empty() ? "refused" : "", e.status, e.type.c_str(), e.message.c_str()); + RAD_INFO("req refused%s -> %d %s: %s", from_peer(peer).c_str(), e.status, e.type.c_str(), + e.message.c_str()); HttpResponse r = HttpResponse::json_body(e.status, e.dump()); if (e.status == 429) r.set_header("Retry-After", std::to_string(opt_.retry_after_s)); return r; @@ -273,14 +279,17 @@ void Server::log_admitted(const OaiRequest& r) const { for (const auto& p : r.prompts) n_prompt += (int64_t)p.tokens.size(); const char* kind = r.endpoint == Endpoint::Chat ? "chat" : "completion"; if (r.endpoint == Endpoint::Chat) - RAD_INFO("req %s %s%s from %s model=%s msgs=%d tools=%d prompt=%lld tok n=%d max_tokens=%lld", - r.id.c_str(), kind, r.stream ? " stream" : "", r.peer.c_str(), r.model.c_str(), - r.n_messages, r.n_tools, (long long)n_prompt, r.n, (long long)r.max_tokens); + RAD_INFO("req %s %s%s%s model=%s msgs=%d tools=%d prompt=%lld tok n=%d max_tokens=%lld", + r.id.c_str(), kind, r.stream ? " stream" : "", from_peer(r.peer).c_str(), + r.model.c_str(), r.n_messages, r.n_tools, (long long)n_prompt, r.n, + (long long)r.max_tokens); else - RAD_INFO("req %s %s%s from %s model=%s prompts=%zu prompt=%lld tok n=%d max_tokens=%lld", - r.id.c_str(), kind, r.stream ? " stream" : "", r.peer.c_str(), r.model.c_str(), - r.prompts.size(), (long long)n_prompt, r.n, (long long)r.max_tokens); - if (!r.last_user.empty()) RAD_DEBUG("req %s last user: %s", r.id.c_str(), r.last_user.c_str()); + RAD_INFO("req %s %s%s%s model=%s prompts=%zu prompt=%lld tok n=%d max_tokens=%lld", + r.id.c_str(), kind, r.stream ? " stream" : "", from_peer(r.peer).c_str(), + r.model.c_str(), r.prompts.size(), (long long)n_prompt, r.n, + (long long)r.max_tokens); + if (!r.last_user.empty()) + RAD_DEBUG("req %s last user: %s", r.id.c_str(), r.last_user.c_str()); } /* ------------------------------------------------------------------ submission */ @@ -570,8 +579,8 @@ void Server::record(const OaiRequest& r, const std::vector& gens, Fi if (ttft >= 0) std::snprintf(ttft_s, sizeof ttft_s, "ttft=%.2fs", ttft); char rate_s[32] = ""; if (rate > 0) std::snprintf(rate_s, sizeof rate_s, " %.1f tok/s", rate); - RAD_INFO("req %s %s finish=%s prompt=%lld (cache %lld) gen=%lld%s %s%s %.2fs", - r.id.c_str(), r.peer.empty() ? "done" : r.peer.c_str(), finish_reason_oai(overall), + RAD_INFO("req %s done%s finish=%s prompt=%lld (cache %lld) gen=%lld%s %s%s %.2fs", + r.id.c_str(), from_peer(r.peer).c_str(), finish_reason_oai(overall), (long long)n_prompt, (long long)(t.valid ? t.cache_n : 0), (long long)n_gen, reason, ttft_s, rate_s, e2e); } @@ -584,7 +593,7 @@ HttpResponse Server::blocking_completion(const HttpRequest& req, OaiRequest& r) if (submit_all(r, &gens, &err) < 0) { retire(gens); release(r.n_choices()); - return error_response(err); + return error_response(err, req.peer); } for (;;) { @@ -605,7 +614,7 @@ HttpResponse Server::blocking_completion(const HttpRequest& req, OaiRequest& r) cancel_all(gens, false); retire(gens); release(r.n_choices()); - return error_response(err_overloaded("the server is shutting down")); + return error_response(err_overloaded("the server is shutting down"), req.peer); } /* Wait on whichever choice is still running. Bounded, so the peer check above runs. */ for (auto& g : gens) if (!g.closed) { g.sink->wait(); break; } @@ -673,7 +682,7 @@ HttpResponse Server::blocking_completion(const HttpRequest& req, OaiRequest& r) e.status = 500; e.type = "internal_server_error"; e.message = why; - return error_response(e); + return error_response(e, req.peer); } } @@ -717,7 +726,7 @@ HttpResponse Server::streaming_completion(const HttpRequest& req, OaiRequest& r) if (submit_all(st->r, &st->gens, &err) < 0) { retire(st->gens); release(r.n_choices()); - return error_response(err); + return error_response(err, req.peer); } if (st->r.endpoint == Endpoint::Chat) for (auto& g : st->gens) @@ -878,7 +887,8 @@ HttpResponse Server::handle_chat(const HttpRequest& req) { OaiRequest r; ApiError err; - if (parse_chat_request(req.body, odeps_, lim_, &r, &err) < 0) return error_response(err, req.peer); + if (parse_chat_request(req.body, odeps_, lim_, &r, &err) < 0) + return error_response(err, req.peer); r.peer = req.peer; sweep_abandoned(); @@ -898,7 +908,8 @@ HttpResponse Server::handle_completion(const HttpRequest& req) { OaiRequest r; ApiError err; - if (parse_completion_request(req.body, odeps_, lim_, &r, &err) < 0) return error_response(err, req.peer); + if (parse_completion_request(req.body, odeps_, lim_, &r, &err) < 0) + return error_response(err, req.peer); r.peer = req.peer; sweep_abandoned(); @@ -914,14 +925,17 @@ HttpResponse Server::handle_completion(const HttpRequest& req) { HttpResponse Server::handle_embeddings(const HttpRequest& req) { if (!deps_.tok) - return error_response(err_not_implemented("the server has no tokenizer attached")); + return error_response(err_not_implemented("the server has no tokenizer attached"), + req.peer); if (!deps_.embed) return error_response(err_not_implemented( - "/v1/embeddings requires an embedding head; this model was not loaded with one")); + "/v1/embeddings requires an embedding head; this model was not loaded with one"), + req.peer); OaiRequest r; ApiError err; - if (parse_embeddings_request(req.body, odeps_, lim_, &r, &err) < 0) return error_response(err, req.peer); + if (parse_embeddings_request(req.body, odeps_, lim_, &r, &err) < 0) + return error_response(err, req.peer); std::vector> vecs; UsageOut u; @@ -934,7 +948,7 @@ HttpResponse Server::handle_embeddings(const HttpRequest& req) { e.status = 500; e.type = "internal_server_error"; e.message = std::string("the embedding pass failed: ") + rad_strerror(s); - return error_response(e); + return error_response(e, req.peer); } u.prompt += (int64_t)p.tokens.size(); vecs.push_back(std::move(v)); diff --git a/core/server/server.h b/core/server/server.h index ef9f07ae..96f4defe 100644 --- a/core/server/server.h +++ b/core/server/server.h @@ -189,7 +189,7 @@ private: HttpResponse handle_stats(const HttpRequest& req); HttpResponse handle_graph(const HttpRequest& req); - HttpResponse error_response(const ApiError& e, const std::string& peer = std::string()); + HttpResponse error_response(const ApiError& e, const std::string& peer); /* THE REQUEST LOG. One line when a request is admitted and one from record() when it ends, * at the info level, so `docker logs` answers "who asked what, how long, how did it end" * without the engine's own levels. The debug level adds the last user message's opening. */ diff --git a/deploy/grafana/README.md b/deploy/grafana/README.md index 5db0082e..e774390e 100644 --- a/deploy/grafana/README.md +++ b/deploy/grafana/README.md @@ -15,6 +15,10 @@ scrape_configs: - job_name: radiance static_configs: - targets: ["gpu-host:8000"] + # Only when the server runs with --api-key: /metrics is behind the key like every path but + # /health, /ping and the dashboard page, and an unauthorised scrape gets 401. + authorization: + credentials: "" ``` Window values are counter ratios with the definitions of the since-start gauges: diff --git a/docs/OPS.md b/docs/OPS.md index a23f18b4..4653a9c4 100644 --- a/docs/OPS.md +++ b/docs/OPS.md @@ -742,8 +742,9 @@ libr4d serves these at **2, 3, 4 and 8 ranks**. Two ranks have their own kernels block, the rotated 6-bit wire, the fused norm-and-reduce forms). The wide family is one template on the world size; 4 and 8 have both hops, 3 has the one-shot only -- the two-shot shards the message `world` ways and a residual width such as 2560 does not divide by 3 -- and `all_gather` at width -rides the same instance as the wide `all_reduce` (`ar_gather_3rank`, `_4rank`, `_8rank`). The fused forms are declared -only at two ranks by the arch blocks, which fall back to the plain pair at any other width. +rides the same instance as the wide `all_reduce` (`ar_gather_3rank`, `_4rank`, `_8rank`). The +fused forms are declared only at two ranks by the arch blocks, which fall back to the plain pair at +any other width. `min_bytes` is the byte floor under which a LOSSY row must serve the message exactly anyway, and it is a parameter rather than a constant in the library because it is a property of the link and not diff --git a/docs/TP3.md b/docs/TP3.md index cc4a8729..4c0b2d02 100644 --- a/docs/TP3.md +++ b/docs/TP3.md @@ -107,8 +107,8 @@ radiance --model qfn-tp3pad.rad --tp 3 --tp-wire exact --max-num-seqs 8 --max-mo Measured on three Radeon AI PRO R9700 (gfx1201, PCIe Gen5 x16, Threadripper PRO 9955WX), the uncensored Flash-Next fine-tune padded as above and converted with the shipped recipe -(`qwen4exp-w4nl64-i8-hc8m`, here without Hessians: nearest into the codebook), this branch over -1.0.8; the two-rank column is the shipped `qwen3.8-next-flash-fp8-iq4r-moe.rad` on the same box: +(`qwen4exp-w4nl64-i8-hc8m`, here without Hessians: nearest into the codebook), on 1.0.8 with +the changes above; the two-rank column is the shipped `qwen3.8-next-flash-fp8-iq4r-moe.rad` on the same box: | | three ranks, padded | two ranks, shipped container | |---|---|---| diff --git a/tools/pad_tp.py b/tools/pad_tp.py index 02e176a8..31773501 100755 --- a/tools/pad_tp.py +++ b/tools/pad_tp.py @@ -15,7 +15,7 @@ What is padded and why it is exact (fp32-accumulated, zero terms add nothing): gdn (Qwen3-Next, --gdn-k/--gdn-v) in_proj_qkvz / in_proj_ba gain zero rows per the fused layout, conv1d zero channels, A_log / dt_bias zero heads, out_proj zero columns. Everything with n_embd as its only width (norms, embeddings, lm_head) is untouched. config.json is -rewritten with the new counts and an explicit head_dim. Dummies go LAST, as Rob's vLLM tp_padding +rewritten with the new counts and an explicit head_dim. Dummies go LAST, as tcclaviger's vLLM tp_padding does, so rank w-1 carries them. bf16 is handled as raw u16 (no arithmetic happens here), so numpy alone suffices.