Archived
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.
This commit is contained in:
1 parent
b4c04b6042
commit
ddcb9c69bb
696 files changed
+120770
-56596
No files matched your search
+14
-4
@@ -19,7 +19,7 @@ extern "C" {
|
||||
* version is refused at load with both versions printed. Each also exports the layout's fingerprint
|
||||
* (rad_abi_layout.h), so two layouts given one number are refused as well. A new optional export
|
||||
* (e.g. rad_plugin_reference) is not a change of shape: a plugin without it gets the default. */
|
||||
#define RAD_ABI_VERSION 37u
|
||||
#define RAD_ABI_VERSION 39u
|
||||
|
||||
/* ================================================================== plugin identity */
|
||||
/* One value per plugin, not flags (QUANT is 3). RAD_PLUGIN_QUANT is a quantiser plugin:
|
||||
@@ -62,8 +62,8 @@ typedef struct RadArgs {
|
||||
int world_size;
|
||||
/* ABI 35: host-side maximum KV length represented by this exact launch operand (a seqused
|
||||
* span or a supported one-sequence prefill boundary), or -1 when it cannot be proven. In a
|
||||
* decode, verify or draft pass of an architecture with no rad_arch_pass_key it is instead the
|
||||
* step's context bound plus its longest query, which the recorded pass's key holds. Plugins
|
||||
* decode, verify or draft pass it is instead the step's context bound plus its longest query,
|
||||
* which the recorded pass's key holds. Plugins
|
||||
* must not infer it from a device pointer or synchronously read device memory to get it. */
|
||||
int32_t kv_used_max_h;
|
||||
/* The current rank's WGP count (HIP multiProcessorCount on RDNA); lets split launchers use
|
||||
@@ -162,7 +162,8 @@ typedef int (*RadLayoutFn)(const RadParam* p, int n_p, int operand, const RadEnc
|
||||
|
||||
/* Write the stored form `layout` described into `dst`, `dst_bytes` long, from the planes, which
|
||||
* now carry their bytes. Pure host code, run by the loader on a pool behind the container read,
|
||||
* so it has to keep pace with the disk. */
|
||||
* so it has to keep pace with the disk. The planes are read only: the loader may hand them
|
||||
* straight out of its read buffer, which the copies for other ranks read at the same time. */
|
||||
typedef int (*RadRelayoutFn)(const RadParam* p, int n_p, int operand, const RadEncoding* enc,
|
||||
const int* sel, const RadTensor* planes, int n_planes, void* dst,
|
||||
int64_t dst_bytes);
|
||||
@@ -515,6 +516,15 @@ const RadKernelInfo* rad_kernel_at(int i);
|
||||
typedef int (*RadPluginOpenFn) (void);
|
||||
typedef void (*RadPluginCloseFn)(void);
|
||||
|
||||
/* Optional, symbol `rad_plugin_freed`. The core has freed the device memory [base, base + bytes)
|
||||
* and nothing launched against it runs any more. A kernel library that keeps state keyed by an
|
||||
* operand's address (a counter block per output buffer, made at the first launch and replayed by
|
||||
* recorded passes) drops what it keeps for addresses inside the range. A process serving several
|
||||
* models frees an engine's memory when it unloads the model, so state kept past that would pile
|
||||
* up with every load. Called from the freeing thread, any number of times, possibly for ranges the
|
||||
* plugin never saw. */
|
||||
typedef void (*RadPluginFreedFn)(const void* base, int64_t bytes);
|
||||
|
||||
/* Optional promise about kernel `i` of rad_kernel_at: nonzero means every launch reads and writes
|
||||
* only its operands and the scratch it was handed (no allocation it keeps, no counter kept between
|
||||
* launches), so two launches may run at once on one device when their operands and scratch do not
|
||||
|
||||
@@ -17,7 +17,7 @@ ABI_FIELD(RadArchProbe, gen_patches)
|
||||
ABI_FIELD(RadArchProbe, gen_audio)
|
||||
ABI_FIELD(RadArchProbe, gen_ctx)
|
||||
ABI_FIELD(RadArchProbe, gen_video)
|
||||
ABI_FIELD(RadArchProbe, kv_quant_ok)
|
||||
ABI_FIELD(RadArchProbe, kv_fp8_ok)
|
||||
ABI_FIELD(RadArchProbe, chain_pays)
|
||||
ABI_FIELD(RadArchProbe, kv_stream_ok)
|
||||
ABI_FIELD(RadArchProbe, control_vector_ok)
|
||||
@@ -130,8 +130,6 @@ ABI_FIELD(RadBuildCtx, max_enc_patches)
|
||||
ABI_FIELD(RadBuildCtx, max_out_rows)
|
||||
ABI_FIELD(RadBuildCtx, max_audio_frames)
|
||||
ABI_FIELD(RadBuildCtx, max_mixed_tok)
|
||||
ABI_FIELD(RadBuildCtx, kv_quant)
|
||||
ABI_FIELD(RadBuildCtx, attn_prefill_fp8)
|
||||
ABI_FIELD(RadBuildCtx, kv_resident_blocks)
|
||||
ABI_FIELD(RadBuildCtx, kv_stream_ok)
|
||||
ABI_FIELD(RadBuildCtx, cvec)
|
||||
@@ -147,6 +145,7 @@ ABI_FIELD(RadBuildCtx, calib_tokens)
|
||||
ABI_FIELD(RadBuildCtx, gen_max_pixels)
|
||||
ABI_FIELD(RadBuildCtx, gen_max_refs)
|
||||
ABI_FIELD(RadBuildCtx, expert_file_tier)
|
||||
ABI_FIELD(RadBuildCtx, slot_base)
|
||||
ABI_STRUCT(RadAudioGenBatch)
|
||||
ABI_FIELD(RadAudioGenBatch, n_lane)
|
||||
ABI_FIELD(RadAudioGenBatch, lane)
|
||||
|
||||
+76
-61
@@ -56,35 +56,27 @@ double rad_meta_getf(const RadModelMeta* m, const char* key, double dflt);
|
||||
const char* rad_meta_gets(const RadModelMeta* m, const char* key, const char* dflt);
|
||||
|
||||
/* ================================================================== build context */
|
||||
/* RadBuildCtx::kv_quant. A layout groups each head's dims by 32 with an f16 scale per group, the
|
||||
* group's absmax over the largest code. A token's row in a head, at head_dim HD (a multiple of 32):
|
||||
/* A paged cache group's dtype says how a token's row in a head is laid out, at head_dim HD:
|
||||
*
|
||||
* RAD_KVQ_V4 (fp8_v4), 25 * HD / 16 bytes:
|
||||
* [0, HD) K, E4M3 as the fp8 cache stores it
|
||||
* [HD, 3HD/2) V's int4 codes, dim d in the nibble at bit 4 * (d % 2) of byte d / 2
|
||||
* [3HD/2, 25HD/16) V's scales (absmax / 7)
|
||||
* RAD_KVQ_K6V4 (k6_v4), 22 * HD / 16 bytes:
|
||||
* [0, HD/2) K's low four bits, as V's codes above
|
||||
* [HD/2, 3HD/4) K's high two bits, a 4-byte word per 16 dims whose byte j holds dims 2j
|
||||
* and 2j+1 in bits 0-3 and dims 8+2j and 9+2j in bits 4-7
|
||||
* [3HD/4, 5HD/4) V's int4 codes
|
||||
* [5HD/4, 21HD/16) K's scales (absmax / 31)
|
||||
* [21HD/16, 22HD/16) V's scales (absmax / 7)
|
||||
*
|
||||
* Codes are two's complement (int4 -7..7, int6 -31..31). The group is declared at RAD_F8E4M3 with
|
||||
* head_dim the row's bytes / 2 so the core sizes pages from it; only the layout's kernels read
|
||||
* it. */
|
||||
enum {
|
||||
RAD_KVQ_NONE = 0,
|
||||
RAD_KVQ_V4 = 1,
|
||||
RAD_KVQ_K6V4 = 2
|
||||
};
|
||||
* RAD_BF16, 4 * HD bytes: K then V, as the model computes them.
|
||||
* RAD_I8, 2 * HD + 4 bytes: K and V as int8 codes with one f16 scale each per (token, head):
|
||||
* [0, HD) K's int8 codes (two's complement, -127..127)
|
||||
* [HD, 2HD) V's int8 codes
|
||||
* [2HD, 2HD + 2) K's scale (the head's absmax / 127)
|
||||
* [2HD + 2, 2HD + 4) V's scale (absmax / 127)
|
||||
* The plugin declares HD; the core adds the scales' bytes (rad_kv_row_elems). */
|
||||
|
||||
/* The products of the prefill attention a deployment accepts in e4m3 (RadBuildCtx::
|
||||
* attn_prefill_fp8, `attn_paged`'s `prefill_fp8`): bits, so both is 3. */
|
||||
/* Elements of a token's row in one head of a paged group declared at `dtype` and `head_dim`: K
|
||||
* then V, and under the int8 cache the two f16 scales after them. */
|
||||
static inline int64_t rad_kv_row_elems(uint32_t dtype, int64_t head_dim) {
|
||||
return 2 * head_dim + (dtype == RAD_I8 ? 4 : 0);
|
||||
}
|
||||
|
||||
/* RadArchProbe::chain_pays. */
|
||||
enum {
|
||||
RAD_ATTN_FP8_QK = 1, /* Q.K^T, the query rounded to e4m3 after the softmax scale */
|
||||
RAD_ATTN_FP8_PV = 2 /* P.V, the probabilities rounded to e4m3 */
|
||||
RAD_CHAIN_NONE = 0,
|
||||
RAD_CHAIN_SPEC = 1, /* with a drafter decoding speculatively */
|
||||
RAD_CHAIN_ALWAYS = 2 /* with or without one */
|
||||
};
|
||||
|
||||
typedef struct RadBuildCtx {
|
||||
@@ -111,17 +103,16 @@ typedef struct RadBuildCtx {
|
||||
int64_t tp_wire_min_bytes;
|
||||
|
||||
|
||||
/* The KV cache dtype, a deployment choice rather than a property of the checkpoint: fp8
|
||||
* weights may want a bf16 cache and vice versa.
|
||||
/* The KV cache dtype, a deployment choice rather than a property of the checkpoint.
|
||||
*
|
||||
* RAD_DT_INVALID (the zero-initialised default) means the plugin's default, bf16 for every
|
||||
* architecture in this tree. RAD_F8E4M3 is the only other implemented value: the fp8kv
|
||||
* attention family is band-gated on it, and the store side writes E4M3 with per-(sequence,
|
||||
* head) descales. `kv_quant` below narrows the trunk's attention cache further.
|
||||
* architecture in this tree. RAD_I8 is the other value every paged attention serves, the
|
||||
* int8 cache above: the attention kernels band on it and the store writes each token's codes
|
||||
* and scales. RAD_F8E4M3 reaches only a plugin whose probe sets RadArchProbe::kv_fp8_ok.
|
||||
*
|
||||
* An ABI field rather than an environment variable because it changes what the model
|
||||
* computes, so it must have one visible answer: --kv-cache-dtype. */
|
||||
int kv_dtype; /* RAD_DT_INVALID = the plugin's default (bf16); or RAD_F8E4M3 */
|
||||
int kv_dtype; /* RAD_DT_INVALID = the plugin's default (bf16); RAD_I8; RAD_F8E4M3 */
|
||||
int is_draft; /* this builder scope is a drafter (spec §10) */
|
||||
const char* scope; /* "", "draft", "vision", "audio" -- prefixes declared names */
|
||||
|
||||
@@ -172,25 +163,6 @@ typedef struct RadBuildCtx {
|
||||
* Trailing and zero-defaulted, so a plugin built against the older struct is unchanged. */
|
||||
int64_t max_mixed_tok;
|
||||
|
||||
/* A narrower layout of the trunk's attention cache under kv_dtype RAD_F8E4M3, from
|
||||
* --kv-cache-dtype fp8_v4 or k6_v4: a RAD_KVQ_* (below). The engine sets it only for a plugin
|
||||
* whose probe has the layout's bit in RadArchProbe::kv_quant_ok and refuses the flag
|
||||
* otherwise, so no plugin sees it that would store plain E4M3 instead. A drafter's cache stays
|
||||
* E4M3.
|
||||
*
|
||||
* Trailing and zero-defaulted, so a plugin built against the older struct is unchanged. */
|
||||
int kv_quant;
|
||||
|
||||
/* ---- appended in ABI 26 (fp8 prefill attention) */
|
||||
/* RAD_ATTN_FP8_* bits from --attn-prefill-fp8: the attention products the deployment accepts
|
||||
* in e4m3 rather than exactly. 0 (the zero-initialised default) is exact. A plugin passes a
|
||||
* nonzero value on as `attn_paged`'s `prefill_fp8` (docs/OPS.md) and omits the parameter at
|
||||
* 0, so an exact declare is unchanged. The engine refuses to start when no resolved kernel
|
||||
* takes it, so a plugin that ignores the field is refused rather than silently exact.
|
||||
*
|
||||
* Zero-defaulted and in the padding after kv_quant, so no other field moves. */
|
||||
int attn_prefill_fp8;
|
||||
|
||||
/* ---- appended in ABI 30 (KV streaming) */
|
||||
/* --kv-resident in tokens, 0 when nothing streams: the ring a streamed group carves is this in
|
||||
* whole blocks, raised to the engine's floors and clamped to the context. A plugin states it as
|
||||
@@ -301,8 +273,24 @@ typedef struct RadBuildCtx {
|
||||
* drive has to be stored whole, so a plugin that can lay its routed experts out either way
|
||||
* keeps them whole for this; 0 leaves it free to split them across the ranks by width. */
|
||||
int expert_file_tier;
|
||||
|
||||
/* ---- appended in ABI 38 (several engines in one process) */
|
||||
/* The first of this engine's slots. Each engine in the process holds a contiguous block of
|
||||
* slots, one per rank, so an instance's slot, `slot_base + rank` (rad_build_slot), is unique
|
||||
* among the ranks of every engine alive, where `rank` is unique only within one engine. A
|
||||
* plugin keeps per-instance state (handles, geometry, its step's view of the model) indexed by
|
||||
* the slot, and reads it back in step() with rad_slot(). Zero, the default, makes the slot the
|
||||
* rank: one engine in a process, or a test driving a plugin alone. Two engines may serve the
|
||||
* same plugin at once only when it says so (rad_arch_multi_instance). */
|
||||
int slot_base;
|
||||
} RadBuildCtx;
|
||||
|
||||
/* The most instances (engine ranks) one process holds at once; every slot is below it. */
|
||||
#define RAD_MAX_SLOTS 32
|
||||
|
||||
/* The declaring instance's slot (see RadBuildCtx::slot_base). */
|
||||
static inline int rad_build_slot(const RadBuildCtx* c) { return c->slot_base + c->rank; }
|
||||
|
||||
/* ================================================================== control vectors */
|
||||
/* A direction per layer, in the shape llama.cpp's `--cvec-mode project` applies it:
|
||||
*
|
||||
@@ -834,6 +822,23 @@ int rad_drafter_shared_kv(RadBuilder* b, int pos_offset);
|
||||
* the drafter's passes (the KL mode drafts nothing, so trees do not apply there). */
|
||||
int rad_drafter_tree(RadBuilder* b, rad_buf parents);
|
||||
|
||||
/* The model's routing counts live in `table`: an i32 RAD_BUF_PERSIST device buffer of at least
|
||||
* [layers, n_expert], one row per layer that reports (rad_route_report's `layer`, so a head past
|
||||
* the trunk counts) and n_expert the model's expert count. Each layer's router writes its counts
|
||||
* into its own row and the report names that row as RadRouting::expert_count; the core takes it
|
||||
* in place and copies the pass's rows to the host once, at the end of the pass. Without a table
|
||||
* the core keeps the rows itself and a report costs one copy dispatch per routed layer on the
|
||||
* compute stream, since a plugin cannot bind the core's rows as operands of a recorded pass. A
|
||||
* report naming any other buffer is still copied, into the layer's row of the table.
|
||||
*
|
||||
* A row per layer also means a consumer that reads a layer's counts later in stream order (the
|
||||
* file stager, at the layer's first expert op) reads that layer's, which one buffer shared by
|
||||
* every layer does not guarantee once a later layer's router has run.
|
||||
*
|
||||
* Called at most once. The row count is checked when a context binds, where the reporting layers
|
||||
* are known. Additive export; RAD_ABI_VERSION does not move. */
|
||||
int rad_route_table(RadBuilder* b, rad_buf table);
|
||||
|
||||
/* Whether this engine's launches chain (RadKernelChainFn, abi/rad_abi.h): the core's decision, on
|
||||
* the AQL backend only, which keeps a completion counter per queue, where the model's plugin
|
||||
* measured a gain with its speculative drafter (RadArchProbe::chain_pays) and that drafter decodes
|
||||
@@ -1593,6 +1598,13 @@ const char* rad_arch_quant(void);
|
||||
* move. */
|
||||
int rad_arch_serves_imports(void);
|
||||
|
||||
/* Nonzero when every piece of per-instance state the plugin keeps is indexed by
|
||||
* rad_build_slot() / rad_slot(), so several engines in one process may run it at once
|
||||
* (docs/MULTIMODEL.md §3.3). Optional: absent or zero, the core runs the plugin for one engine at
|
||||
* a time and refuses a second engine on it by name. arch/common/rad_arch.h writes it with
|
||||
* RAD_ARCH_MULTI_INSTANCE(). */
|
||||
int rad_arch_multi_instance(void);
|
||||
|
||||
/* What the plugin can say before it declares anything. Optional: a plugin that does not export
|
||||
* it answers zero to everything, each field's default.
|
||||
*
|
||||
@@ -1652,17 +1664,18 @@ typedef struct RadArchProbe {
|
||||
* `gen_rows` (its largest pass: a step's packed sequence at the largest size and length). It
|
||||
* keeps no KV. */
|
||||
int32_t gen_video;
|
||||
/* The RadBuildCtx::kv_quant layouts the plugin serves for this model, bit 1 << RAD_KVQ_*:
|
||||
* libr4d has their rows for its attention geometry. A layout whose bit is clear is refused at
|
||||
* startup with the plugin named. */
|
||||
int32_t kv_quant_ok;
|
||||
/* Nonzero when the plugin serves an E4M3 cache for this model (--kv-cache-dtype fp8,
|
||||
* RadBuildCtx::kv_dtype RAD_F8E4M3): GLM-5.3's latent attention. The engine refuses the flag
|
||||
* for a plugin that leaves it zero, naming the int8 cache every paged attention serves. */
|
||||
int32_t kv_fp8_ok;
|
||||
|
||||
/* ---- appended in ABI 26 (chained launches, control vectors) */
|
||||
/* Nonzero when this plugin measured its speculative step faster with chained launches
|
||||
* (RadKernelChainFn: a dependent kernel waits in its own prologue rather than behind the
|
||||
* queue's barrier bit). With a drafter decoding speculatively on the AQL backend, the core
|
||||
* then takes them. Zero keeps them off: plain decode measured slower chained, and a plugin
|
||||
* that never measured them asks for nothing. */
|
||||
/* How this plugin measured chained launches (RadKernelChainFn: a dependent kernel waits in its
|
||||
* own prologue rather than behind the queue's barrier bit), a RAD_CHAIN_*. SPEC: its
|
||||
* speculative step is faster with them, and the core takes them on the AQL backend while a
|
||||
* drafter decodes speculatively. ALWAYS: its plain decode is faster too, and the core takes
|
||||
* them with or without a drafter. Zero keeps them off: some models' plain decode measured
|
||||
* slower chained, and a plugin that never measured them asks for nothing. */
|
||||
int32_t chain_pays;
|
||||
/* ---- appended in ABI 30 (KV streaming) */
|
||||
/* Nonzero when the architecture can stream a KV group between host memory and a VRAM ring: its
|
||||
@@ -1949,7 +1962,9 @@ void rad_arch_step(struct RadCtx* c, const struct RadBatch* batch);
|
||||
/* Optional. Return a stable fingerprint of actual dispatch geometry whose grid depends on live
|
||||
* per-group seqused values. `kv_used_max_h[g]` is the host maximum for batch->kv[g], and
|
||||
* rad_ctx_wgp_count(c) supplies the device's WGP count. Return 0 when exact geometry is unknown;
|
||||
* that pass runs live and is not recorded. */
|
||||
* that pass runs live and is not recorded. Only prefill and mixed launches read the live maximum:
|
||||
* in a decode, verify or draft pass every launch reads the step's keyed context bound
|
||||
* (RadArgs::kv_used_max_h), so such a pass needs no geometry here and returns nonzero. */
|
||||
uint64_t rad_arch_pass_key(struct RadCtx* c, const struct RadBatch* batch,
|
||||
const int32_t* kv_used_max_h);
|
||||
|
||||
|
||||
@@ -936,6 +936,9 @@ int rad_kv_stage_layer(RadCtx* c, rad_kvgroup group, const RadKVGrou
|
||||
int layer);
|
||||
int rad_kv_stage_next(RadCtx* c, rad_kvgroup group, int layer);
|
||||
int rad_rank(RadCtx* c);
|
||||
/* The instance's slot, rad_build_slot() of the declare that built it: what a plugin indexes its
|
||||
* per-instance state by. */
|
||||
int rad_slot(RadCtx* c);
|
||||
int rad_world_size(RadCtx* c);
|
||||
/* Workgroups the current rank's card can run concurrently (HIP multiProcessorCount on RDNA;
|
||||
* 32 on the host backend or when the backend has no positive count). */
|
||||
|
||||
Reference in new issue
Block a user