Archived
radiance 1.3.0
- #47: llama-server's request fields, routes and sampler order, and /props (with baKon's model entry: max_model_len, root and capabilities on /v1/models, and /v1/models/:id) - new APIs: Anthropic's Messages API (/v1/messages), OpenAI's Responses API (/v1/responses), llama-server's /completion and /infill, logprobs (OpenAI's logprobs and top_logprobs, up to 20; llama-server's n_probs), OpenAI's legacy `functions`, and X-Api-Key beside the bearer key - #4: --model takes a Hugging Face repo id (owner/name), fetched before startup into ~/.cache/radiance/hf or --download-dir and checked for changes at every start (redxherring) - #46: --tp 3 --tp-wire wht6 serves -- a three-rank two-shot all-reduce with uneven shards and the tiered-int8 wire over it (baKon); scripts/cardclock.py names what holds each card's clock under load (baKon) - CPU-only serving works again; --kernels names the kernel libraries to load; a model the loaded libraries cannot fully serve refuses at startup instead of failing its first request; --vram-kv-mib and --vram-weights-mib are gone (the split is automatic) - --embedding-placement ram is the default, and `auto` is gone - #40: Swift 1.5 recipes; rad-convert reads which shard holds a tensor from the index - #53: the pinned host pool gets huge pages where shmem THP is off; #57: a crash on video with an odd frame width is fixed
This commit is contained in:
1 parent
6a2ee986d6
commit
89cee7ce41
107 files changed
+6849
-1091
No files matched your search
+40
-18
@@ -264,18 +264,23 @@ int meta_from_config_json(const std::string& dir, MetaOwn* out) {
|
||||
* be a linear position divide for llama3, longrope or YaRN. */
|
||||
m.rope_scale = 1.0f;
|
||||
|
||||
/* The quantisation descriptor, which with the architecture selects the plugin (spec §2.4).
|
||||
* "fp8" plus its format, so qwen35_fp8 and qwen35_bf16 are told apart by the checkpoint
|
||||
* rather than by a flag. */
|
||||
if (const char* qm = gs("quantization_config.quant_method")) {
|
||||
out->quant = qm;
|
||||
if (const char* fm = gs("quantization_config.fmt")) { out->quant += "_"; out->quant += fm; }
|
||||
}
|
||||
|
||||
out->quant = quant_descriptor(*out);
|
||||
out->finish();
|
||||
return RAD_OK;
|
||||
}
|
||||
|
||||
/* The quantisation descriptor, which with the architecture selects the plugin (spec §2.4).
|
||||
* "fp8" plus its format, so qwen35_fp8 and qwen35_bf16 are told apart by the checkpoint
|
||||
* rather than by a flag. */
|
||||
std::string quant_descriptor(const MetaOwn& m) {
|
||||
std::string q;
|
||||
if (const char* qm = m.get("quantization_config.quant_method")) {
|
||||
q = qm;
|
||||
if (const char* fm = m.get("quantization_config.fmt")) { q += "_"; q += fm; }
|
||||
}
|
||||
return q;
|
||||
}
|
||||
|
||||
int meta_from_gguf(GgufFile& g, MetaOwn* out) {
|
||||
if (!g.get_str("general.architecture", &out->arch)) {
|
||||
RAD_ERR("the GGUF has no general.architecture, so no architecture plugin can be chosen");
|
||||
@@ -414,10 +419,24 @@ int Checkpoint::open_gguf(const std::string& path) {
|
||||
return meta_from_gguf(gguf_, &meta_);
|
||||
}
|
||||
|
||||
int Checkpoint::add_shard(const std::string& p, const std::string& prefix) {
|
||||
int Checkpoint::add_shard(const std::string& p, const std::string& prefix,
|
||||
const std::unordered_map<std::string, std::string>* owner) {
|
||||
shards_.push_back(std::make_unique<SafeTensorsFile>());
|
||||
RAD_TRY(shards_.back()->open(p));
|
||||
const std::string file = p.substr(p.find_last_of('/') + 1);
|
||||
for (const auto& t : shards_.back()->tensors()) {
|
||||
/* THE INDEX SAYS WHICH SHARD A TENSOR IS READ FROM. A directory that merges two
|
||||
* checkpoints -- a finetune's changed tensors in its own shards beside links to the base
|
||||
* model's -- holds some names in two shards, and only the index tells the copies apart. */
|
||||
if (owner) {
|
||||
auto it = owner->find(t.name);
|
||||
if (it != owner->end() && it->second != file) continue;
|
||||
}
|
||||
if (index_.count(prefix + t.name)) {
|
||||
RAD_ERR("%s: '%s' is also in %s, and no index entry says which copy to read", p.c_str(),
|
||||
t.name.c_str(), shards_[index_shard_[prefix + t.name]]->path().c_str());
|
||||
return RAD_E_FORMAT;
|
||||
}
|
||||
if (t.dtype == RAD_DT_INVALID) {
|
||||
RAD_ERR("%s: '%s' has dtype %s, which has no RAD equivalent", p.c_str(),
|
||||
t.name.c_str(), t.dtype_str.c_str());
|
||||
@@ -429,6 +448,7 @@ int Checkpoint::add_shard(const std::string& p, const std::string& prefix) {
|
||||
s.shape = t.shape; /* safetensors is already row-major */
|
||||
s.data = t.data;
|
||||
s.bytes = (int64_t)t.bytes;
|
||||
index_shard_.emplace(s.name, shards_.size() - 1);
|
||||
index_.emplace(s.name, tensors_.size());
|
||||
tensors_.push_back(std::move(s));
|
||||
}
|
||||
@@ -437,13 +457,13 @@ int Checkpoint::add_shard(const std::string& p, const std::string& prefix) {
|
||||
|
||||
namespace {
|
||||
|
||||
/* Every shard an index names, once each and in name order, or the one model.safetensors. */
|
||||
/* Every shard an index names, once each and in name order, or the one model.safetensors; `map`
|
||||
* is the index's weight_map, empty without one. */
|
||||
int shard_list(const std::string& dir, const std::string& index, bool index_given,
|
||||
std::vector<std::string>* out) {
|
||||
std::unordered_map<std::string, std::string> map;
|
||||
const int s = st_load_index(index, &map);
|
||||
std::vector<std::string>* out, std::unordered_map<std::string, std::string>* map) {
|
||||
const int s = st_load_index(index, map);
|
||||
if (s == RAD_OK) {
|
||||
for (auto& [t, f] : map)
|
||||
for (auto& [t, f] : *map)
|
||||
if (std::find(out->begin(), out->end(), f) == out->end()) out->push_back(f);
|
||||
std::sort(out->begin(), out->end());
|
||||
for (auto& f : *out) f = dir + "/" + f;
|
||||
@@ -460,6 +480,7 @@ int Checkpoint::open_safetensors(const std::string& path) {
|
||||
kind_ = SafeT;
|
||||
/* One shard, an index, or the directory holding either: one namespace whichever it is. */
|
||||
std::vector<std::string> shards;
|
||||
std::unordered_map<std::string, std::string> owner;
|
||||
const bool is_index = path.size() > 10 && path.compare(path.size() - 10, 10, "index.json") == 0;
|
||||
const bool is_file = path.size() > 12 &&
|
||||
path.compare(path.size() - 12, 12, ".safetensors") == 0;
|
||||
@@ -467,9 +488,9 @@ int Checkpoint::open_safetensors(const std::string& path) {
|
||||
shards.push_back(path);
|
||||
} else {
|
||||
RAD_TRY(shard_list(dir_, is_index ? path : dir_ + "/model.safetensors.index.json",
|
||||
is_index, &shards));
|
||||
is_index, &shards, &owner));
|
||||
}
|
||||
for (const auto& sh : shards) RAD_TRY(add_shard(sh));
|
||||
for (const auto& sh : shards) RAD_TRY(add_shard(sh, "", owner.empty() ? nullptr : &owner));
|
||||
|
||||
RAD_TRY(meta_from_config_json(dir_, &meta_));
|
||||
RAD_TRY(meta_merge_generation_config(dir_, &meta_));
|
||||
@@ -669,8 +690,9 @@ int Checkpoint::add_draft(const std::string& dir, const std::string& prefix) {
|
||||
? prefix
|
||||
: prefix.substr(0, prefix.size() - 1), &meta_));
|
||||
std::vector<std::string> shards;
|
||||
RAD_TRY(shard_list(dir, dir + "/model.safetensors.index.json", false, &shards));
|
||||
for (const auto& sh : shards) RAD_TRY(add_shard(sh, prefix));
|
||||
std::unordered_map<std::string, std::string> owner;
|
||||
RAD_TRY(shard_list(dir, dir + "/model.safetensors.index.json", false, &shards, &owner));
|
||||
for (const auto& sh : shards) RAD_TRY(add_shard(sh, prefix, owner.empty() ? nullptr : &owner));
|
||||
meta_.finish();
|
||||
return RAD_OK;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user