prefill: key tape splits from ordered host KV bounds

This commit is contained in:
Constantin authored and StillDeadcode committed 2026-11-03 19:05:30 +01:00
1 parent aa14eea76c
commit 798fb21e51
14 files changed
+221 -65

No files matched your search

+9 -1
View File
@@ -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 34u
#define RAD_ABI_VERSION 35u
/* ================================================================== plugin identity */
/* One value per plugin, not flags (QUANT is 3). RAD_PLUGIN_QUANT is a quantiser plugin:
@@ -60,6 +60,14 @@ typedef struct RadArgs {
void* instance; /* whatever init() returned for this resolved instance */
int rank; /* tensor-parallel rank and world size, for collectives */
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. 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
* exactly the same per-device occupancy as architecture pass-key callbacks without querying
* the process-global current device on the hot path. */
int32_t wgp_count;
} RadArgs;
/* Read a parameter by key. Inline definitions, because a plugin links only the ABI headers and
+4
View File
@@ -37,6 +37,8 @@ ABI_FIELD(RadArgs, scratch_bytes)
ABI_FIELD(RadArgs, instance)
ABI_FIELD(RadArgs, rank)
ABI_FIELD(RadArgs, world_size)
ABI_FIELD(RadArgs, kv_used_max_h)
ABI_FIELD(RadArgs, wgp_count)
ABI_STRUCT(RadBatch)
ABI_FIELD(RadBatch, phase)
ABI_FIELD(RadBatch, step)
@@ -96,6 +98,7 @@ ABI_FIELD(RadBatch, plugin_words_h)
ABI_FIELD(RadBatch, plugin_cu_h)
ABI_FIELD(RadBatch, sgen_b)
ABI_FIELD(RadBatch, kv_used_max_h)
ABI_FIELD(RadBatch, positions_h)
ABI_STRUCT(RadBufDecl)
ABI_FIELD(RadBufDecl, dtype)
ABI_FIELD(RadBufDecl, rank)
@@ -503,6 +506,7 @@ ABI_FIELD(RadKVGroupBatch, state_index_pitch)
ABI_FIELD(RadKVGroupBatch, block_size)
ABI_FIELD(RadKVGroupBatch, max_blocks)
ABI_FIELD(RadKVGroupBatch, stream)
ABI_FIELD(RadKVGroupBatch, seqused_h)
ABI_STRUCT(RadKVGroupDecl)
ABI_FIELD(RadKVGroupDecl, kind)
ABI_FIELD(RadKVGroupDecl, dtype)
+6 -1
View File
@@ -68,8 +68,10 @@ typedef struct RadKVGroupBatch {
int64_t state_index_pitch;
int64_t block_size;
int64_t max_blocks;
/* Null unless this group streams (RadKVStream). Trailing and zero-defaulted. */
/* Null unless this group streams (RadKVStream). */
const RadKVStream* stream;
/* ABI 35: host mirror of seqused, retained through this batch for exact sliced-launch bounds. */
const int32_t* seqused_h;
} RadKVGroupBatch;
typedef struct RadBatch {
@@ -334,6 +336,9 @@ typedef struct RadBatch {
/* ---- appended in ABI 34: host-side max seqused per entry of kv[], for an architecture's
* optional recorded-pass geometry key. Null when the batch has no host summary. */
const int32_t* kv_used_max_h;
/* ABI 35: host mirror of positions, for a one-sequence prefill op whose exact KV bound is the
* position immediately after its first query piece. Valid through the batch's issue pass. */
const int32_t* positions_h;
} RadBatch;
/* What a generator pass carries beside the step batch's own fields, which keep their meanings: