dashboard: attribute fleet rows and KPIs per LoRA adapter

(cherry picked from commit e3492fbb1a0f7759360f636c15014d971e955849)
This commit is contained in:
Donna Patch authored and StillDeadcode committed 2026-11-20 15:56:44 +01:00
1 parent b424572afd
commit ce47698795
4 files changed
+53 -9

No files matched your search

+7 -3
View File
@@ -2623,15 +2623,19 @@ json Fleet::status() {
/* Runtime LoRA: an adapter is a model as far as choosing one goes, and /v1/models lists
* each as a child under `base:adapter` (server.cpp). The fleet view must say the same,
* or a view built on it is blind to what this machine answers to. A child owns nothing:
* no cards, no bytes, no policy of its own; its state and counters are the parent's,
* because the parent is what serves it. */
* no cards, no bytes, no policy of its own. Its state is the parent's, because the parent
* is what serves it; its in-flight count is its own -- the leases taken under its name
* (Front::adapter_leases) -- so a view can tell which adapter is running. A request for
* the base names no adapter and lights up no child, and one adapter's traffic never
* lights up another's. Its waiting is the parent's queue: while the parent is not open
* nothing reaches any child. */
for (const std::string& a : adapters_of(n)) {
json ad;
ad["id"] = n + ":" + a;
ad["parent"] = n;
ad["adapter"] = true;
ad["state"] = j["state"];
ad["in_flight"] = j["in_flight"];
ad["in_flight"] = front_.adapter_leases(n, a);
ad["waiting"] = j["waiting"];
models.push_back(std::move(ad));
}
+30 -3
View File
@@ -384,14 +384,30 @@ std::vector<std::string> Front::names() const {
return v;
}
std::shared_ptr<void> Front::lease_entry(Entry* e) {
int64_t Front::adapter_leases(const std::string& name, const std::string& adapter) const {
std::lock_guard<std::mutex> lk(mu_);
for (auto& p : entries_)
if (p->name == name && !p->removed) {
const auto it = p->adapter_leases.find(adapter);
return it == p->adapter_leases.end() ? 0 : it->second;
}
return 0;
}
std::shared_ptr<void> Front::lease_entry(Entry* e, const std::string& adapter) {
++e->leases;
++e->uses;
e->last_used_ns = rad_mono_ns();
return std::shared_ptr<void>(static_cast<void*>(e), [this](void* p) {
std::map<std::string, int64_t>* per = adapter.empty() ? nullptr : &e->adapter_leases;
if (per) ++(*per)[adapter];
return std::shared_ptr<void>(static_cast<void*>(e), [this, per, adapter](void* p) {
std::lock_guard<std::mutex> lk(mu_);
Entry* x = static_cast<Entry*>(p);
--x->leases;
if (per) {
const auto it = per->find(adapter);
if (it != per->end()) --it->second;
}
x->last_used_ns = rad_mono_ns();
changed_.notify_all();
});
@@ -511,7 +527,18 @@ Front::Got Front::lease(const std::string& model, const std::string& path, int64
return Got::Refused;
}
*out = e;
*held = lease_entry(e);
/* A request may name an adapter within the model's name (`base:adapter`): the base's server
* runs it and the base's lease covers it, but what is running is the named tail. A model's
* own name carries no colon (the fleet's config reserves it), so a name that resolved
* through the colon rule carries the adapter as what stands after it. */
std::string adapter;
{
const size_t colon = model.find(':');
if (colon != std::string::npos && colon + 1 < model.size() &&
e->name == model.substr(0, colon))
adapter = model.substr(colon + 1);
}
*held = lease_entry(e, adapter);
/* The whole wait began where *until_ns was set, the entry's timeout before its end. */
const uint64_t began = *until_ns - (uint64_t)std::max<int64_t>(e->wait_ms, 0) * 1000000ull;
const double waited = (double)(rad_mono_ns() - std::min(began, rad_mono_ns())) * 1e-9;
+12 -1
View File
@@ -132,6 +132,10 @@ public:
bool detach(const std::string& name, int wait_ms);
Activity activity(const std::string& name) const;
/* The leases a model's name now holds under the name `name:adapter` (the tail a request put
* after the colon). 0 when nothing runs under that suffix and 0 for a model that serves no
* adapter of that name: the Front counts names, and an unasked name has none. */
int64_t adapter_leases(const std::string& name, const std::string& adapter) const;
/* Every model's name, in the order added. */
std::vector<std::string> names() const;
@@ -201,6 +205,11 @@ private:
bool removed = false;
int64_t leases = 0;
int64_t waiting = 0;
/* Leases taken under the name `name:adapter`, keyed by what the request put after the
* colon. The Front knows no adapters -- it counts the name a request asked by, so the
* suffix is just the name's tail. Only lease() fills this in; card reads, health reads
* and broadcast holds name no adapter. */
std::map<std::string, int64_t> adapter_leases;
uint64_t last_used_ns = 0;
uint64_t uses = 0;
uint64_t waits = 0;
@@ -228,7 +237,9 @@ private:
Got lease(const std::string& model, const std::string& path, int64_t wait_ms,
uint64_t* until_ns, Entry** out, std::shared_ptr<void>* held, HttpResponse* refusal,
bool operator_ok);
std::shared_ptr<void> lease_entry(Entry* e);
/* `adapter` is the tail of the requested name after the colon, empty when the request named
* the model itself: the lease then marks no adapter. */
std::shared_ptr<void> lease_entry(Entry* e, const std::string& adapter = "");
std::shared_ptr<void> lease_quiet(Entry* e);
HttpResponse forward(HttpRequest q);
HttpResponse forward_waiting(HttpRequest q, const std::string& model);
+4 -2
View File
@@ -39,8 +39,10 @@ export function Overview() {
// the copies of parked ones. A server that does not say counts the copies alone.
const copies = f.models.reduce((a, m) => a + (m.host_bytes ?? 0), 0)
const hostBytes = f.host?.held_bytes ?? copies
const flight = f.models.reduce((a, m) => a + (m.in_flight ?? 0), 0)
const waiting = f.models.reduce((a, m) => a + (m.waiting ?? 0), 0)
// LoRA children are rows too, and a child's in-flight is part of its parent's: counting both
// twice would make one request look like two active ones. The KPI counts the work, in parents.
const flight = f.models.filter((m) => !m.parent).reduce((a, m) => a + (m.in_flight ?? 0), 0)
const waiting = f.models.filter((m) => !m.parent).reduce((a, m) => a + (m.waiting ?? 0), 0)
const returns = f.models.reduce((a, m) => a + (m.restores ?? 0), 0)
const power = f.cards.reduce((a, c) => a + (fin(c.power_w) ? c.power_w : 0), 0)
const [cv, cu] = bytesParts(onCards)