Archived
radiance 1.12.0
New models: - Fish Audio drama-3: speech with speaker tags and inline direction, voices cloned from reference clips (the `references` field of /v1/audio/speech and the streaming session), two cards - Gemma 4 E2B/E4B (KV-shared layers, per-layer embeddings, clipped vision linears), with NVIDIA-Nemotron-3.5-Bolt-E4B in bf16 with DFlash and vision on one card, and E4B recipes Speed: - MXFP4 GEMMs for one to 64 rows and a tiled prefill GEMM at TN=4 from 1024 rows: the 27B MXFP4 with DFlash2 decodes about 1% faster at c1, 5% at c4 and 14% at c16 - The fp8 and int8 LM heads read their weight once for 65 to 128 rows - A prefill step of one sequence runs in two pieces on a second lane at two ranks (qwen35_fp8, gemma3): a 45K-token prompt on the 27B fp8 in 15.1 s instead of 16.2 s - Gemma 3's fused all-reduce junctions also under a lossy wire - --draft-short-from N: a block drafter runs its shorter block from N decoding sequences on (off by default; with 8 on the 27B MXFP4: c8 +12%, c16 +18%, c64 +32%, c1 unchanged) - --tp-attn-split rows: GLM-5.3-Flash's MLA attention split by rows over the ranks, 18 to 21% faster prefill; lossy, `heads` stays the default - --draft-coupling on: Qwen3.8-Flash-Next's MTP drafter samples its proposals from its reranked top-8 and the target's draw is coupled to it; pays at high temperatures (c1 at T 1.0: 155 -> 178 tok/s), costs at low ones; off by default Features: - Edited prompts on windowed models (Gemma 4) reuse their prefix: periodic window snapshots, and snapshot-backed prefix KV kept across recomputes (an edited tail on Gemma 4 31B: 96 s -> 2.6 s) - DELETE /sessions/<label> and DELETE /sessions?id=<id> forget one stored conversation - --state-cache-dtype f16: the delta-net state cache at half the memory (qwen35 plugins; lossy) Fixes: - A browser's CORS preflight allows DELETE Changes: Plugin ABI 27: out-of-tree plugins must be rebuilt. The environment switches the PRs added are flags now (--tp-attn-split, --draft-coupling, --state-cache-dtype).
This commit is contained in:
10 parents
4bca30369b
b1f4fccc52
d90e19dc15
3aded1bbf8
d912c694f3
824e238996
58142a6638
9322ea0b92
e9d03362f0
4d68a01a08
commit
5a9ce4912b
137 files changed
+12959
-1126
No files matched your search
@@ -3257,6 +3257,188 @@ TEST(the_tiers_are_told_the_cache_s_block_ids_and_not_the_requests) {
|
||||
}
|
||||
}
|
||||
|
||||
/* ================================================================== release on request
|
||||
*
|
||||
* A client that deleted a conversation, or kept a prefix of it and replaced the rest, forgets it
|
||||
* through the session table: by label, from the tip inwards, host copy and snapshots with it.
|
||||
* What another conversation also walks stays, as does what a live sequence holds.
|
||||
*/
|
||||
|
||||
/* Publishes `tokens` under `id` with a session label, as the scheduler does at a turn's close,
|
||||
* and frees the sequence, as it does right after. */
|
||||
static void publish_turn(Fixture& f, uint64_t id, const std::vector<int32_t>& tokens,
|
||||
const std::string& label) {
|
||||
CHECK_OK(f.kv.add_sequence(id));
|
||||
CHECK_OK(f.kv.ensure(id, (int64_t)tokens.size()));
|
||||
std::vector<std::vector<int32_t>> bt;
|
||||
for (int32_t g : f.pc.cached_groups()) bt.push_back(f.kv.block_table(id, g));
|
||||
CHECK_OK(f.pc.insert(id, tokens, {}, bt, (int64_t)tokens.size(), label));
|
||||
f.kv.free_sequence(id);
|
||||
}
|
||||
|
||||
/* The label's rows in the session table. */
|
||||
static std::vector<IdleTiers::SessionInfo> rows_of(IdleTiers& t, const std::string& label) {
|
||||
std::vector<IdleTiers::SessionInfo> out;
|
||||
for (const IdleTiers::SessionInfo& s : t.sessions())
|
||||
if (s.label == label) out.push_back(s);
|
||||
return out;
|
||||
}
|
||||
|
||||
TEST(a_released_conversation_goes_from_the_tip_down_to_what_another_one_shares) {
|
||||
Fixture f;
|
||||
CHECK_OK(f.build(/*with_linear=*/false, /*ckpt_slots=*/0));
|
||||
IdleTiers t;
|
||||
CHECK_OK(t.configure(tier_config(1 << 20, 1024)));
|
||||
f.pc.set_tiers(&t);
|
||||
|
||||
/* Conversation A over three turns under three request ids: each turn extends the last. The
|
||||
* first two blocks are a system prompt conversation B opens with too. */
|
||||
const auto a1 = tok_run(100, 64); /* 4 blocks */
|
||||
auto a2 = a1; for (int i = 0; i < 32; ++i) a2.push_back(700 + i); /* 6 */
|
||||
auto a3 = a2; for (int i = 0; i < 32; ++i) a3.push_back(800 + i); /* 8 */
|
||||
publish_turn(f, 1, a1, "chat-a");
|
||||
publish_turn(f, 2, a2, "chat-a");
|
||||
publish_turn(f, 3, a3, "chat-a");
|
||||
auto b = tok_run(100, 32); for (int i = 0; i < 64; ++i) b.push_back(900 + i); /* 6 */
|
||||
publish_turn(f, 4, b, "chat-b");
|
||||
CHECK_EQ(f.pc.size(), 12ll); /* 8 + 4 own blocks of B */
|
||||
REQUIRE_EQ(rows_of(t, "chat-a").size(), 1u); /* one row per conversation */
|
||||
CHECK_EQ(rows_of(t, "chat-a")[0].n_tokens, 128ll);
|
||||
/* Every entry has its host copy. */
|
||||
copy_now(t);
|
||||
CHECK_EQ(t.arena().used_slots(), 12);
|
||||
const int64_t pool_before = f.kv.free_blocks(G_FULL);
|
||||
|
||||
SessionRelease r;
|
||||
CHECK_EQ(f.pc.release_session("chat-c", 0, 0, &r), RAD_E_NOTFOUND);
|
||||
CHECK_EQ(f.pc.release_session("", 0, 0, &r), RAD_E_INVAL);
|
||||
|
||||
CHECK_OK(f.pc.release_session("chat-a", 0, 0, &r));
|
||||
CHECK_EQ(r.sessions, 1ll);
|
||||
CHECK_EQ(r.entries, 6ll); /* 8 less the 2 B walks too */
|
||||
CHECK_EQ(r.tokens, 96ll);
|
||||
CHECK_EQ(r.kept_shared, 2ll);
|
||||
CHECK_EQ(r.kept_live, 0ll);
|
||||
CHECK_EQ(r.kept_tokens, 0ll);
|
||||
CHECK(r.device_bytes > 0);
|
||||
CHECK_EQ(r.host_bytes, 6 * 1024ll);
|
||||
/* Pool and arena got the six back; the index holds B's chain and the shared start. */
|
||||
CHECK_EQ(f.kv.free_blocks(G_FULL), pool_before + 6);
|
||||
CHECK_EQ(t.arena().used_slots(), 6);
|
||||
CHECK_EQ(f.pc.size(), 6ll);
|
||||
CHECK_EQ(f.pc.stats().released, 6ll);
|
||||
/* A's next turn hits the shared system prompt and nothing more; B is whole. */
|
||||
CHECK_EQ(f.pc.lookup(a3, {}).n_attn_tokens, 32);
|
||||
CHECK_EQ(f.pc.lookup(b, {}).n_attn_tokens, 80);
|
||||
CHECK_EQ(rows_of(t, "chat-a").size(), 0u);
|
||||
REQUIRE_EQ(rows_of(t, "chat-b").size(), 1u);
|
||||
CHECK_EQ(rows_of(t, "chat-b")[0].n_tokens, 96ll);
|
||||
|
||||
/* Released twice is not found the second time. */
|
||||
CHECK_EQ(f.pc.release_session("chat-a", 0, 0, &r), RAD_E_NOTFOUND);
|
||||
}
|
||||
|
||||
TEST(keep_tokens_leaves_the_chains_start_standing_in_whole_blocks) {
|
||||
Fixture f;
|
||||
CHECK_OK(f.build(/*with_linear=*/false, /*ckpt_slots=*/0));
|
||||
IdleTiers t;
|
||||
CHECK_OK(t.configure(tier_config(1 << 20, 1024)));
|
||||
f.pc.set_tiers(&t);
|
||||
|
||||
auto b = tok_run(100, 32); for (int i = 0; i < 64; ++i) b.push_back(900 + i); /* 6 blocks */
|
||||
publish_turn(f, 4, b, "chat-b");
|
||||
|
||||
/* 40 tokens keep three blocks: the one holding token 40 goes with them. */
|
||||
SessionRelease r;
|
||||
CHECK_OK(f.pc.release_session("chat-b", 0, 40, &r));
|
||||
CHECK_EQ(r.entries, 3ll);
|
||||
CHECK_EQ(r.kept_tokens, 48ll);
|
||||
CHECK_EQ(r.kept_shared, 0ll);
|
||||
CHECK_EQ(f.pc.lookup(b, {}).n_attn_tokens, 48);
|
||||
/* The row stays, cut to the kept prefix: the client extends it again. */
|
||||
REQUIRE_EQ(rows_of(t, "chat-b").size(), 1u);
|
||||
CHECK_EQ(rows_of(t, "chat-b")[0].n_tokens, 48ll);
|
||||
const uint64_t id = rows_of(t, "chat-b")[0].id;
|
||||
|
||||
/* The same by engine id, keeping more than is left: nothing goes, nothing breaks. */
|
||||
CHECK_OK(f.pc.release_session("", id, 200, &r));
|
||||
CHECK_EQ(r.entries, 0ll);
|
||||
CHECK_EQ(r.kept_tokens, 48ll);
|
||||
CHECK_EQ(f.pc.lookup(b, {}).n_attn_tokens, 48);
|
||||
|
||||
/* A later turn extends the stub into a full row again. */
|
||||
publish_turn(f, 5, b, "chat-b");
|
||||
REQUIRE_EQ(rows_of(t, "chat-b").size(), 1u);
|
||||
CHECK_EQ(rows_of(t, "chat-b")[0].n_tokens, 96ll);
|
||||
CHECK_EQ(f.pc.lookup(b, {}).n_attn_tokens, 80);
|
||||
}
|
||||
|
||||
TEST(a_release_takes_the_sessions_snapshots_past_the_kept_prefix_and_leaves_live_blocks) {
|
||||
Fixture f;
|
||||
CHECK_OK(f.build(/*with_linear=*/true, /*ckpt_slots=*/4));
|
||||
IdleTiers t;
|
||||
IdleTiers::Config tc = tier_config(1 << 20, 1024);
|
||||
tc.ckpt_bytes = f.kv.checkpoint_bytes();
|
||||
tc.ckpt_slots = 4;
|
||||
CHECK_OK(t.configure(tc));
|
||||
f.pc.set_tiers(&t);
|
||||
|
||||
const auto a = tok_run(100, 128); /* 8 blocks, checkpoints at 64, 128 */
|
||||
const std::vector<BlockHash> hs = chain_of(a);
|
||||
CHECK_OK(f.kv.add_sequence(3));
|
||||
CHECK_OK(f.kv.ensure(3, 128));
|
||||
ckpt_at(f, 3, hs, 64);
|
||||
ckpt_at(f, 3, hs, 128);
|
||||
f.pc.begin_step();
|
||||
{
|
||||
std::vector<std::vector<int32_t>> bt;
|
||||
for (int32_t g : f.pc.cached_groups()) bt.push_back(f.kv.block_table(3, g));
|
||||
CHECK_OK(f.pc.insert(3, a, {}, bt, 128, "chat-a"));
|
||||
}
|
||||
f.kv.free_sequence(3);
|
||||
CHECK_EQ(f.kv.free_checkpoint_slots(), 2ll);
|
||||
CHECK_EQ(rows_of(t, "chat-a")[0].snapshots, 2ll);
|
||||
|
||||
/* A waiting request restored the chain and holds it; a running one adopted the first
|
||||
* five blocks. Both keep their blocks through a release. */
|
||||
std::vector<std::vector<int32_t>> found;
|
||||
const CacheHit h = f.pc.lookup(a, {}, &found);
|
||||
CHECK_EQ(h.n_attn_tokens, 112);
|
||||
CHECK_OK(f.kv.add_sequence(9));
|
||||
std::vector<int32_t> five(found[0].begin(), found[0].begin() + 5);
|
||||
CHECK_OK(f.kv.adopt(9, f.pc.cached_groups()[0], five, 80));
|
||||
f.pc.begin_step();
|
||||
|
||||
SessionRelease r;
|
||||
CHECK_OK(f.pc.release_session("chat-a", 0, 64, &r));
|
||||
/* Blocks 4..7 are past the kept 64 tokens; block 4 is live, 5..7 go. */
|
||||
CHECK_EQ(r.entries, 3ll);
|
||||
CHECK_EQ(r.kept_live, 1ll);
|
||||
CHECK_EQ(r.kept_tokens, 64ll);
|
||||
/* The snapshot at 128 sat on block 7 and went with it; the one at 64 is on the kept prefix. */
|
||||
CHECK_EQ(r.snapshots, 1ll);
|
||||
CHECK_EQ(f.kv.free_checkpoint_slots(), 3ll);
|
||||
const std::vector<int64_t> left = f.pc.checkpoints(3);
|
||||
REQUIRE_EQ(left.size(), 1u);
|
||||
CHECK_EQ(left[0], 64ll);
|
||||
CHECK_EQ(f.pc.stats().ckpt_released, 1ll);
|
||||
/* The live block is still indexed and the sequence still reads it; the row reaches it. */
|
||||
CHECK_EQ(f.kv.block_refcount(G_FULL, five[4]), 2);
|
||||
REQUIRE_EQ(rows_of(t, "chat-a").size(), 1u);
|
||||
CHECK_EQ(rows_of(t, "chat-a")[0].n_tokens, 80ll);
|
||||
CHECK_EQ(f.pc.lookup(a, {}).n_attn_tokens, 80);
|
||||
CHECK_EQ(f.pc.lookup(a, {}).n_linear_tokens, 64);
|
||||
|
||||
/* The sequence is gone: the block it held goes on the next release. */
|
||||
f.kv.free_sequence(9);
|
||||
CHECK_OK(f.pc.release_session("chat-a", 0, 64, &r));
|
||||
CHECK_EQ(r.entries, 1ll);
|
||||
CHECK_EQ(r.kept_live, 0ll);
|
||||
CHECK_EQ(f.pc.lookup(a, {}).n_attn_tokens, 64);
|
||||
CHECK_EQ(f.pc.lookup(a, {}).n_linear_tokens, 64);
|
||||
CHECK_EQ(rows_of(t, "chat-a")[0].n_tokens, 64ll);
|
||||
}
|
||||
|
||||
/* ================================================================== the pool in bytes
|
||||
*
|
||||
* Blocks and tokens cannot be summed across KV groups: a recurrent group has no token axis and
|
||||
|
||||
Reference in new issue
Block a user