Archived
radiance 1.7.0
- every model serves without a GPU: libavx covers every op, so `--kernels libavx` alone serves every shipped container - Qwen3-ASR (zivius): speech to text on /v1/audio/transcriptions and live over /v1/realtime - /v1/messages works with Claude Code as it ships (gearwave00001) - a long agent conversation keeps its cached history when the client rewrites its last turn (manueloverride) - a stream's first event goes out with the first token, so llama-benchy measures prefill right - opt-in --prefill-interleave (Smellyyyy, baKon) and --prefill-span (keptn42) - four-rank TP releases the link early; four-rank selftests and docs/TP4.md (goodman-b) - NVFP4 and FP8 compressed-tensors imports (devmilan); tools/rad-export for finetunes and LoRA adapters (baKon) - many fixes, among them lost tokens on stop strings under concurrency, keep-alive, MiniCPM5 tool arguments and the CPU's vision and audio encoders - plugin ABI 17 and changed op schemas: out-of-tree plugins must be rebuilt
This commit is contained in:
1 parent
b068190326
commit
1e968f6e1d
739 files changed
+128447
-84632
No files matched your search
+131
-14
@@ -1,14 +1,15 @@
|
||||
/* hf_model_test.cpp -- a --model that names a Hugging Face repo (core/hf_model.h).
|
||||
*
|
||||
* Two questions, both answered before anything is fetched, and both wrong in a way that costs a
|
||||
* download or a confusing refusal:
|
||||
* Both questions are answered before anything is fetched; a wrong answer costs a download or a
|
||||
* confusing refusal.
|
||||
*
|
||||
* IS IT A REPO a path that exists is never looked up, and a missing model FILE is reported as
|
||||
* missing rather than sent to the hub as a repo name
|
||||
* WHAT TO SERVE the hub's model repos hold one container beside a README, a recipe and a
|
||||
* licence; a checkpoint repo holds none and is served as the directory
|
||||
* Is it a repo a path that exists is never looked up, and a missing model file is reported
|
||||
* as missing rather than sent to the hub as a repo name
|
||||
* What to serve a model repo holds one container beside a README, a recipe and a licence;
|
||||
* a checkpoint repo holds none and is served as the directory
|
||||
*
|
||||
* No network: the fetch itself is scripts/hfget.sh, which this does not run.
|
||||
* No network: where the fetch itself runs (scripts/hfget.sh, from the build tree's libexec/), a
|
||||
* `curl` placed first on PATH answers for the hub.
|
||||
*/
|
||||
#include "rad_test.h"
|
||||
|
||||
@@ -18,6 +19,7 @@
|
||||
#include <cstdlib>
|
||||
#include <filesystem>
|
||||
#include <string>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
using namespace rad;
|
||||
@@ -25,16 +27,12 @@ namespace fs = std::filesystem;
|
||||
|
||||
namespace {
|
||||
|
||||
/* A scratch directory of its own, removed with everything in it. */
|
||||
/* An empty directory of its own under the test's temporary directory. */
|
||||
struct TempDir {
|
||||
std::string path;
|
||||
TempDir() {
|
||||
char t[] = "/tmp/hf_model_test.XXXXXX";
|
||||
path = mkdtemp(t) ? t : "";
|
||||
}
|
||||
~TempDir() {
|
||||
std::error_code ec;
|
||||
if (!path.empty()) fs::remove_all(path, ec);
|
||||
std::string t = radtest::tmp_path("dir.XXXXXX");
|
||||
path = mkdtemp(t.data()) ? t : "";
|
||||
}
|
||||
void touch(const std::string& name) const {
|
||||
if (FILE* f = std::fopen((path + "/" + name).c_str(), "w")) std::fclose(f);
|
||||
@@ -121,4 +119,123 @@ TEST(the_download_dir_defaults_to_the_xdg_cache) {
|
||||
if (x) setenv("XDG_CACHE_HOME", saved.c_str(), 1);
|
||||
}
|
||||
|
||||
/* ================================================================== a restart with the hub out of reach */
|
||||
namespace {
|
||||
|
||||
/* Where resolve_hf_model looks for the downloader: libexec/radiance/ beside this binary's
|
||||
* directory, where the build copies it. */
|
||||
std::string hfget_beside_this_binary() {
|
||||
std::error_code ec;
|
||||
const fs::path exe = fs::read_symlink("/proc/self/exe", ec);
|
||||
return (exe.parent_path() / ".." / "libexec" / "radiance" / "hfget.sh").lexically_normal();
|
||||
}
|
||||
|
||||
bool on_path(const char* tool) {
|
||||
const char* path = std::getenv("PATH");
|
||||
std::string all = path ? path : "";
|
||||
size_t at = 0;
|
||||
while (at <= all.size()) {
|
||||
size_t c = all.find(':', at);
|
||||
if (c == std::string::npos) c = all.size();
|
||||
const std::string d = all.substr(at, c - at);
|
||||
if (!d.empty() && ::access((d + "/" + tool).c_str(), X_OK) == 0) return true;
|
||||
at = c + 1;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* PATH with a directory holding a `curl` script first, restored on destruction. */
|
||||
struct FakeCurl {
|
||||
TempDir bin;
|
||||
std::string saved;
|
||||
explicit FakeCurl(const std::string& script) {
|
||||
const char* p = std::getenv("PATH");
|
||||
saved = p ? p : "";
|
||||
const std::string f = bin.path + "/curl";
|
||||
if (FILE* o = std::fopen(f.c_str(), "w")) {
|
||||
std::fputs(script.c_str(), o);
|
||||
std::fclose(o);
|
||||
}
|
||||
::chmod(f.c_str(), 0755);
|
||||
setenv("PATH", (bin.path + ":" + saved).c_str(), 1);
|
||||
}
|
||||
~FakeCurl() { setenv("PATH", saved.c_str(), 1); }
|
||||
};
|
||||
|
||||
/* A hub that cannot be reached: every request fails as curl does without a network. hfget.sh
|
||||
* exits 3 (nothing on disk changed). */
|
||||
const char* kOffline = "#!/bin/sh\nexit 6\n";
|
||||
/* A hub that lists a file and then fails to send it: hfget.sh exits 1 (a file may be partial). */
|
||||
const char* kBrokenTransfer =
|
||||
"#!/bin/sh\n"
|
||||
"for a in \"$@\"; do case \"$a\" in *api/models*)\n"
|
||||
" printf '[{\"type\":\"file\",\"path\":\"new.bin\",\"size\":5}]'; exit 0;; esac; done\n"
|
||||
"exit 22\n";
|
||||
|
||||
} /* namespace */
|
||||
|
||||
/* hfget.sh exits 3 when it changed nothing on disk, and a copy a complete fetch left (it has the
|
||||
* success manifest) is then served, with a warning, so a restart does not need the hub. Without
|
||||
* the manifest the copy may be incomplete; after any other failure a file may be partial; either
|
||||
* way nothing is served. */
|
||||
TEST(a_restart_serves_the_complete_copy_when_the_hub_cannot_be_reached) {
|
||||
NEED_ARTIFACT(hfget_beside_this_binary());
|
||||
if (!on_path("jq")) SKIP("no jq on PATH, which hfget.sh needs");
|
||||
TempDir root;
|
||||
REQUIRE(!root.path.empty());
|
||||
const std::string repo = "radiance-test-owner/radiance-test-model";
|
||||
const std::string dest = root.path + "/" + repo;
|
||||
fs::create_directories(dest);
|
||||
if (FILE* f = std::fopen((dest + "/m.rad").c_str(), "w")) std::fclose(f);
|
||||
|
||||
auto resolve = [&](std::string* model, std::string* log) {
|
||||
Config c;
|
||||
c.model = repo;
|
||||
c.download_dir = root.path;
|
||||
bool ok = false;
|
||||
*log = stderr_of([&] { ok = resolve_hf_model(c); });
|
||||
*model = c.model;
|
||||
return ok;
|
||||
};
|
||||
std::string model, log;
|
||||
{
|
||||
FakeCurl curl(kOffline);
|
||||
/* No manifest: an interrupted first fetch, refused. */
|
||||
CHECK(!resolve(&model, &log));
|
||||
CHECK(has(log, "exit 3"));
|
||||
|
||||
if (FILE* f = std::fopen((dest + "/.hfget-manifest").c_str(), "w")) {
|
||||
std::fputs("0\tm.rad\n", f);
|
||||
std::fclose(f);
|
||||
}
|
||||
CHECK(resolve(&model, &log));
|
||||
CHECK_EQ(model, dest + "/m.rad");
|
||||
CHECK(has(log, "serving the copy fetched before"));
|
||||
}
|
||||
{
|
||||
FakeCurl curl(kBrokenTransfer);
|
||||
CHECK(!resolve(&model, &log));
|
||||
CHECK(has(log, "exit 1"));
|
||||
}
|
||||
}
|
||||
|
||||
/* With no --download-dir and neither XDG_CACHE_HOME nor HOME there is nowhere to fetch to, which
|
||||
* is refused by name before anything runs. */
|
||||
TEST(a_repo_id_with_nowhere_to_fetch_to_is_refused) {
|
||||
const char* x = std::getenv("XDG_CACHE_HOME");
|
||||
const char* h = std::getenv("HOME");
|
||||
const std::string sx = x ? x : "", sh = h ? h : "";
|
||||
unsetenv("XDG_CACHE_HOME");
|
||||
unsetenv("HOME");
|
||||
Config c;
|
||||
c.model = "radiance-test-owner/radiance-test-model";
|
||||
bool ok = true;
|
||||
const std::string log = stderr_of([&] { ok = resolve_hf_model(c); });
|
||||
CHECK(!ok);
|
||||
CHECK(has(log, "--download-dir"));
|
||||
CHECK_EQ(c.model, std::string("radiance-test-owner/radiance-test-model"));
|
||||
if (x) setenv("XDG_CACHE_HOME", sx.c_str(), 1);
|
||||
if (h) setenv("HOME", sh.c_str(), 1);
|
||||
}
|
||||
|
||||
RAD_TEST_MAIN()
|
||||
Reference in new issue
Block a user