Archived
abi: RadBatch::lora_slot, each row's runtime LoRA adapter; RAD_ABI_VERSION 18
The per-row adapter slot moves from the core's `lora_slot` derivation into the step batch, beside the other per-row arrays: [n_tok] i32 device, the row's slot in the adapter pools, < 0 or >= S a base row, null when the engine serves no adapters. The batch builder fills it from Request::lora_slot where it fills token_ids and positions, in the slab every rank's batch already points into -- one address per rank for the engine's life, uploaded in stream order ahead of the step's kernels -- so a recorded pass replays it the way it replays token_ids. Ctx::pass_key reads the pointer; the adapter ops are issued whatever the slots hold, so nothing a pass launches depends on their values. Off: the slab carves nothing for it (a zero-length carve), no buffer is declared, and every other slab offset and the arena are what they were. The derivation, its program buffer and Program::lora_slot_buf are gone. abi_layout_table regenerated at 18 (RadBatch grows to 320 bytes, the fields after seq_ids move by 8); sched_test holds the per-row fill, and that the slot array is the only thing adapters add to the slab.
This commit is contained in:
1 parent
09ff76701c
commit
582cda0a53
15 files changed
+141
-84
No files matched your search
@@ -32,6 +32,7 @@ ABI_FIELD(RadBatch, token_ids)
|
||||
ABI_FIELD(RadBatch, positions)
|
||||
ABI_FIELD(RadBatch, cu_seqlens)
|
||||
ABI_FIELD(RadBatch, seq_ids)
|
||||
ABI_FIELD(RadBatch, lora_slot)
|
||||
ABI_FIELD(RadBatch, n_out)
|
||||
ABI_FIELD(RadBatch, out_ids)
|
||||
ABI_FIELD(RadBatch, q_lens)
|
||||
|
||||
+39
-38
@@ -1,4 +1,4 @@
|
||||
/* abi_layout_table.h -- every abi/ struct's size and field offsets at RAD_ABI_VERSION 17 and
|
||||
/* abi_layout_table.h -- every abi/ struct's size and field offsets at RAD_ABI_VERSION 18 and
|
||||
* RAD_FORMAT_VER 2, as { type, field, offset, size } rows ("" is the struct itself). A snapshot
|
||||
* of the headers on x86-64 Linux, which abi_layout_test.cpp holds the layout to; regenerate it
|
||||
* from the test's printout only together with a version bump. */
|
||||
@@ -20,7 +20,7 @@
|
||||
{ "RadArgs", "instance", 48, 8 },
|
||||
{ "RadArgs", "rank", 56, 4 },
|
||||
{ "RadArgs", "world_size", 60, 4 },
|
||||
{ "RadBatch", "", 0, 312 },
|
||||
{ "RadBatch", "", 0, 320 },
|
||||
{ "RadBatch", "phase", 0, 4 },
|
||||
{ "RadBatch", "step", 4, 4 },
|
||||
{ "RadBatch", "n_tok", 8, 8 },
|
||||
@@ -29,42 +29,43 @@
|
||||
{ "RadBatch", "positions", 32, 8 },
|
||||
{ "RadBatch", "cu_seqlens", 40, 8 },
|
||||
{ "RadBatch", "seq_ids", 48, 8 },
|
||||
{ "RadBatch", "n_out", 56, 8 },
|
||||
{ "RadBatch", "out_ids", 64, 8 },
|
||||
{ "RadBatch", "q_lens", 72, 8 },
|
||||
{ "RadBatch", "ctx_lens", 80, 8 },
|
||||
{ "RadBatch", "max_q_len", 88, 4 },
|
||||
{ "RadBatch", "max_ctx_len", 92, 4 },
|
||||
{ "RadBatch", "n_kv_groups", 96, 4 },
|
||||
{ "RadBatch", "kv", 104, 8 },
|
||||
{ "RadBatch", "n_spec", 112, 4 },
|
||||
{ "RadBatch", "num_accepted", 120, 8 },
|
||||
{ "RadBatch", "spec_parent", 128, 8 },
|
||||
{ "RadBatch", "draft_pass", 136, 4 },
|
||||
{ "RadBatch", "n_checkpoints", 140, 4 },
|
||||
{ "RadBatch", "checkpoint_tok", 144, 8 },
|
||||
{ "RadBatch", "checkpoint_slot", 152, 8 },
|
||||
{ "RadBatch", "n_seq_decode", 160, 8 },
|
||||
{ "RadBatch", "n_tok_decode", 168, 8 },
|
||||
{ "RadBatch", "max_q_len_decode", 176, 4 },
|
||||
{ "RadBatch", "max_q_len_prefill", 180, 4 },
|
||||
{ "RadBatch", "n_draft_out", 184, 8 },
|
||||
{ "RadBatch", "draft_out_ids", 192, 8 },
|
||||
{ "RadBatch", "n_ahead", 200, 8 },
|
||||
{ "RadBatch", "rope_pos", 208, 8 },
|
||||
{ "RadBatch", "rope_mixed", 216, 4 },
|
||||
{ "RadBatch", "n_mm_rows", 224, 8 },
|
||||
{ "RadBatch", "mm_rows", 232, 8 },
|
||||
{ "RadBatch", "mm_embd", 240, 8 },
|
||||
{ "RadBatch", "enc", 248, 4 },
|
||||
{ "RadBatch", "enc_n_patch", 256, 8 },
|
||||
{ "RadBatch", "enc_pixels", 264, 8 },
|
||||
{ "RadBatch", "enc_coord", 272, 8 },
|
||||
{ "RadBatch", "enc_n_seg", 280, 8 },
|
||||
{ "RadBatch", "enc_cu", 288, 8 },
|
||||
{ "RadBatch", "enc_max_seg", 296, 4 },
|
||||
{ "RadBatch", "gen", 300, 4 },
|
||||
{ "RadBatch", "gen_b", 304, 8 },
|
||||
{ "RadBatch", "lora_slot", 56, 8 },
|
||||
{ "RadBatch", "n_out", 64, 8 },
|
||||
{ "RadBatch", "out_ids", 72, 8 },
|
||||
{ "RadBatch", "q_lens", 80, 8 },
|
||||
{ "RadBatch", "ctx_lens", 88, 8 },
|
||||
{ "RadBatch", "max_q_len", 96, 4 },
|
||||
{ "RadBatch", "max_ctx_len", 100, 4 },
|
||||
{ "RadBatch", "n_kv_groups", 104, 4 },
|
||||
{ "RadBatch", "kv", 112, 8 },
|
||||
{ "RadBatch", "n_spec", 120, 4 },
|
||||
{ "RadBatch", "num_accepted", 128, 8 },
|
||||
{ "RadBatch", "spec_parent", 136, 8 },
|
||||
{ "RadBatch", "draft_pass", 144, 4 },
|
||||
{ "RadBatch", "n_checkpoints", 148, 4 },
|
||||
{ "RadBatch", "checkpoint_tok", 152, 8 },
|
||||
{ "RadBatch", "checkpoint_slot", 160, 8 },
|
||||
{ "RadBatch", "n_seq_decode", 168, 8 },
|
||||
{ "RadBatch", "n_tok_decode", 176, 8 },
|
||||
{ "RadBatch", "max_q_len_decode", 184, 4 },
|
||||
{ "RadBatch", "max_q_len_prefill", 188, 4 },
|
||||
{ "RadBatch", "n_draft_out", 192, 8 },
|
||||
{ "RadBatch", "draft_out_ids", 200, 8 },
|
||||
{ "RadBatch", "n_ahead", 208, 8 },
|
||||
{ "RadBatch", "rope_pos", 216, 8 },
|
||||
{ "RadBatch", "rope_mixed", 224, 4 },
|
||||
{ "RadBatch", "n_mm_rows", 232, 8 },
|
||||
{ "RadBatch", "mm_rows", 240, 8 },
|
||||
{ "RadBatch", "mm_embd", 248, 8 },
|
||||
{ "RadBatch", "enc", 256, 4 },
|
||||
{ "RadBatch", "enc_n_patch", 264, 8 },
|
||||
{ "RadBatch", "enc_pixels", 272, 8 },
|
||||
{ "RadBatch", "enc_coord", 280, 8 },
|
||||
{ "RadBatch", "enc_n_seg", 288, 8 },
|
||||
{ "RadBatch", "enc_cu", 296, 8 },
|
||||
{ "RadBatch", "enc_max_seg", 304, 4 },
|
||||
{ "RadBatch", "gen", 308, 4 },
|
||||
{ "RadBatch", "gen_b", 312, 8 },
|
||||
{ "RadBufDecl", "", 0, 80 },
|
||||
{ "RadBufDecl", "dtype", 0, 4 },
|
||||
{ "RadBufDecl", "rank", 4, 4 },
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Checked: a C translation unit (abi_c_test.c, strict C11) lays every struct out as C++ does; every
|
||||
* struct's listed fields account for its size, so the list in abi_layout_rows.h is complete; and
|
||||
* the layout agrees with the table below, taken at RAD_ABI_VERSION 17 and RAD_FORMAT_VER 2. Under
|
||||
* the layout agrees with the table below, taken at RAD_ABI_VERSION 18 and RAD_FORMAT_VER 2. Under
|
||||
* those versions a listed field may not move or change size, an ABI struct may only grow by fields
|
||||
* past its old end, and an on-disk struct may not change at all. The table is a snapshot of the
|
||||
* headers: nothing else states the layout. When it disagrees the test prints the live table.
|
||||
@@ -57,8 +57,8 @@ std::vector<Row> cpp_rows() {
|
||||
};
|
||||
}
|
||||
|
||||
/* The layout at RAD_ABI_VERSION 17 / RAD_FORMAT_VER 2 (see the file header). */
|
||||
constexpr uint32_t kTableAbi = 17, kTableFormat = 2;
|
||||
/* The layout at RAD_ABI_VERSION 18 / RAD_FORMAT_VER 2 (see the file header). */
|
||||
constexpr uint32_t kTableAbi = 18, kTableFormat = 2;
|
||||
const AbiRow kTable[] = {
|
||||
#include "abi_layout_table.h"
|
||||
};
|
||||
|
||||
@@ -1121,6 +1121,52 @@ TEST(derived_metadata_is_computed_once_per_step_into_the_arena) {
|
||||
CHECK_EQ(ci[0], cslot * 4 + (p.e[0].conv_cursor % 4));
|
||||
}
|
||||
|
||||
/* RadBatch::lora_slot: every row of a sequence carries its request's runtime LoRA slot, -1 for a
|
||||
* base request, in the step's row order (decode rows first). */
|
||||
TEST(the_step_batch_carries_each_rows_adapter_slot) {
|
||||
Fixture f;
|
||||
f.build();
|
||||
f.cfg.lora.max_loras = 2;
|
||||
CHECK_OK(f.start());
|
||||
|
||||
auto r = f.request(100, 64);
|
||||
r->lora_slot = 1;
|
||||
r->lora_uid = 7;
|
||||
CHECK(f.add(std::move(r)) != 0);
|
||||
const RadBatch* b = f.sch.step();
|
||||
CHECK(b != nullptr);
|
||||
CHECK(b->lora_slot != nullptr);
|
||||
CHECK_EQ(b->n_tok, (int64_t)100);
|
||||
for (int64_t i = 0; i < b->n_tok; ++i) CHECK_EQ(b->lora_slot[i], 1);
|
||||
f.commit_plain();
|
||||
|
||||
f.submit(64, 64);
|
||||
b = f.sch.step();
|
||||
CHECK(b != nullptr);
|
||||
CHECK_EQ(b->n_tok, (int64_t)65);
|
||||
CHECK_EQ(b->lora_slot[0], 1); /* the adapter request's decode row */
|
||||
for (int64_t i = 1; i < 65; ++i) CHECK_EQ(b->lora_slot[i], -1); /* the base prefill */
|
||||
}
|
||||
|
||||
/* With no adapters served the field is null and the step slab is byte for byte what it was before
|
||||
* the field existed: the slot array is the only thing adapters add to it. */
|
||||
TEST(no_adapters_no_slot_array) {
|
||||
Fixture f;
|
||||
f.build();
|
||||
CHECK_OK(f.start());
|
||||
f.submit(32, 8);
|
||||
const RadBatch* b = f.sch.step();
|
||||
CHECK(b != nullptr);
|
||||
CHECK(b->lora_slot == nullptr);
|
||||
|
||||
Config on = f.cfg;
|
||||
on.lora.max_loras = 2;
|
||||
const int64_t off_bytes = BatchBuilder::device_bytes(f.prog, f.cfg, f.kv.geom);
|
||||
const int64_t on_bytes = BatchBuilder::device_bytes(f.prog, on, f.kv.geom);
|
||||
CHECK(off_bytes > 0);
|
||||
CHECK_EQ(on_bytes - off_bytes, (f.cfg.max_tok * 4 + 255) / 256 * 256);
|
||||
}
|
||||
|
||||
TEST(state_chunk_bounds_split_a_long_prefill_at_absolute_multiples) {
|
||||
DeriveInput in;
|
||||
StepPlan plan;
|
||||
|
||||
Reference in new issue
Block a user