Archived
core: a frame pass names the row before the frame's own -- its KV slot, position and context, for a frame head that attends at the row its hidden state comes from (Fish Audio drama-3's codebook tower)
This commit is contained in:
1 parent
346efdeb2e
commit
f201c140ab
6 files changed
+34
-2
No files matched your search
@@ -466,6 +466,15 @@ typedef struct RadAudioGenBatch {
|
||||
/* VOCODE with RadAudioGenDecl::voc_chunk: the lane's first frame the pass reads, counted
|
||||
* from the first kept frame. 64 bits so that it starts past the struct's ABI 18 end. */
|
||||
int64_t voc_frame0;
|
||||
|
||||
/* FRAME, one value per entry ([n_seq]): the row before the frame's own row -- the one whose
|
||||
* hidden state the frame is sampled from -- as its KV slot, its position, and the context
|
||||
* through it (position + 1). A model whose frame head attends at that row (Fish Audio
|
||||
* drama-3's codebook tower, layers bound to the language model's full-attention group) issues
|
||||
* those layers there, before the language model runs at the frame's own row. */
|
||||
const int32_t* prev_slot;
|
||||
const int32_t* prev_pos;
|
||||
const int32_t* prev_used;
|
||||
} RadAudioGenBatch;
|
||||
|
||||
/* A window entry's flags on a WINDOW pass. FIRST is RAD_GEN_F_FIRST's bit and the others are clear
|
||||
|
||||
@@ -129,6 +129,9 @@ int64_t carve(const Sizes& z, int64_t (*bytes)[2], int n) {
|
||||
z.S * I, /* R_ACC */
|
||||
z.NG * z.S * I, /* R_SBT */
|
||||
z.NG * z.S * AudioDriver::kMaxStateWidth * I, /* R_SIDX */
|
||||
z.S * I, /* R_PSLOT */
|
||||
z.S * I, /* R_PPOS */
|
||||
z.S * I, /* R_PUSED */
|
||||
};
|
||||
int64_t off = 0;
|
||||
for (int r = 0; r < n; ++r) {
|
||||
@@ -499,6 +502,9 @@ void AudioDriver::base_batches(int64_t n_tok, int64_t n_seq, int32_t max_q, int3
|
||||
A.slot = dptr<int32_t>(ri, R_ESLOT);
|
||||
A.last_row = dptr<int32_t>(ri, R_LROW);
|
||||
A.prefix = dptr<int32_t>(ri, R_PREFIX);
|
||||
A.prev_slot = dptr<int32_t>(ri, R_PSLOT);
|
||||
A.prev_pos = dptr<int32_t>(ri, R_PPOS);
|
||||
A.prev_used = dptr<int32_t>(ri, R_PUSED);
|
||||
B.agen_b = &A;
|
||||
}
|
||||
}
|
||||
@@ -716,6 +722,11 @@ const RadBatch* AudioDriver::build_frame(const std::vector<Job*>& js, int step)
|
||||
for (int64_t k = 0; k < pitch; ++k)
|
||||
btab[e * pitch + k] = k < (int64_t)bt.size() ? bt[(size_t)k] : -1;
|
||||
used[e] = (int32_t)(p + 1);
|
||||
/* The row before, whose hidden state the frame is sampled from: the prompt's last
|
||||
* row for the first frame. */
|
||||
hptr<int32_t>(R_PSLOT)[e] = slot_of(bt, p - 1, block_size_);
|
||||
hptr<int32_t>(R_PPOS)[e] = (int32_t)(p - 1);
|
||||
hptr<int32_t>(R_PUSED)[e] = (int32_t)p;
|
||||
hptr<int32_t>(R_ESLOT)[e] = nb_ * j.lane + b;
|
||||
hptr<int32_t>(R_LROW)[e] = (int32_t)e;
|
||||
max_ctx = std::max<int32_t>(max_ctx, (int32_t)(p + 1));
|
||||
@@ -738,6 +749,7 @@ const RadBatch* AudioDriver::build_frame(const std::vector<Job*>& js, int step)
|
||||
reg_[R_LANE].used = reg_[R_FRAME].used = reg_[R_CFG].used = L * 4;
|
||||
reg_[R_SEED].used = 2 * L * 4;
|
||||
reg_[R_ESLOT].used = reg_[R_LROW].used = S * 4;
|
||||
reg_[R_PSLOT].used = reg_[R_PPOS].used = reg_[R_PUSED].used = S * 4;
|
||||
if (upload() < 0) return nullptr;
|
||||
base_batches(S, S, 1, max_ctx, step, true, pitch);
|
||||
for (size_t r = 0; r < ranks_.size(); ++r) {
|
||||
|
||||
@@ -124,7 +124,8 @@ private:
|
||||
struct Region { int64_t off = 0, bytes = 0, used = 0; };
|
||||
enum { R_TOK, R_POS, R_CU, R_SLOT, R_BT, R_USED, R_LANE, R_LAST, R_FRAME, R_SEED,
|
||||
R_T, R_TN, R_CFG, R_PAIR, R_WLANE, R_FLAGS, R_WIDX, R_WF0, R_WNF, R_LCU, R_LSRC,
|
||||
R_ESLOT, R_LROW, R_PREFIX, R_CTX, R_ACC, R_SBT, R_SIDX, R_N };
|
||||
R_ESLOT, R_LROW, R_PREFIX, R_CTX, R_ACC, R_SBT, R_SIDX, R_PSLOT, R_PPOS, R_PUSED,
|
||||
R_N };
|
||||
/* A hybrid model's stateful groups (linear-attention state, convolution history), each staged
|
||||
* as one block-table word a sequence (its slot) and its state_index row. */
|
||||
struct StateGroup { int32_t g = 0; int64_t width = 1; };
|
||||
|
||||
@@ -137,6 +137,9 @@ ABI_FIELD(RadAudioGenBatch, voc_latents)
|
||||
ABI_FIELD(RadAudioGenBatch, voc_left)
|
||||
ABI_FIELD(RadAudioGenBatch, voc_right)
|
||||
ABI_FIELD(RadAudioGenBatch, voc_frame0)
|
||||
ABI_FIELD(RadAudioGenBatch, prev_slot)
|
||||
ABI_FIELD(RadAudioGenBatch, prev_pos)
|
||||
ABI_FIELD(RadAudioGenBatch, prev_used)
|
||||
ABI_STRUCT(RadAudioGenDecl)
|
||||
ABI_FIELD(RadAudioGenDecl, name)
|
||||
ABI_FIELD(RadAudioGenDecl, tmpl)
|
||||
|
||||
@@ -98,7 +98,7 @@
|
||||
{ "RadBuildCtx", "max_audio_frames", 88, 8 },
|
||||
{ "RadBuildCtx", "max_mixed_tok", 96, 8 },
|
||||
{ "RadBuildCtx", "kv_quant", 104, 4 },
|
||||
{ "RadAudioGenBatch", "", 0, 264 },
|
||||
{ "RadAudioGenBatch", "", 0, 288 },
|
||||
{ "RadAudioGenBatch", "n_lane", 0, 8 },
|
||||
{ "RadAudioGenBatch", "lane", 8, 8 },
|
||||
{ "RadAudioGenBatch", "lane_h", 16, 8 },
|
||||
@@ -134,6 +134,9 @@
|
||||
{ "RadAudioGenBatch", "voc_left", 244, 4 },
|
||||
{ "RadAudioGenBatch", "voc_right", 248, 4 },
|
||||
{ "RadAudioGenBatch", "voc_frame0", 256, 8 },
|
||||
{ "RadAudioGenBatch", "prev_slot", 264, 8 },
|
||||
{ "RadAudioGenBatch", "prev_pos", 272, 8 },
|
||||
{ "RadAudioGenBatch", "prev_used", 280, 8 },
|
||||
{ "RadAudioGenDecl", "", 0, 232 },
|
||||
{ "RadAudioGenDecl", "name", 0, 8 },
|
||||
{ "RadAudioGenDecl", "tmpl", 8, 8 },
|
||||
|
||||
@@ -267,6 +267,10 @@ TEST(a_hybrid_model_of_one_branch_stages_its_state_groups) {
|
||||
CHECK_EQ(b->n_tok, (int64_t)1);
|
||||
CHECK_EQ(b->positions[0], 4); /* after the four prompt rows */
|
||||
CHECK_EQ(b->ctx_lens[0], 4);
|
||||
/* The row the frame is sampled from: the prompt's last, at its slot. */
|
||||
CHECK_EQ(b->agen_b->prev_pos[0], 3);
|
||||
CHECK_EQ(b->agen_b->prev_used[0], 4);
|
||||
CHECK_EQ(b->agen_b->prev_slot[0], b->kv[0].slot_mapping[0] - 1);
|
||||
CHECK_EQ(b->num_accepted[0], 1);
|
||||
int32_t st1 = 0, cv1 = 0;
|
||||
state_rows(b, &st1, &cv1);
|
||||
|
||||
Reference in new issue
Block a user