Archived
radiance 1.13.0
New models: - Tencent Hy-Memory (HYV3) from its BF16, FP8 and GGUF checkpoints, with its native tool calls - M2XFP4: metadata-augmented MXFP4 weights for Qwen3.8-27B and its DFlash2 drafter (top-1 89.1% -> 92.4% against plain MXFP4), its quantiser and recipe, and ParoQuant's M2XFP4 checkpoints - Gemma 4 E2B/E4B audio input; NVIDIA-Nemotron-3.5-Bolt-E4B in int8 and 4-bit, on two cards by default; Ornith-1.5-122B compose files Speed: - Weight reads beside the decode all-reduces (qwen35_fp8, gemma3; --weight-prefetch, on by default): the 27B MXFP4 with DFlash2 61.2 -> 67.9 tok/s at c1, TranslateGemma 27B +13% - Head-256 split-KV decode attention at 256 workgroups and without bank conflicts (27B: +3-5% a step at 25-41K context), and the prefill KV split for small launches (a short turn over a long context decodes the other sequences 27% faster in that step) - MXFP4 decode gate_up, activation and fp8 quantiser in one launch (27B, Gemma 3 up to 64 rows: TranslateGemma +2-5% at 2-8 streams) - ParoQuant int4/int5 tiled GEMMs 6-9% faster - Speculation: a step's tokens are sent before the drafter's passes end, no step waits behind one that ends its requests, and the MTP head's first draft no longer collapses after short chats in the prefix cache Features: - --kv-resident N: KV streaming for a context bigger than VRAM (qwen4exp_fp8, GLM-5.3) - MiniMax-H3: reference media and keyframe conditioning with the VAE encoders - Krea 2 rebalance presets balanced, detail and subtle - The dashboard's request history; a stall watch that reports a frozen step's thread and stack - rad-tune at the served configuration, collectives measured as the exchange; Gemma 4 E2B/E4B's per-layer embeddings read ahead off the step path - A GPTQ calibration tap and recipe for Gemma 4 31B's w4a8 container Fixes: - The two-rank all-reduce checks that a peer's push has landed before reducing it - z-lab's DFlash drafter on Gemma 4 31B keeps drafting after a prefix-cache hit - MiniMax-H3's modulation rows Changes: Plugin ABI 31: out-of-tree plugins must be rebuilt. RADIANCE_PREFETCH_BESIDE is --weight-prefetch now; RADIANCE_NO_HUGE_PAGES, RADIANCE_IDS_EARLY, RADIANCE_ATTN_BAND_SPLIT, R4D_PREFILL_SPLITS, RAD_PLE_TIMING and RAD_PLE_CACHE_ROWS are gone.
This commit is contained in:
commit
6645337f69
198 files changed
+20904
-3240
No files matched your search
+2
-39
@@ -16,45 +16,8 @@ extern "C" {
|
||||
* rad_builder.h, rad_runtime.h, rad_device.h, rad_encoding.h, rad_quant.h, rad_sample.h or
|
||||
* rad_spechub.h. Every kind of plugin reports it, and a plugin that does not report exactly this
|
||||
* version is refused at load with both versions printed. A new optional export (e.g.
|
||||
* rad_plugin_reference) is not a
|
||||
* change of shape: a plugin without it gets the default.
|
||||
*
|
||||
* 26: RadKVGroupBatch grows one trailing, zero-defaulted field (`stream`, a RadKVStream) so a
|
||||
* plugin can see a streamed KV group's ring, residency map and host mirror, and RadBuildCtx grows
|
||||
* `kv_resident_blocks` and `kv_stream_ok` (--kv-resident and the architecture's capability). Every
|
||||
* earlier field keeps its offset, but the structs are larger, so out-of-tree plugins must be
|
||||
* rebuilt against 26.
|
||||
*
|
||||
* 27: RadBuildCtx grows `cvec`, a rank's control-vector direction table (control vectors). Trailing
|
||||
* and zero-defaulted as above, so a plugin built against 26 keeps every offset.
|
||||
*
|
||||
* 28: RadArchProbe grows two trailing, zero-defaulted fields that met in the same merge:
|
||||
* `chain_pays` (the plugin measured its speculative step faster with chained launches) and
|
||||
* `kv_stream_ok` (the architecture can move a KV group between host memory and a resident ring).
|
||||
* Both are additions a 27 plugin never reads; a plugin that does set them must be built against
|
||||
* 28, since 27's struct ends where these begin.
|
||||
*
|
||||
* 29: radiance 1.11.0's Unlimited-OCR and control-vector work meets KV streaming. RadBuildCtx
|
||||
* grows `attn_prefill_fp8` (--attn-prefill-fp8, the prefill attention's products accepted in
|
||||
* e4m3); it fills the four padding bytes ABI 28 already had after `kv_quant`, so no field moves.
|
||||
* RadArchProbe grows `control_vector_ok` after ABI 28's `kv_stream_ok`: upstream 1.11.0 had it at
|
||||
* the offset `kv_stream_ok` took in 28, so it moves to 80 and the struct grows, which is why this
|
||||
* is a bump. Both trailing fields are zero-defaulted, but a plugin that sets either must be built
|
||||
* against 29.
|
||||
*
|
||||
* 30: radiance 1.12.0 meets KV streaming. Upstream spent 27 on its own additions and this tree had
|
||||
* already spent it, so the merge takes the next number for both: upstream's `RadBuildCtx` grows
|
||||
* `tp_attn_rows`, `state_dtype` (--state-cache-dtype f16) and `draft_coupling`, and gains
|
||||
* `rad_lane1_window_begin/end` and `rad_drafter_short_block`; `RadArchProbe` grows
|
||||
* `tp_attn_rows_ok` and `state_f16_ok`; `RadAudioGenBatch` grows `prev_slot`/`prev_pos`/
|
||||
* `prev_used` and the reference prompt's `n_ref`/`ref_samples`/`ref_audio`/`ref_cu`/`ref_cu_h`/
|
||||
* `ref_frame`/`ref_frame_h`; `RadAudioGenDecl` grows `branches`, `input_special` and the
|
||||
* `tmpl_ref`/`ref_*` reference template; and the plugin ABI gains `rad_spechub.h` (a whole new
|
||||
* header) with the per-row `rad_kernel_reference` override. Every upstream field is trailing and
|
||||
* zero-defaulted, and `RadKVStream` loses our never-read `scratch` (80 -> 72 bytes), so a plugin
|
||||
* built against 26-29 keeps the offsets it reads only if it is rebuilt; the loss of a middle
|
||||
* pointer in `RadKVStream` is why this is a bump even before upstream's additions. */
|
||||
#define RAD_ABI_VERSION 30u
|
||||
* rad_plugin_reference) is not a change of shape: a plugin without it gets the default. */
|
||||
#define RAD_ABI_VERSION 31u
|
||||
|
||||
/* ================================================================== plugin identity */
|
||||
/* One value per plugin, not flags (QUANT is 3). RAD_PLUGIN_QUANT is a quantiser plugin:
|
||||
|
||||
+92
-5
@@ -188,11 +188,20 @@ typedef struct RadBuildCtx {
|
||||
* 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 and a plugin built
|
||||
* against the older struct is unchanged. */
|
||||
* Zero-defaulted and in the padding after kv_quant, so no other field moves. */
|
||||
int attn_prefill_fp8;
|
||||
|
||||
/* ---- appended in ABI 26 (control vectors) */
|
||||
/* ---- 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
|
||||
* its `kv_resolve`'s ring depth. */
|
||||
int64_t kv_resident_blocks;
|
||||
/* RadArchProbe::kv_stream_ok. The streamed-only ops (`kv_store_streamed`, its folded form,
|
||||
* `kv_resolve`) are declared only when this is set and kv_resident_blocks asks for a ring;
|
||||
* otherwise rad_op_declared says no and the plugin takes its resident path. */
|
||||
int kv_stream_ok;
|
||||
|
||||
/* ---- appended in ABI 27 (control vectors) */
|
||||
/* A control vector loaded from a GGUF `controlvector` file found for this model, or null.
|
||||
*
|
||||
* The engine loads and validates it once, at bringup, and the plugin only reads it: the
|
||||
@@ -240,6 +249,17 @@ typedef struct RadBuildCtx {
|
||||
*
|
||||
* Trailing and zero-defaulted, so a plugin built against the older struct is unchanged. */
|
||||
int draft_coupling;
|
||||
|
||||
/* ---- appended in ABI 28 (weight prefetch) */
|
||||
/* Nonzero from --weight-prefetch off: the plugin declares none of its weight prefetches, the
|
||||
* reads of a following GEMM's weight beside a collective (arch/common/rad_arch.h
|
||||
* prefetch_beside). An engine that shares its cards with another server sets it: where the
|
||||
* read goes on the second lane, the two servers hold more compute queues than a card has
|
||||
* slots, and the join from the first lane puts a queue switch into every decode step. 0, the
|
||||
* zero-initialised default, prefetches where the plugin does.
|
||||
*
|
||||
* Trailing and zero-defaulted, so a plugin built against the older struct is unchanged. */
|
||||
int weight_prefetch_off;
|
||||
} RadBuildCtx;
|
||||
|
||||
/* ================================================================== control vectors */
|
||||
@@ -428,6 +448,10 @@ typedef struct RadKVGroupDecl {
|
||||
rad_kvgroup rad_decl_kv_group(RadBuilder* b, const char* name, const RadKVGroupDecl* d);
|
||||
/* Valid only after the op that reads this group has been declared. 0 before that. */
|
||||
int64_t rad_kv_block_size(RadBuilder* b, rad_kvgroup g);
|
||||
/* Bytes one block of one layer of a paged group occupies: its pool slot's pitch and its host
|
||||
* mirror row's. 0 for a group that is not paged, or before the block size is known. Additive
|
||||
* export. */
|
||||
int64_t rad_kv_layer_bytes(RadBuilder* b, rad_kvgroup g);
|
||||
|
||||
/* Bind a layer to a group, so the block manager knows how many state instances a sequence owns. */
|
||||
int rad_bind_layer_kv(RadBuilder* b, int layer, rad_kvgroup g);
|
||||
@@ -526,9 +550,16 @@ int rad_kv_group_zero(RadBuilder* b, rad_kvgroup g);
|
||||
* rank computes whole, an indexer's key cache every rank pools into); the engine moves bytes and
|
||||
* cannot know. RADIANCE_DEBUG_TIER_VERIFY checks the claim: each follower hashes what it would
|
||||
* have written and the leader compares. Paged groups only, and never a group this rank declared
|
||||
* zero. No effect at one rank. Additive export; RAD_ABI_VERSION does not move. */
|
||||
* zero. No effect at one rank, and none on a group that streams, whose host mirror is its tier.
|
||||
* Additive export. */
|
||||
int rad_kv_group_replicated(RadBuilder* b, rad_kvgroup g);
|
||||
|
||||
/* The group is read over its whole history every decode step (an indexer's block keys), so it
|
||||
* cannot stream. While a sibling group streams, its carve holds every sequence's full context
|
||||
* rather than the split's share, as the sibling's host mirror holds --max-num-seqs sequences.
|
||||
* Additive export. */
|
||||
int rad_kv_group_dense_read(RadBuilder* b, rad_kvgroup g);
|
||||
|
||||
#define RAD_BUFS(...) ((const rad_buf[]){ __VA_ARGS__ }), \
|
||||
(int)(sizeof((const rad_buf[]){ __VA_ARGS__ }) / sizeof(rad_buf))
|
||||
|
||||
@@ -1206,9 +1237,24 @@ int rad_declare_audio_generator(RadBuilder* b, const RadAudioGenDecl* d);
|
||||
* pass carries the geometry its latent has at that point: a step before the VUPSCALE pass is at
|
||||
* W' x H'. The schedule is the request's own, whatever size each evaluation runs at.
|
||||
*
|
||||
* Reference conditioning, for a plugin with the VAE encoders (`max_enc_side`, `max_enc_samples`,
|
||||
* below): before the prompt pass each of a request's reference media and keyframes is encoded,
|
||||
* one a pass, into the lane, where the steps read it. Nothing an encode makes is read back.
|
||||
*
|
||||
* RAD_GEN_PASS_VENCODE one picture or video, its frames in `enc_pixels` (RadVideoGenBatch),
|
||||
* through the video VAE's encoder.
|
||||
* RAD_GEN_PASS_AENCODE one soundtrack, its samples in `enc_samples`, through the audio VAE's
|
||||
* encoder.
|
||||
*
|
||||
* `enc_kind` (RAD_ENC_*, rad_runtime.h) and `enc_slot`, the media's 1-based number within its kind,
|
||||
* say where the latents go. The media's shape is the plugin's to accept: rad_arch_encode_geom
|
||||
* (below) refuses what the encoders cannot take, and the step's packed sequence with the encoded
|
||||
* media in it is the plugin's rad_arch_video_pack.
|
||||
*
|
||||
* A program declares exactly one of this, the other generators, logits or pooled vectors. */
|
||||
enum { RAD_GEN_PASS_VCOND = 8, RAD_GEN_PASS_VSTEP = 9, RAD_GEN_PASS_ADECODE = 10,
|
||||
RAD_GEN_PASS_VDECODE = 11, RAD_GEN_PASS_VUPSCALE = 12 };
|
||||
RAD_GEN_PASS_VDECODE = 11, RAD_GEN_PASS_VUPSCALE = 12,
|
||||
RAD_GEN_PASS_VENCODE = 13, RAD_GEN_PASS_AENCODE = 14 };
|
||||
|
||||
typedef struct RadVideoGenDecl {
|
||||
const char* name; /* "minimax-h3" -- the served model id and messages */
|
||||
@@ -1326,6 +1372,20 @@ typedef struct RadVideoGenDecl {
|
||||
* Null: one decoder. */
|
||||
const char* decoders;
|
||||
const int64_t* decoder_max_area;
|
||||
|
||||
/* ---- appended in ABI 31 (MiniMax-H3 reference conditioning, above) */
|
||||
/* The reference media a request may carry: pictures, videos (each with an optional soundtrack
|
||||
* of its own) and standalone soundtracks. 0 for none of a kind; a plugin that declares any
|
||||
* exports rad_arch_video_pack. */
|
||||
int64_t max_ref_images, max_ref_videos, max_ref_audios;
|
||||
/* What one encode pass carries: a video's frames after rad_arch_encode_geom pads them to whole
|
||||
* clips, a frame's longer side and a soundtrack's samples. `max_enc_side` 0: no video encoder,
|
||||
* `max_enc_samples` 0: no audio encoder. A picture's sides are multiples of `enc_ratio`. */
|
||||
int64_t max_enc_frames, max_enc_side, max_enc_samples;
|
||||
int32_t enc_ratio;
|
||||
/* The distinct modulations a step's groups may read (rad_arch_video_pack's `mod`, the highest
|
||||
* cell + 1); a request needing more is refused at submit. 0: no limit. */
|
||||
int32_t max_mod_cells;
|
||||
} RadVideoGenDecl;
|
||||
|
||||
int rad_declare_video_generator(RadBuilder* b, const RadVideoGenDecl* d);
|
||||
@@ -1429,6 +1489,12 @@ typedef struct RadArchProbe {
|
||||
* then takes them. Zero keeps them off: 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
|
||||
* attention is sparse and block-addressed and it declares a streamed store and `kv_resolve`.
|
||||
* --kv-resident on an architecture that says 0 is turned off at startup, and nothing streamed
|
||||
* is declared (RadBuildCtx::kv_stream_ok). */
|
||||
int32_t kv_stream_ok;
|
||||
/* Nonzero when the plugin applies RadBuildCtx::cvec for this model. --control-vector is
|
||||
* refused at startup with the plugin named when this is 0. */
|
||||
int32_t control_vector_ok;
|
||||
@@ -1646,6 +1712,27 @@ typedef struct RadVideoGeom {
|
||||
enum { RAD_VPOS_STEP = 1, RAD_VPOS_DECODE = 2 };
|
||||
int64_t rad_arch_video_positions(int which, const RadVideoGeom* g, float* pos, int64_t cap);
|
||||
|
||||
/* The geometry of an encode pass (RAD_GEN_PASS_VENCODE, RAD_GEN_PASS_AENCODE): the int32s the
|
||||
* driver stages verbatim in RadVideoGenBatch::enc_geom_d for the plugin's kernels. `kind` is the
|
||||
* pass; `in` is {frames or samples, height, width, channels}, 0 where unused. With `out` null it
|
||||
* returns the count, with `out` it fills out[cap]; negative for media the encoders cannot take.
|
||||
* Entry 0 of an Aencode geometry is the samples padded to the encoder's hop, entry 23 of a Vencode
|
||||
* geometry the frames padded to whole clips and entry 24 its latent frames: the driver stages the
|
||||
* media padded to those lengths. A plugin with encoders exports it. Called on any thread. */
|
||||
int64_t rad_arch_encode_geom(int32_t kind, const int64_t* in, int32_t* out, int64_t cap);
|
||||
|
||||
/* The packed sequence of a step with reference media or keyframes in: `ref_tab` is
|
||||
* RadVideoGenBatch::ref_tab. Returns the sequence's rows, the rows RAD_VPOS_STEP would position, or
|
||||
* a negative status. `seg` receives the segment boundaries (seg[0] = 0, the last the rows) and
|
||||
* `mod` the boundaries of the modulation groups, then the cell each group reads (groups that read
|
||||
* the same modulation share a cell, numbered from 0); `*n_seg` and `*n_mod` are their capacities
|
||||
* in and their counts out, and a null array asks for the count alone. `pos` receives the rotary
|
||||
* positions, f32 [3, rows], when `cap_pos` holds 3 x rows. A plugin that declares reference media
|
||||
* exports it. Called on any thread. */
|
||||
int64_t rad_arch_video_pack(const RadVideoGeom* g, const int32_t* ref_tab, int32_t* seg,
|
||||
int32_t* n_seg, int32_t* mod, int32_t* n_mod, float* pos,
|
||||
int64_t cap_pos);
|
||||
|
||||
int rad_arch_declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* ctx);
|
||||
/* Forward declaration; the signature is in rad_runtime.h. */
|
||||
struct RadCtx;
|
||||
|
||||
+3
-4
@@ -42,10 +42,9 @@ int rad_dev_count(void);
|
||||
int rad_dev_set(int device);
|
||||
int rad_dev_props(int device, RadDeviceProps* out);
|
||||
int rad_dev_enable_peer(int self, int peer);
|
||||
/* Whether the driver reports that `self` can reach `peer`'s memory, 1 or 0, asked before anything
|
||||
* is enabled: this is the fact collectives constrain (rad_types.h's RAD_FACT_P2P), so a tool that
|
||||
* declares a multi-rank graph must measure it and set the fact as Engine does. Negative on a
|
||||
* device error. */
|
||||
/* 1 when the driver reports that `self` can reach `peer`'s memory, 0 when not, negative on a
|
||||
* device error. A tool that declares a multi-rank graph sets the device.p2p fact from it, as the
|
||||
* engine does (RAD_FACT_P2P). */
|
||||
int rad_dev_peer_access(int self, int peer);
|
||||
|
||||
void* rad_dev_alloc(int64_t bytes, int kind);
|
||||
|
||||
+84
-53
@@ -23,52 +23,34 @@ typedef struct RadCtx RadCtx;
|
||||
enum { RAD_PHASE_PREFILL = 0, RAD_PHASE_DECODE = 1, RAD_PHASE_MIXED = 2 };
|
||||
|
||||
/* ================================================================== KV streaming */
|
||||
/* A streamed KV group keeps its whole context in pinned host memory and only a ring of blocks on
|
||||
* the card (docs/KV-STREAMING.md §3.2, §3.6, §4.2). The step batch carries this view of that
|
||||
* group; a group whose KV is fully resident has none.
|
||||
/* A streamed KV group keeps its whole context in pinned host memory and a ring of blocks on the
|
||||
* card (docs/KV-STREAMING.md). The step batch points every group that streams at this view, which
|
||||
* is fixed from bring-up (so a recorded pass replays a resolve); a resident group's is null.
|
||||
*
|
||||
* Why one pointer to a struct rather than fields inside RadKVGroupBatch: the data is per group
|
||||
* and fixed at bring-up, while the batch is rebuilt per step for every rank, so copying its
|
||||
* pointers and geometry per group into every step's batch would be work that never changes. One
|
||||
* trailing pointer also keeps a group's own layout as it was for every plugin that does not
|
||||
* stream: the field is zero-defaulted, and a null `stream` means the group is fully resident and
|
||||
* has no ring, no map and no host copy.
|
||||
*
|
||||
* The layout mirrors the pool, layer by layer: a layer's mirror is a dense run of `blocks` rows
|
||||
* of `block_bytes`, and `host_layer_stride` is `blocks * block_bytes`. So layer l's row for block
|
||||
* b is at `host + l * host_layer_stride + b * block_bytes`, and `block_bytes` is both the row
|
||||
* pitch `kv_resolve` reads the mirror at and the length of every copy into the ring.
|
||||
*
|
||||
* `res`, `slot_block`, `slot_state` and `ctl` are device memory: a resolve launch reads and
|
||||
* rewrites them every step, so a host round trip per lookup would cost the link latency the ring
|
||||
* exists to avoid. Nothing here changes address for the engine's life, which is what lets a
|
||||
* recorded pass replay a resolve. */
|
||||
* The mirror is laid out like the pool, layer by layer: layer l's row for block b is at
|
||||
* `host + l * host_layer_stride + b * block_bytes`. `res`, `slot_block`, `slot_state` and `ctl`
|
||||
* are device memory, read and rewritten by every resolve launch. */
|
||||
typedef struct RadKVStream {
|
||||
/* The group's mirror, pinned host memory, RAD_MEM_HOST_MAPPED so a device kernel reads it over
|
||||
* the link in place. `blocks * bytes_per_block` bytes, all layers, zeroed at bring-up: a block
|
||||
* no store has written yet reads as zeros rather than as whatever the page held. */
|
||||
/* The mirror: pinned host memory a kernel reads over the link in place, every layer, zeroed at
|
||||
* bring-up. */
|
||||
uint8_t* host;
|
||||
/* Residency, both directions, ONE SLICE A LAYER: `res` is block -> ring slot or -1 (device,
|
||||
* `n_layers * blocks` entries, layer l at `res + l * blocks`), `slot_block` is slot -> block or
|
||||
* -1 (`n_layers * slots`), `slot_state` is `n_layers * slots * 2`: the epoch of a slot's last
|
||||
* use and its CLOCK reference bit. A block is resident per layer because the resolve copies one
|
||||
* layer's bytes; a group-wide map would call a block resident for a layer that was never
|
||||
* copied. `ctl` is shared: its counters and overflow latch are the group's. */
|
||||
/* Residency, one slice a layer: `res` is block -> ring slot or -1 (layer l at `res + l *
|
||||
* blocks`), `slot_block` is slot -> block or -1, `slot_state` is [slots, 2]: the epoch of a
|
||||
* slot's last use and its CLOCK reference bit. Per layer, because the resolve copies one
|
||||
* layer's bytes. */
|
||||
int32_t* res;
|
||||
int32_t* slot_block;
|
||||
int32_t* slot_state;
|
||||
/* The control block: epoch, clock hand, the last launch's miss count, the overflow latch, and
|
||||
* the cumulative misses/lookups/calls counters (docs/OPS.md "kv_resolve"). */
|
||||
/* The group's control block: epoch, clock hand, the last launch's miss count, the overflow
|
||||
* latch and cumulative counters (docs/OPS.md "kv_resolve"). */
|
||||
int32_t* ctl;
|
||||
/* Bytes one block of ONE layer occupies: the mirror's row pitch and the ring's slot pitch. */
|
||||
/* Bytes one block of one layer occupies: the mirror's row pitch and the ring's slot pitch. */
|
||||
int64_t block_bytes;
|
||||
/* Bytes one layer of the mirror occupies, i.e. the distance between layer l and layer l+1. */
|
||||
/* Bytes between one layer's mirror and the next. */
|
||||
int64_t host_layer_stride;
|
||||
/* Ring depth in blocks: the group's device pool is `slots` blocks deep while a selection names
|
||||
* block ids over the group's whole context. */
|
||||
/* The ring's depth in blocks; a selection names block ids over the whole context. */
|
||||
int64_t slots;
|
||||
/* Bytes the host mirror occupies, all layers (`blocks * block_bytes * n_layers`), so a caller
|
||||
* that only has this view can report or check the off-card tier. */
|
||||
/* The whole mirror's bytes, every layer. */
|
||||
int64_t host_bytes;
|
||||
} RadKVStream;
|
||||
|
||||
@@ -86,9 +68,7 @@ typedef struct RadKVGroupBatch {
|
||||
int64_t state_index_pitch;
|
||||
int64_t block_size;
|
||||
int64_t max_blocks;
|
||||
/* Null unless this group's KV streams: the mirror, the residency map and the ring's geometry
|
||||
* (RadKVStream above). Trailing and zero-defaulted, so a plugin built against ABI 25 reads
|
||||
* every field it knows at the same offset and simply never sees the ring. */
|
||||
/* Null unless this group streams (RadKVStream). Trailing and zero-defaulted. */
|
||||
const RadKVStream* stream;
|
||||
} RadKVGroupBatch;
|
||||
|
||||
@@ -593,8 +573,11 @@ enum {
|
||||
* ADECODE no rows of the pass's own.
|
||||
* VDECODE `dec_rows` rows of the decoder's own (rad_arch_video_positions, RAD_VPOS_DECODE).
|
||||
* VUPSCALE no rows of the pass's own: the lane's video latent from `geom_from` to `geom`.
|
||||
* VENCODE no rows of the pass's own: a picture's or a video's frames in `enc_pixels`.
|
||||
* AENCODE no rows of the pass's own: a soundtrack's samples in `enc_samples`.
|
||||
*
|
||||
* Every pointer is device memory unless the name ends in _h. */
|
||||
|
||||
typedef struct RadVideoGenBatch {
|
||||
int32_t lane;
|
||||
RadVideoGeom geom; /* the request's geometry */
|
||||
@@ -603,9 +586,10 @@ typedef struct RadVideoGenBatch {
|
||||
/* The same lane, i32 [1], and 1 on a request's first step (0 otherwise), i32 [1]. */
|
||||
const int32_t* lane_d;
|
||||
const int32_t* first_d;
|
||||
/* i32 [4]: the packed sequence's segments, {0, n_text, n_text + audio rows, n_tok} -- text,
|
||||
* soundtrack, video -- and i32 [4] {0, video rows, 0, audio rows}, the bounds of the lane's two
|
||||
* latents counted from each one's first row. */
|
||||
/* i32: the packed sequence's segment boundaries, {0, n_text, n_text + audio rows, n_tok} --
|
||||
* text, soundtrack, video -- or rad_arch_video_pack's for a request with references; and i32
|
||||
* [4] {0, video rows, 0, audio rows}, the bounds of the lane's two latents counted from each
|
||||
* one's first row. */
|
||||
const int32_t* seg_cu;
|
||||
const int32_t* lat_cu;
|
||||
|
||||
@@ -616,7 +600,8 @@ typedef struct RadVideoGenBatch {
|
||||
|
||||
/* ---- VSTEP */
|
||||
int32_t step; /* from 0; the first draws the lane's noise */
|
||||
/* f32 [6]: the video's timestep, sigma and next sigma, then the soundtrack's. */
|
||||
/* f32 [16]: the video's timestep, sigma and next sigma, then the soundtrack's; from [6] the
|
||||
* res_multistep scalars of the video, then of the soundtrack (`sampler`, below). */
|
||||
const float* sched;
|
||||
const float* pos; /* f32 [3, n_tok]: RAD_VPOS_STEP */
|
||||
/* u32 [2, 2]: the video's noise seed and the soundtrack's, low word first (VSTEP, VUPSCALE and
|
||||
@@ -656,8 +641,55 @@ typedef struct RadVideoGenBatch {
|
||||
/* VDECODE: the decoder the request named (RadVideoGenDecl::decoders), its index; 0 the
|
||||
* default. */
|
||||
int32_t decoder;
|
||||
|
||||
/* ---- appended in ABI 31 (rad_builder.h, "Reference conditioning") */
|
||||
/* The sampler a VSTEP advances the latents with: RAD_SAMPLER_EULER, the first-order step on
|
||||
* sched[0..5], or RAD_SAMPLER_RES_MULTISTEP, the second-order one on the clean estimate
|
||||
* (k-diffusion's res_multistep at eta 0), which keeps the previous step's estimate. Its scalars
|
||||
* are sched[6..10] for the video and sched[11..15] for the soundtrack: sigma, r = next sigma /
|
||||
* sigma, the weights hb1 and hb2 of this step's estimate and the previous one, and the order,
|
||||
* 1 where there is no previous estimate on the same grid. */
|
||||
int32_t sampler;
|
||||
/* VENCODE: f32 [enc_frames, enc_height, enc_width, 3] RGB in 0..255, the frames padded to
|
||||
* whole clips by repeating the last (rad_arch_encode_geom's entry 23). AENCODE: f32
|
||||
* [enc_channels, enc_n_samples], each channel padded with zeros to the hop (entry 0). Both:
|
||||
* the pass's geometry as rad_arch_encode_geom gave it, i32 on the device, and the media's
|
||||
* kind (RAD_ENC_*, below) and its number within the kind from 1. */
|
||||
const float* enc_pixels;
|
||||
int32_t enc_frames, enc_height, enc_width;
|
||||
const float* enc_samples;
|
||||
int64_t enc_n_samples;
|
||||
int32_t enc_channels;
|
||||
const int32_t* enc_geom_d;
|
||||
int32_t enc_kind, enc_slot;
|
||||
/* VCOND and VSTEP of a request with reference media or keyframes: their table, host i32, null
|
||||
* without. [0] the references, [1] the keyframes, then 6 words a reference {kind, slot, latent
|
||||
* height, latent width, latent frames, soundtrack latents} in presentation order and 3 a
|
||||
* keyframe {frame, latent frames, soundtrack latents}, then the prompt's vision pads: a count
|
||||
* and {first token, tokens} of each picture's run. A reference's kind is RAD_VREF_PICTURE,
|
||||
* _AUDIO or _VIDEO; its slot is its encode pass's. */
|
||||
const int32_t* ref_tab;
|
||||
/* VSTEP: i32, rad_arch_video_pack's `mod`: the boundaries of the modulation groups, then the
|
||||
* cell each reads; `seg_cu` then holds the segment boundaries. A request without references
|
||||
* stages `seg_cu`'s four and no cells. */
|
||||
const int32_t* mod_cu;
|
||||
} RadVideoGenBatch;
|
||||
|
||||
enum { RAD_SAMPLER_EULER = 0, RAD_SAMPLER_RES_MULTISTEP = 1 };
|
||||
|
||||
/* RadVideoGenBatch::enc_kind: the media an encode pass carries, numbered from 1 within a kind. A
|
||||
* keyframe is 1 for the first frame and 2 for the last. */
|
||||
enum {
|
||||
RAD_ENC_IMAGE = 1, /* a reference picture; Vencode */
|
||||
RAD_ENC_VIDEO = 2, /* a reference video; Vencode */
|
||||
RAD_ENC_VAUDIO = 3, /* the soundtrack of reference video `enc_slot`; Aencode */
|
||||
RAD_ENC_AUDIO = 4, /* a standalone soundtrack; Aencode */
|
||||
RAD_ENC_KEYFRAME = 5 /* a first or last frame; Vencode */
|
||||
};
|
||||
|
||||
/* RadVideoGenBatch::ref_tab: a reference's kind. */
|
||||
enum { RAD_VREF_PICTURE = 0, RAD_VREF_AUDIO = 1, RAD_VREF_VIDEO = 2 };
|
||||
|
||||
/* RadVideoGenBatch::geom_d. The request's latent geometry, then a VDECODE pass's chunk: the latent
|
||||
* frames it reads (from latent frame `chunk_lat0`), its latent grid again so that (frames, h, w,
|
||||
* first, last) is one run, and the same chunk in patches. */
|
||||
@@ -780,19 +812,18 @@ int rad_step_fail(RadCtx* c, const char* what);
|
||||
|
||||
/* ================================================================== run-phase queries */
|
||||
const RadBatch* rad_batch(RadCtx* c);
|
||||
/* The position of absolute model layer `layer` in the cache `group` holds, or -1 when this rank
|
||||
* has no pool for it or the group does not hold that layer. It is the same lookup a RAD_KV operand
|
||||
* makes (KVPoolBinding::layer_slot), and the index a streamed group's host mirror is laid out by:
|
||||
* layer `i` of the group is at `stream->host + i * stream->host_layer_stride`. A group's bound
|
||||
* layers need not be contiguous, so this is never `layer` itself. */
|
||||
/* The position of model layer `layer` among `group`'s bound layers, or -1 when this rank has no
|
||||
* pool for it or the group does not hold the layer: the lookup a RAD_KV operand makes, and the
|
||||
* index of the layer's host mirror row. Bound layers need not be contiguous. */
|
||||
int rad_kv_layer_index(RadCtx* c, rad_kvgroup group, int layer);
|
||||
/* Prefill staging (docs/KV-STREAMING.md §4.1). When the group's pass selected the one-layer stage
|
||||
* view, copy this layer's whole host-mirror row into it, on the compute stream, after the layer's
|
||||
* store and before its attention; returns 1 and the caller must not resolve. Returns 0 when the
|
||||
* group has no stage view (a resident group, or the parity configuration's context-sized ring) and
|
||||
* the caller proceeds normally. The ordering rule is in core/kvstream/stage.h. */
|
||||
/* Prefill staging of a streamed group (the ordering rule is in core/kvstream/stage.h).
|
||||
* rad_kv_stage_layer, before the layer's store: when the pass uses the one-layer stage view, make
|
||||
* the layer's mirror row whole in it (once a pass) and return 1, after which the caller reads
|
||||
* block ids directly and must not resolve; 0 when the group has no stage view.
|
||||
* rad_kv_stage_next, after every attention launch of the layer: start the next layer's copy. */
|
||||
int rad_kv_stage_layer(RadCtx* c, rad_kvgroup group, const RadKVGroupBatch* kvb,
|
||||
int layer);
|
||||
int rad_kv_stage_next(RadCtx* c, rad_kvgroup group, int layer);
|
||||
int rad_rank(RadCtx* c);
|
||||
int rad_world_size(RadCtx* c);
|
||||
RadStream rad_stream(RadCtx* c);
|
||||
|
||||
Reference in new issue
Block a user