This repository has been archived on 2026-11-24. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
radiance-sycl/core/fleet/broker.h
T
Deadcode ddcb9c69bb radiance 2.0.0
Radiance becomes a multi-model engine: one process serves several models behind one port, loads
each when a request names it, parks it in host memory or restores it from its container, and
shares the cards between them (docs/MULTIMODEL.md). The configuration is one YAML file; the
command line flags are gone (`radiance --config FILE`, hot reload on SIGHUP).

Formats. IQ8R (rotated int8) and IQR-V4 replace FP8 and MXFP4 as whole-model formats, with an
int8 KV cache (`kv-cache-dtype: i8`) in place of the fp8 one. Containers whose weights are block
FP8, MXFP4, M2XFP4, NVFP4 or ParoQuant are refused at startup by the name of the first such
weight. Not served until they have int8 containers: GLM-5.3-Flash, Ornith-1.5, Sage-A1.5,
Nemotron-3.5-Bolt-74B, Ling-3.0-flash, drama-3 and Anima's FP8 container; Nemotron-3.5-Bolt-E4B,
the Gemma 4 31B DFlash containers and MiniCPM5-2B bf16 serve without their drafter. 1.17.0
serves all of them.

Speed. Chained launches for Qwen3.8-27B, Gemma 4, Gemma 3 and the small bf16 models, a new
Qwen3.8-Flash-Next container (IQR-V4 experts, int8 trunk) with its decode step and prefill
reworked, and a reworked adaptive draft window.

Deployment. deploy/compose has two fleet files, tp1.yaml and tp2.yaml, each with its
configuration beside it, in place of the per-model files. `host-pool-mib` is a model's host pool
in all, split among its ranks. The dashboard is rebuilt: an hour of history kept by the server,
each accelerator's memory by model, model states over time.

Merged since 1.17.0: Nemotron-3.5-Bolt-74B-A9B by keptn42 (#339); GLM-5.3-Flash on four cards by
AnimusNull (#397); chained launches for Flash-Next's decode step (#396) and preempted requests
keeping their prefix and place (#405) by mici81; --prefill-interleave auto by Code000 (#410);
eight more libr3d kernels and the w4a4 reference by RikshaDriver (#403, #407, #408); libr3d
large-BAR and E4M3 decode fixes by neuromanMD (#438, #439); int4/int5 decode tiles by Kezi
(#426); attention for Nanbeige 4.3 33B by everplays (#417); expert_stats_report.py by baKon
(#431). Fixed: #398, #402, #419, #437 (dschmitz's patch); added the metrics of #392, and
multi-model serving as asked for in #367 and #109.

Plugin ABI 39: out-of-tree plugins need to be rebuilt.

Thanks to @keptn42, @AnimusNull, @mici81, @Code000, @RikshaDriver, @neuromanMD, @Kezi, @everplays, @baKon and @dschmitz.
2026-11-14 22:32:28 +01:00

75 lines
4.3 KiB
C++

/* fleet/broker.h -- how an engine asks the fleet for its part of the cards (docs/MULTIMODEL.md §6.3).
*
* An engine in a fleet of several models does not split a card by itself: the other models hold
* part of it, and the fleet decides who leaves to make room. Once declare has told the engine what
* it costs, the engine asks its broker for a claim between what it cannot start without and what it
* could use at most; the broker makes room (evicting by the fleet's policy) and grants a claim, and
* the engine splits that claim as a one-model process splits its card (Config::vram_claim).
*/
#pragma once
#include <cstdint>
#include <string>
#include <vector>
namespace rad {
struct VramAsk {
std::vector<int> cards; /* the engine's cards, rank i on cards[i]; the claim is per card */
int64_t need = 0; /* the fixed part: weights, arena, queues, one full-length context */
int64_t want = 0; /* the most the engine can use: every expert, the cache's ceiling */
/* The cache's terms, so a broker can price a token count: kv_fixed is state no context uses,
* (kv_ceiling - kv_fixed) pages max_seqs x max_ctx tokens, and kv_one is the cache's part of
* `need` (kv_fixed and the pages of one full-length context). */
int64_t kv_fixed = 0;
int64_t kv_ceiling = 0;
int64_t kv_one = 0;
int64_t max_tokens = 0; /* max_seqs x max_ctx */
int64_t experts = 0; /* the whole expert plane, 0 for a dense model */
int64_t expert_floor = 0; /* the experts the host pool cannot hold */
};
class VramBroker {
public:
virtual ~VramBroker() = default;
/* Grants a claim per card of at least `ask.need`, blocking until it is free on every card of
* the ask. The claim is at most `want` unless the model's configuration fixes it. RAD_OK with
* *grant set, or an error with *why naming what is in the way (models that may not leave, a
* card too small). */
virtual int grant(const VramAsk& ask, int64_t* grant, std::string* why) = 0;
/* Room for `bytes` of host memory the engine will pin beyond the pools the fleet already counted
* (the tables placed in host memory), made and waited for as for a load's pools, and counted
* from here until the load ends. False when it cannot be had, and nothing is counted. */
virtual bool host_room(int64_t bytes) { (void)bytes; return true; }
/* All that is counted for this load, about to be pinned, once more. It was there when counted,
* and the load may have waited minutes for its VRAM since. False when it cannot be had: pinning
* anyway gets the process killed by the kernel. */
virtual bool host_pools_room() { return true; }
/* Host memory this engine must leave free beside what it pins: the host's floor and what other
* loads have counted on and not pinned yet. */
virtual int64_t host_margin() { return 0; }
/* ---- flex (docs/MULTIMODEL.md §6). A granted engine's cache may grow past its claim into
* memory no model holds, and gives it back when the fleet needs it. */
/* For the engine being granted: the most tokens its cache may grow to, 0 for none (it stays at
* its claim), -1 for its ceiling. */
virtual int64_t flex_kv_max_tokens() { return 0; }
/* May `bytes` more be backed on each of `cards` now? Never evicts and never blocks; refused
* while the fleet is making room for a load. From an engine's step loop. */
virtual bool flex_grow(const std::vector<int>& cards, int64_t bytes) {
(void)cards; (void)bytes; return false;
}
/* After every flex_grow that said yes, once the engine has backed the bytes or given up: a load
* or restore starting meanwhile waits for granted growth to land before it reads the cards'
* free memory, or it would plan room that the growth then takes. */
virtual void flex_done() {}
/* The bytes a cache on `cards` could still grow by now, for admission (KVManager::set_flex_room). */
virtual int64_t flex_room(const std::vector<int>& cards) { (void)cards; return 0; }
/* For the engine being granted: the most VRAM its experts may take on a card, the claim's
* share included, as its slab grows into memory no model holds (docs/MULTIMODEL.md §6.7); 0
* for no growth, -1 for every expert it keeps in host memory. */
virtual int64_t flex_experts_max_bytes() { return 0; }
};
} // namespace rad