Archived
radiance 1.8.0
- video: MiniMax-H3 and FastVideo's FastH3 8-Step V2, a video with its stereo soundtrack from text on OpenAI's /v1/videos, block fp8 on two cards - music: MiniMax-Music3, songs from lyrics and a description on /v1/audio/speech - speech: Breeze-TTS-2 on /v1/audio/speech and vLLM-Omni's realtime WebSocket - runtime LoRA adapters beside the base model, picked per request by `model` (baKon, #105) - several agent streams keep their cached history: --checkpoint-slots auto, the new default, sizes the snapshot store by --max-num-seqs (#108) - the Swift 1.5 27B W4 releases convert and serve: compressed-tensors AWQ and GPTQ int4, AutoRound, ModelOpt NVFP4 (#110) - the image's host tests pass where perf_event_open is refused, as in BuildKit's sandbox (#106) - plugin ABI 21: out-of-tree plugins must be rebuilt
This commit is contained in:
1 parent
91127395ee
commit
7a7707a955
179 files changed
+37542
-1892
No files matched your search
+64
-12
@@ -82,6 +82,58 @@ void KeepAll::select(const std::vector<int64_t>& pos, std::vector<int64_t>* keep
|
||||
*keep = pos;
|
||||
}
|
||||
|
||||
/* A session's tip is usually a prompt's tail between two interval checkpoints, so each step also
|
||||
* counts the ladder with a tail half an interval on as its tip. */
|
||||
int64_t CheckpointPolicy::held(int64_t ctx, int64_t interval) const {
|
||||
if (interval <= 0 || ctx < interval) return 1;
|
||||
std::vector<int64_t> kept, keep;
|
||||
size_t most = 0;
|
||||
for (int64_t p = interval; p <= ctx; p += interval) {
|
||||
kept.push_back(p);
|
||||
select(kept, &keep);
|
||||
std::sort(keep.begin(), keep.end());
|
||||
kept.swap(keep);
|
||||
most = std::max(most, kept.size());
|
||||
if (p + interval / 2 <= ctx) {
|
||||
std::vector<int64_t> tipped = kept;
|
||||
tipped.push_back(p + interval / 2);
|
||||
select(tipped, &keep);
|
||||
most = std::max(most, keep.size());
|
||||
}
|
||||
}
|
||||
return (int64_t)most;
|
||||
}
|
||||
|
||||
int64_t KeepAll::held(int64_t ctx, int64_t interval) const {
|
||||
return interval > 0 && ctx >= interval ? ctx / interval : 1;
|
||||
}
|
||||
|
||||
std::unique_ptr<CheckpointPolicy> make_checkpoint_policy(const std::string& name,
|
||||
int64_t interval) {
|
||||
if (name == "tip-only") return std::make_unique<KeepTipOnly>();
|
||||
if (name == "keep-all") return std::make_unique<KeepAll>();
|
||||
return std::make_unique<GeometricBackoff>(interval);
|
||||
}
|
||||
|
||||
CheckpointSlots checkpoint_slots_auto(const CheckpointPolicy& policy, int64_t max_seqs,
|
||||
int64_t ctx, int64_t interval, int64_t slot_bytes,
|
||||
int64_t share_bytes, int64_t room_bytes) {
|
||||
CheckpointSlots c;
|
||||
c.per_seq = policy.held(ctx, interval) + 1;
|
||||
const int64_t seqs = std::max<int64_t>(max_seqs, 1);
|
||||
c.want = seqs > INT64_MAX / c.per_seq ? INT64_MAX : seqs * c.per_seq;
|
||||
if (slot_bytes <= 0) return c;
|
||||
const int64_t share = std::max<int64_t>(share_bytes, 0) / slot_bytes;
|
||||
const int64_t room = std::max<int64_t>(room_bytes, 0) / slot_bytes;
|
||||
c.slots = std::min(c.want, std::max(share, std::min(c.want, kCheckpointSlotsFloor)));
|
||||
if (c.slots < c.want) c.bound = CheckpointSlots::Bound::Share;
|
||||
if (room < c.slots) {
|
||||
c.slots = room;
|
||||
c.bound = CheckpointSlots::Bound::Room;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ configure */
|
||||
|
||||
int PrefixCache::configure(const Config& cfg, KVManager* kv, int64_t checkpoint_interval) {
|
||||
@@ -93,11 +145,8 @@ int PrefixCache::configure(const Config& cfg, KVManager* kv, int64_t checkpoint_
|
||||
groups_.clear();
|
||||
map_.clear(); lru_.clear();
|
||||
ck_by_prefix_.clear(); ck_by_session_.clear();
|
||||
/* config_parse rejects unknown names, so the else branch is "geometric-backoff".
|
||||
* set_policy() may override this afterwards. */
|
||||
if (cfg.checkpoint_policy == "tip-only") policy_ = std::make_unique<KeepTipOnly>();
|
||||
else if (cfg.checkpoint_policy == "keep-all") policy_ = std::make_unique<KeepAll>();
|
||||
else policy_ = std::make_unique<GeometricBackoff>(checkpoint_interval);
|
||||
/* set_policy() may override this afterwards. */
|
||||
policy_ = make_checkpoint_policy(cfg.checkpoint_policy, checkpoint_interval);
|
||||
report_.clear();
|
||||
|
||||
if (!kv) return RAD_E_INVAL;
|
||||
@@ -202,7 +251,7 @@ void PrefixCache::touch(const BlockHash& h, uint64_t now_ns) const {
|
||||
CacheHit PrefixCache::lookup(const std::vector<int32_t>& tokens,
|
||||
const std::vector<MMContentKey>& mm,
|
||||
std::vector<std::vector<int32_t>>* blocks_out,
|
||||
const HitCap* cap) const {
|
||||
const HitCap* cap, uint64_t session) const {
|
||||
CacheHit hit;
|
||||
if (blocks_out) { blocks_out->assign(groups_.size(), {}); }
|
||||
if (!enabled_ || tokens.empty()) return hit;
|
||||
@@ -296,6 +345,7 @@ CacheHit PrefixCache::lookup(const std::vector<int32_t>& tokens,
|
||||
best->second.used_ns = now;
|
||||
handed_.push_back(best->first);
|
||||
++stats_.ckpt_hits;
|
||||
if (session != 0) take_over(session, hs, hit.n_attn_tokens);
|
||||
return hit;
|
||||
}
|
||||
|
||||
@@ -384,13 +434,16 @@ int PrefixCache::insert(uint64_t session,
|
||||
tiers_->note_session(session, hs, n_tokens, now, label);
|
||||
}
|
||||
|
||||
/* A conversation's snapshots belong to its latest turn. Sessions are keyed by request id, so
|
||||
* without this each earlier turn's deepest snapshot would stay a protected tip. Every snapshot
|
||||
* on the chain just published moves under this id, so the policy sees one session, one tip. */
|
||||
take_over(session, hs, n_full * block_size_);
|
||||
return RAD_OK;
|
||||
}
|
||||
|
||||
void PrefixCache::take_over(uint64_t session, const std::vector<BlockHash>& hs,
|
||||
int64_t upto) const {
|
||||
for (auto& kvp : ck_by_prefix_) {
|
||||
Ckpt& c = kvp.second;
|
||||
if (c.session == session || c.pos <= 0 || c.pos > n_full * block_size_ ||
|
||||
c.pos % block_size_ != 0 || hs[(size_t)(c.pos / block_size_ - 1)] != kvp.first)
|
||||
if (c.session == session || c.pos <= 0 || c.pos > upto || c.pos % block_size_ != 0 ||
|
||||
hs[(size_t)(c.pos / block_size_ - 1)] != kvp.first)
|
||||
continue;
|
||||
auto old = ck_by_session_.find(c.session);
|
||||
if (old != ck_by_session_.end()) {
|
||||
@@ -401,7 +454,6 @@ int PrefixCache::insert(uint64_t session,
|
||||
c.session = session;
|
||||
ck_by_session_[session].push_back(kvp.first);
|
||||
}
|
||||
return RAD_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+43
-3
@@ -110,6 +110,11 @@ public:
|
||||
* retain. The tip, positions.back(), must always be kept: an appending transcript resumes
|
||||
* from it. */
|
||||
virtual void select(const std::vector<int64_t>& positions, std::vector<int64_t>* keep) const = 0;
|
||||
/* The most snapshots the policy keeps for one session that grows to `ctx` tokens with a
|
||||
* checkpoint on every `interval`, retention applied after each: the session's standing share
|
||||
* of the store. The base applies select() to its own output one checkpoint at a time, which
|
||||
* is cheap only for a policy that keeps few. */
|
||||
virtual int64_t held(int64_t ctx, int64_t interval) const;
|
||||
};
|
||||
|
||||
/* Keep the tip and, at every scale S = interval x 2^k, the shallowest checkpoint in the tip's
|
||||
@@ -134,13 +139,40 @@ class KeepTipOnly final : public CheckpointPolicy {
|
||||
public:
|
||||
const char* name() const override { return "tip-only"; }
|
||||
void select(const std::vector<int64_t>& positions, std::vector<int64_t>* keep) const override;
|
||||
int64_t held(int64_t, int64_t) const override { return 1; }
|
||||
};
|
||||
class KeepAll final : public CheckpointPolicy {
|
||||
public:
|
||||
const char* name() const override { return "keep-all"; }
|
||||
void select(const std::vector<int64_t>& positions, std::vector<int64_t>* keep) const override;
|
||||
int64_t held(int64_t ctx, int64_t interval) const override;
|
||||
};
|
||||
|
||||
/* The policy --checkpoint-policy names, at the resolved checkpoint interval. config_parse admits
|
||||
* only the three names, so any other is geometric backoff. */
|
||||
std::unique_ptr<CheckpointPolicy> make_checkpoint_policy(const std::string& name, int64_t interval);
|
||||
|
||||
/* ------------------------------------------------------------------ the store's size */
|
||||
/* --checkpoint-slots auto. Every sequence --max-num-seqs admits gets its session's standing share
|
||||
* at --max-model-len (CheckpointPolicy::held) plus one slot for the checkpoint its running turn
|
||||
* writes while the previous turn's snapshots are still held. The store is pinned for the life of
|
||||
* the process, so the count is bounded by two byte budgets the engine measures: `share`, the part
|
||||
* of host memory the store may take, and `room`, what the host can pin after everything still to
|
||||
* be allocated. Under the share it never drops below kCheckpointSlotsFloor (or `want`, if fewer);
|
||||
* the room is a hard bound. */
|
||||
constexpr int64_t kCheckpointSlotsFloor = 8;
|
||||
|
||||
struct CheckpointSlots {
|
||||
int64_t per_seq = 0; /* snapshots a sequence is given */
|
||||
int64_t want = 0; /* --max-num-seqs x per_seq */
|
||||
int64_t slots = 0; /* the store's size */
|
||||
enum class Bound { Want, Share, Room } bound = Bound::Want;
|
||||
};
|
||||
|
||||
CheckpointSlots checkpoint_slots_auto(const CheckpointPolicy& policy, int64_t max_seqs,
|
||||
int64_t ctx, int64_t interval, int64_t slot_bytes,
|
||||
int64_t share_bytes, int64_t room_bytes);
|
||||
|
||||
/* ------------------------------------------------------------------ the cache */
|
||||
class PrefixCache {
|
||||
public:
|
||||
@@ -168,11 +200,13 @@ public:
|
||||
* cached_groups() order, ready for KVManager::adopt().
|
||||
*
|
||||
* Never returns the whole prompt: one token must remain to compute a logit from, so a full
|
||||
* hit is backed off by one block. `cap`, when given, ends the hit early (HitCap). */
|
||||
* hit is backed off by one block. `cap`, when given, ends the hit early (HitCap). `session`,
|
||||
* when not 0, is the request being admitted: it takes over the snapshots on the chain it hit
|
||||
* (take_over). */
|
||||
CacheHit lookup(const std::vector<int32_t>& tokens,
|
||||
const std::vector<MMContentKey>& mm,
|
||||
std::vector<std::vector<int32_t>>* blocks_out = nullptr,
|
||||
const HitCap* cap = nullptr) const;
|
||||
const HitCap* cap = nullptr, uint64_t session = 0) const;
|
||||
|
||||
/* Publish the whole blocks a sequence just filled. `blocks[i]` is the block table of
|
||||
* cached_groups()[i]. Takes a KV reference on every newly indexed block. */
|
||||
@@ -347,6 +381,12 @@ private:
|
||||
/* Retire one snapshot: free its slot and tell the tiers. The session index is left to the
|
||||
* caller. */
|
||||
void retire_ckpt(std::unordered_map<BlockHash, Ckpt, BlockHashHash>::iterator it);
|
||||
/* Move every snapshot on the chain `hs` at or below `upto` tokens under `session`. A
|
||||
* conversation's snapshots belong to its latest turn: sessions are request ids, so otherwise
|
||||
* each earlier turn's deepest snapshot would stay a protected tip, and a running turn would be
|
||||
* a second session beside its conversation, two ladders where retention should keep one.
|
||||
* The admission's lookup and the publish both call it. */
|
||||
void take_over(uint64_t session, const std::vector<BlockHash>& hs, int64_t upto) const;
|
||||
/* Take one key out of a session's index entry, and the entry when it empties. */
|
||||
void unindex_ckpt(uint64_t session, const BlockHash& key);
|
||||
/* For the debug lines: whether `c` is its session's deepest snapshot, and seconds since a
|
||||
@@ -375,7 +415,7 @@ private:
|
||||
std::unordered_map<BlockHash, int32_t, BlockHashHash> held_;
|
||||
bool released_ = false;
|
||||
mutable std::unordered_map<BlockHash, Ckpt, BlockHashHash> ck_by_prefix_;
|
||||
std::unordered_map<uint64_t, std::vector<BlockHash>> ck_by_session_;
|
||||
mutable std::unordered_map<uint64_t, std::vector<BlockHash>> ck_by_session_;
|
||||
/* Snapshots lookup handed out since begin_step; kept in their slots until the next one. */
|
||||
mutable std::vector<BlockHash> handed_;
|
||||
bool handed(const BlockHash& h) const {
|
||||
|
||||
Reference in new issue
Block a user