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:
zivius committed 2026-10-20 23:07:33 +02:00
1 parent 346efdeb2e
commit f201c140ab
6 files changed
+34 -2

No files matched your search

+12
View File
@@ -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) {
+2 -1
View File
@@ -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; };