From 1577854d00d46f5d28d91c489ea1d43b25b74025 Mon Sep 17 00:00:00 2001 From: fl0l0u Date: Fri, 30 Oct 2026 12:57:54 +0000 Subject: [PATCH] hfget+deploy: fetch a repo on verified claims, and run with a key argv cannot show The --model repo-id path trusts the hub with the machine's filesystem and the container runs with the kernel's door off. Both stop here. hfget.sh trusted a listing's file names to be names: an absolute path or a .. segment wrote wherever the destination's owner could write, and a name shadowing .hfget-manifest taught the next run whatever it liked. A listing is now vetted whole before anything is fetched -- absolute paths, .. segments, control characters (a tab splices one entry into two fields), names of hfget's own manifest -- and a child refuses a path that would escape anyway. Silent skipping was the alternative, and it leaves a directory that reads as complete and is not. And the content key was the hub's claim, never checked: an LFS file was kept for its size and its claimed oid recorded without ever hashing the download, so a swapped file of equal length -- or a spliced resume at any length -- passed forever after. The download is hashed on arrival and kept only when it matches the claimed sha256; a mismatch deletes the file, and the manifest now certifies verified content. --model-revision REV fetches at a branch, tag, sha or refs/pr/N instead of the moving main: without it a restart can serve weights nobody reviewed, and the guide now says to name one. --api-key-env NAME reads the key from the environment, where only the process and root can reach it, not the command line where every process on the host reads it in ps; an unset or empty variable refuses startup exactly like an empty --api-key. The compose files carry the key through environment: now -- the fail-closed :? guard moves with it -- across all 52 model files. And the containers' seccomp=unconfined has a way out: Docker's default profile, plus exactly the calls that forced the escape -- io_uring for the n-gram table, mbind/set_mempolicy/get_mempolicy for ROCm's NUMA binding -- is shipped as seccomp-radiance.json and selected through RADIANCE_SECCOMP; the default stays unconfined until each operator audits their own card stack. Verified: under the profile io_uring_setup and set_mempolicy behave as under unconfined and a non-listed syscall earns EPERM. hf_model_test: the escape-listing refusal, the oid verify (bad rejected and deleted, good certified), the pinned revision fetched -- against a fake curl for a hub. config_test: --api-key-env fails closed unset, reads the key set. ASan+UBSan: config/diag/hf_model/server/transport/ wire/lifecycle, 8/8. --- core/config.cpp | 24 + core/hf_model.cpp | 11 +- core/rad_core.h | 5 + deploy/compose/.env.example | 9 +- deploy/compose/anima.yaml | 2 +- deploy/compose/breeze-tts2.yaml | 2 +- deploy/compose/common.yaml | 12 +- deploy/compose/drama3.yaml | 2 +- deploy/compose/embeddinggemma2.yaml | 2 +- deploy/compose/fasth3.yaml | 2 +- deploy/compose/flashnext-bf16.yaml | 2 +- deploy/compose/flashnext-tp1.yaml | 2 +- deploy/compose/flashnext.yaml | 2 +- deploy/compose/flux-3-klein.yaml | 2 +- .../compose/gemma4-31b-heretic-ara-w4a8.yaml | 2 +- deploy/compose/gemma4-31b-q8-df.yaml | 2 +- deploy/compose/gemma4-31b-w4a8-df.yaml | 2 +- deploy/compose/gemma4-31b-w4a8-df2-tp4.yaml | 2 +- .../compose/gemma4-31b-w4a8-df2b16-tp2.yaml | 2 +- .../compose/gemma4-31b-w4a8-df2b16-tp4.yaml | 2 +- deploy/compose/gemma4-31b-w4a8.yaml | 2 +- deploy/compose/glm53-flash.yaml | 2 +- deploy/compose/krea-2-raw.yaml | 2 +- deploy/compose/krea-2-turbo.yaml | 2 +- deploy/compose/ltx-2.5.yaml | 2 +- deploy/compose/minicpm5-2b-bf16.yaml | 2 +- deploy/compose/minicpm5-2b.yaml | 2 +- deploy/compose/minimax-h3.yaml | 2 +- deploy/compose/minimax-music3.yaml | 2 +- .../compose/nemotron-3.5-bolt-e4b-a4-tp1.yaml | 2 +- deploy/compose/nemotron-3.5-bolt-e4b-a4.yaml | 2 +- .../nemotron-3.5-bolt-e4b-bf16-tp1.yaml | 2 +- .../compose/nemotron-3.5-bolt-e4b-bf16.yaml | 2 +- .../nemotron-3.5-bolt-e4b-i8g-tp1.yaml | 2 +- deploy/compose/nemotron-3.5-bolt-e4b-i8g.yaml | 2 +- deploy/compose/ornith-1.5-122b-df2.yaml | 2 +- deploy/compose/ornith-1.5-122b-w4a8-df2.yaml | 2 +- deploy/compose/ornith-1.5-122b-w4a8.yaml | 2 +- deploy/compose/ornith-1.5-122b.yaml | 2 +- .../compose/ornith-1.5-35b-a3b-w4a8-tp1.yaml | 2 +- deploy/compose/ornith-1.5-35b-a3b-w4a8.yaml | 2 +- deploy/compose/ornith-1.5-35b-a3b.yaml | 2 +- deploy/compose/qwen-image-2.1-turbo.yaml | 2 +- deploy/compose/qwen-image-2.1.yaml | 2 +- deploy/compose/qwen3-asr-1.7b.yaml | 2 +- deploy/compose/qwen3.6-35b-a3b.yaml | 2 +- deploy/compose/qwen3.8-27b-bf16.yaml | 2 +- deploy/compose/qwen3.8-27b-fp8.yaml | 2 +- deploy/compose/qwen3.8-27b-mxfp4.yaml | 2 +- deploy/compose/qwen3.8-27b-paro.yaml | 2 +- deploy/compose/sage-a1.5-df2.yaml | 2 +- deploy/compose/sage-a1.5-mxfp4-df2.yaml | 2 +- deploy/compose/sage-a1.5-tp1.yaml | 2 +- deploy/compose/sage-a1.5.yaml | 2 +- deploy/compose/sdxl.yaml | 2 +- deploy/compose/seccomp-radiance.json | 1238 +++++++++++++++++ deploy/compose/translategemma-27b.yaml | 2 +- deploy/compose/unlimited-ocr-bf16.yaml | 2 +- docs/GUIDE.md | 10 +- scripts/hfget.sh | 39 +- tests/config_test.cpp | 20 + tests/hf_model_test.cpp | 140 ++ 62 files changed, 1551 insertions(+), 61 deletions(-) create mode 100644 deploy/compose/seccomp-radiance.json diff --git a/core/config.cpp b/core/config.cpp index 2df429f0..78133a37 100644 --- a/core/config.cpp +++ b/core/config.cpp @@ -49,6 +49,8 @@ static const Flag g_flags[] = { "Hugging Face repo id (owner/name), fetched before startup" }, { "--download-dir", "DIR", "where a repo id is fetched to; default\n" "$XDG_CACHE_HOME/radiance/hf, else ~/.cache/radiance/hf" }, + { "--model-revision", "REV", "the hub revision -- a branch, tag, full commit sha or refs/pr/N --\n" + "a repo id is fetched at; default the repo's moving main branch" }, { "--radiance-home", "DIRS", "where kernels/, architectures/ and quantizers/ live; several\n" "homes separated by ':' are searched in order, the first winning" }, { "--kernels", "LIST", "the kernel libraries to use, separated by ',' or ':', first wins; unnamed ones are not loaded. Default: every library found" }, @@ -213,6 +215,8 @@ static const Flag g_flags[] = { { "--port", "N", "listen port" }, { "--api-key", "KEY", "require `Authorization: Bearer KEY` or `X-Api-Key: KEY` on every request but /health,\n" " /v1/health, /ping and the dashboard page" }, + { "--api-key-env", "NAME", "read the API key from the named environment variable; keeps it off the\n" + " command line, where every process on the machine can read it" }, { "--allow-host", "NAME", "a Host name the keyless loopback-only routes (/diagnostics,\n" " /admin/control-vector, the LoRA and session admin) accept besides\n" " localhost; repeatable" }, @@ -523,6 +527,7 @@ int config_parse(int argc, char** argv, Config* c) { else if (S("-vv")) log_set_level(Log::Trace); else if (S("--model")) { if (!(v = need(i))) return RAD_E_INVAL; c->model = v; } else if (S("--download-dir")) { if (!(v = need(i))) return RAD_E_INVAL; c->download_dir = v; } + else if (S("--model-revision")) { if (!(v = need(i))) return RAD_E_INVAL; c->model_revision = v; } else if (S("--radiance-home")) { if (!(v = need(i))) return RAD_E_INVAL; c->radiance_home = v; } else if (S("--kernels")) { if (!(v = need(i))) return RAD_E_INVAL; c->kernel_hierarchy = rad_split_kernel_list(v); } else if (S("--tp")) { if (!num(1, INT32_MAX, &c->tp)) return RAD_E_INVAL; } @@ -823,6 +828,23 @@ int config_parse(int argc, char** argv, Config* c) { return RAD_E_INVAL; } c->api_key = v; } + else if (S("--api-key-env")) { + if (!(v = need(i))) return RAD_E_INVAL; + if (!*v) { RAD_ERR("--api-key-env takes the name of an environment variable"); + return RAD_E_INVAL; } + const char* k = std::getenv(v); + /* The empty --api-key refusal's sibling: a unit or compose file whose variable was + * never set must not start a server that looks guarded and answers everything + * keyless. The name is recorded so the config report can say where the key came + * from without showing it. */ + if (!k || !*k) { + RAD_ERR("--api-key-env: %s is unset or empty; refusing to serve keyless under a " + "guarded-looking command line", v); + return RAD_E_INVAL; + } + c->api_key = k; + c->api_key_env = v; + } else if (S("--allow-host")) { if (!(v = need(i))) return RAD_E_INVAL; if (!*v) { RAD_ERR("--allow-host takes a non-empty name"); return RAD_E_INVAL; } @@ -1269,6 +1291,7 @@ struct ShowRow { const char* flag; Show show; }; const ShowRow kShow[] = { { "--model", [](const Config& c) { return c.model; } }, { "--download-dir", [](const Config& c) { return or_none(c.download_dir, "the XDG cache (~/.cache/radiance/hf)"); } }, + { "--model-revision", [](const Config& c) { return or_none(c.model_revision, "the repo's main branch"); } }, { "--radiance-home", [](const Config& c) { return c.radiance_home; } }, { "--kernels", [](const Config& c) { std::string s; @@ -1352,6 +1375,7 @@ const ShowRow kShow[] = { { "--port", [](const Config& c) { return num(c.port); } }, /* Never print the secret, only whether it is set. */ { "--api-key", [](const Config& c) { return std::string(c.api_key.empty() ? "not set" : "set"); } }, + { "--api-key-env", [](const Config& c) { return or_none(c.api_key_env, "not used"); } }, { "--allow-host", [](const Config& c) { std::string o; for (const std::string& h : c.allow_hosts) o += (o.empty() ? "" : ",") + h; diff --git a/core/hf_model.cpp b/core/hf_model.cpp index 66f85efa..5f3d5f0a 100644 --- a/core/hf_model.cpp +++ b/core/hf_model.cpp @@ -51,15 +51,18 @@ std::string hfget_path() { return fs::is_regular_file(p, ec) ? p.lexically_normal().string() : std::string(); } -/* The script's exit status, or -1 when it could not be run. */ -int run_hfget(const std::string& script, const std::string& repo, const std::string& dest) { +/* The script's exit status, or -1 when it could not be run. `rev` empty leaves the script's own + * default: the repo's moving default branch. */ +int run_hfget(const std::string& script, const std::string& repo, const std::string& dest, + const std::string& rev) { const pid_t pid = fork(); if (pid < 0) { RAD_ERR("hfget: fork: %s", std::strerror(errno)); return -1; } if (pid == 0) { - const char* argv[] = { "sh", script.c_str(), repo.c_str(), dest.c_str(), nullptr }; + const char* argv[] = { "sh", script.c_str(), repo.c_str(), dest.c_str(), + rev.empty() ? nullptr : rev.c_str(), nullptr }; execv("/bin/sh", const_cast(argv)); std::fprintf(stderr, "hfget: /bin/sh: %s\n", std::strerror(errno)); _exit(127); @@ -134,7 +137,7 @@ bool resolve_hf_model(Config& c) { } RAD_INFO("model: %s is not a path here; fetching it as a Hugging Face repo into %s", repo.c_str(), dest.c_str()); - const int rc = run_hfget(script, repo, dest); + const int rc = run_hfget(script, repo, dest, c.model_revision); if (rc != 0) { if (rc == 3 && cached) { RAD_WARN("model: %s could not be checked for changes (hfget.sh, above); serving the " diff --git a/core/rad_core.h b/core/rad_core.h index 7efca3ec..83407b1b 100644 --- a/core/rad_core.h +++ b/core/rad_core.h @@ -787,6 +787,8 @@ struct Config { std::string model; /* path to the .rad, or a Hugging Face repo id (hf_model.h) */ LoraConfig lora; /* --lora, --max-loras, --max-lora-rank, --lora-target-modules */ std::string download_dir; /* where a repo id is fetched to; empty = the XDG cache */ + std::string model_revision; /* --model-revision: the hub revision a repo id fetches; + empty = the repo's moving default branch */ std::string radiance_home; std::vector kernel_hierarchy; /* ordered; first wins */ @@ -1049,6 +1051,9 @@ struct Config { /* --api-key: the bearer key every request but the probes and the dashboard page must carry. * Empty serves without one. */ std::string api_key; + /* --api-key-env: the environment variable api_key was read from, recorded so the config + * report can say where the key came from. Empty when the key came from the command line. */ + std::string api_key_env; /* --allow-host, repeatable: Host names the keyless loopback-only routes accept beside the * loopback names themselves, for operators who reach the box by another name. */ std::vector allow_hosts; diff --git a/deploy/compose/.env.example b/deploy/compose/.env.example index d6941845..d74ccda3 100644 --- a/deploy/compose/.env.example +++ b/deploy/compose/.env.example @@ -8,7 +8,8 @@ RADIANCE_IMAGE=stilldeadcode/radiance:latest RADIANCE_MODELS=/srv/models/rad # Every request but /health, /ping and the dashboard page must carry `Authorization: Bearer ` -# (or `X-Api-Key: `). +# (or `X-Api-Key: `). It enters the container through the environment (--api-key-env), not +# the command line, where every process on the host could read it in `ps`. RADIANCE_API_KEY= # The port the server listens on. @@ -23,3 +24,9 @@ VIDEO_GID= # The card a one-card model runs on (embeddinggemma2.yaml), by index. RADIANCE_GPU=0 + +# Run the container under a seccomp profile: Docker's default plus exactly the calls radiance +# needs beyond it (io_uring for the n-gram table, the NUMA binding calls) is seccomp-radiance.json +# beside this file. Give its absolute path on the host to confine; unset runs unconfined, which is +# what these files have always done, because the stock Docker default blocks radiance's startup. +#RADIANCE_SECCOMP=/srv/radiance/deploy/compose/seccomp-radiance.json diff --git a/deploy/compose/anima.yaml b/deploy/compose/anima.yaml index 794863e3..9be9e8d6 100644 --- a/deploy/compose/anima.yaml +++ b/deploy/compose/anima.yaml @@ -15,5 +15,5 @@ services: ROCR_VISIBLE_DEVICES: "${RADIANCE_GPU:-0}" command: > --model /models/anima-aesthetic-fp8.rad - --host :: --port ${PORT:-8000} --api-key ${RADIANCE_API_KEY:?set RADIANCE_API_KEY in .env} + --host :: --port ${PORT:-8000} --api-key-env RADIANCE_API_KEY --tp 1 diff --git a/deploy/compose/breeze-tts2.yaml b/deploy/compose/breeze-tts2.yaml index 8081a2b2..921c2bc8 100644 --- a/deploy/compose/breeze-tts2.yaml +++ b/deploy/compose/breeze-tts2.yaml @@ -11,5 +11,5 @@ services: ROCR_VISIBLE_DEVICES: "${RADIANCE_GPU:-0}" command: > --model /models/breeze-tts2-bf16.rad - --host :: --port ${PORT:-8000} --api-key ${RADIANCE_API_KEY:?set RADIANCE_API_KEY in .env} + --host :: --port ${PORT:-8000} --api-key-env RADIANCE_API_KEY --tp 1 diff --git a/deploy/compose/common.yaml b/deploy/compose/common.yaml index 0a67f552..beba7e5b 100644 --- a/deploy/compose/common.yaml +++ b/deploy/compose/common.yaml @@ -23,11 +23,19 @@ services: group_add: - "${RENDER_GID:?set RENDER_GID in .env}" - "${VIDEO_GID:?set VIDEO_GID in .env}" + # The API key reaches the server through the container's environment, read by + # --api-key-env, not its command line: argv is world-readable in `ps` and /proc, the + # environment only by the process itself and root. The :? still fails closed on an unset + # value, at compose-parse time, before any container starts. + environment: + RADIANCE_API_KEY: ${RADIANCE_API_KEY:?set RADIANCE_API_KEY in .env} # Docker's default seccomp profile refuses io_uring (used for the n-gram table's reads from the # model file) and the NUMA binding calls (mbind, set_mempolicy) the ROCm runtime makes for - # host memory. + # host memory. seccomp-radiance.json beside this file is Docker's default plus exactly those + # calls; point RADIANCE_SECCOMP at it (absolute host path) to run confined, and audit your + # own card stack before you do -- unset, the service runs unconfined, as it always has. security_opt: - - seccomp=unconfined + - seccomp=${RADIANCE_SECCOMP:-unconfined} ulimits: memlock: -1 volumes: diff --git a/deploy/compose/drama3.yaml b/deploy/compose/drama3.yaml index 6d95f2be..45edd364 100644 --- a/deploy/compose/drama3.yaml +++ b/deploy/compose/drama3.yaml @@ -12,5 +12,5 @@ services: container_name: radiance-drama3 command: > --model /models/drama3-fp8.rad - --host :: --port ${PORT:-8000} --api-key ${RADIANCE_API_KEY:?set RADIANCE_API_KEY in .env} + --host :: --port ${PORT:-8000} --api-key-env RADIANCE_API_KEY --tp 2 diff --git a/deploy/compose/embeddinggemma2.yaml b/deploy/compose/embeddinggemma2.yaml index e922ac4b..1c3a483f 100644 --- a/deploy/compose/embeddinggemma2.yaml +++ b/deploy/compose/embeddinggemma2.yaml @@ -11,5 +11,5 @@ services: ROCR_VISIBLE_DEVICES: "${RADIANCE_GPU:-0}" command: > --model /models/embeddinggemma2-bf16.rad - --host :: --port ${PORT:-8000} --api-key ${RADIANCE_API_KEY:?set RADIANCE_API_KEY in .env} + --host :: --port ${PORT:-8000} --api-key-env RADIANCE_API_KEY --tp 1 --max-num-seqs 64 --max-num-batched-tokens 8192 diff --git a/deploy/compose/fasth3.yaml b/deploy/compose/fasth3.yaml index f6c265b3..bdc45e78 100644 --- a/deploy/compose/fasth3.yaml +++ b/deploy/compose/fasth3.yaml @@ -12,5 +12,5 @@ services: container_name: radiance-fasth3 command: > --model /models/fasth3-8-step-v2-fp8.rad - --host :: --port ${PORT:-8000} --api-key ${RADIANCE_API_KEY:?set RADIANCE_API_KEY in .env} + --host :: --port ${PORT:-8000} --api-key-env RADIANCE_API_KEY --tp 2 --vision-tower-placement ram diff --git a/deploy/compose/flashnext-bf16.yaml b/deploy/compose/flashnext-bf16.yaml index c442e83b..a28e4126 100644 --- a/deploy/compose/flashnext-bf16.yaml +++ b/deploy/compose/flashnext-bf16.yaml @@ -10,7 +10,7 @@ services: container_name: radiance-flashnext-bf16 command: > --model /models/qwen3.8-flash-next-bf16.rad - --host :: --port ${PORT:-8000} --api-key ${RADIANCE_API_KEY:?set RADIANCE_API_KEY in .env} + --host :: --port ${PORT:-8000} --api-key-env RADIANCE_API_KEY --tp 2 --max-model-len 32768 --placement expert_tiered --weights-disk-tier --host-pool-mib 12288 --gpu-headroom-mib 768 --deterministic --max-num-seqs 32 --max-num-batched-tokens 32768 --num-speculative-tokens 0 diff --git a/deploy/compose/flashnext-tp1.yaml b/deploy/compose/flashnext-tp1.yaml index 47988b1a..ed93c8d9 100644 --- a/deploy/compose/flashnext-tp1.yaml +++ b/deploy/compose/flashnext-tp1.yaml @@ -15,7 +15,7 @@ services: container_name: radiance-flashnext-tp1 command: > --model /models/qwen3.8-next-flash-fp8-iq4r-moe.rad - --host :: --port ${PORT:-8000} --api-key ${RADIANCE_API_KEY:?set RADIANCE_API_KEY in .env} + --host :: --port ${PORT:-8000} --api-key-env RADIANCE_API_KEY --tp 1 --max-num-seqs 4 --max-model-len 200000 --placement expert_tiered --host-pool-mib 43000 --gpu-headroom-mib 96 --kv-cache-dtype fp8 diff --git a/deploy/compose/flashnext.yaml b/deploy/compose/flashnext.yaml index 62e43f9e..4ed4bdd5 100644 --- a/deploy/compose/flashnext.yaml +++ b/deploy/compose/flashnext.yaml @@ -8,7 +8,7 @@ services: container_name: radiance-flashnext command: > --model /models/qwen3.8-next-flash-fp8-iq4r-moe.rad - --host :: --port ${PORT:-8000} --api-key ${RADIANCE_API_KEY:?set RADIANCE_API_KEY in .env} + --host :: --port ${PORT:-8000} --api-key-env RADIANCE_API_KEY --tp 2 --tp-wire wht6 --max-num-seqs 8 --max-model-len 200000 --placement expert_tiered --host-pool-mib 12288 --gpu-headroom-mib 96 --kv-cache-dtype fp8 diff --git a/deploy/compose/flux-3-klein.yaml b/deploy/compose/flux-3-klein.yaml index ecc70aba..7fcc5f87 100644 --- a/deploy/compose/flux-3-klein.yaml +++ b/deploy/compose/flux-3-klein.yaml @@ -14,5 +14,5 @@ services: ROCR_VISIBLE_DEVICES: "${RADIANCE_GPU:-0}" command: > --model /models/flux-3-klein-fp8.rad - --host :: --port ${PORT:-8000} --api-key ${RADIANCE_API_KEY:?set RADIANCE_API_KEY in .env} + --host :: --port ${PORT:-8000} --api-key-env RADIANCE_API_KEY --tp 1 diff --git a/deploy/compose/gemma4-31b-heretic-ara-w4a8.yaml b/deploy/compose/gemma4-31b-heretic-ara-w4a8.yaml index 9fd27492..e3df5090 100644 --- a/deploy/compose/gemma4-31b-heretic-ara-w4a8.yaml +++ b/deploy/compose/gemma4-31b-heretic-ara-w4a8.yaml @@ -9,6 +9,6 @@ services: container_name: radiance-gemma4-31b-heretic-ara-w4a8 command: > --model /models/gemma4-31b-heretic-ara-w4a8.rad - --host :: --port ${PORT:-8000} --api-key ${RADIANCE_API_KEY:?set RADIANCE_API_KEY in .env} + --host :: --port ${PORT:-8000} --api-key-env RADIANCE_API_KEY --tp 2 --max-num-seqs 8 --max-model-len 65536 --kv-cache-dtype fp8 --vision-tower-placement ram --num-speculative-tokens 3 --max-num-batched-tokens 2048 --temp 1.0 --top-p 0.95 --top-k 64 diff --git a/deploy/compose/gemma4-31b-q8-df.yaml b/deploy/compose/gemma4-31b-q8-df.yaml index 3ee8ce9c..2be8e522 100644 --- a/deploy/compose/gemma4-31b-q8-df.yaml +++ b/deploy/compose/gemma4-31b-q8-df.yaml @@ -11,6 +11,6 @@ services: container_name: radiance-gemma4-31b-q8-df command: > --model /models/gemma4-31b-dense-q8-df.rad - --host :: --port ${PORT:-8000} --api-key ${RADIANCE_API_KEY:?set RADIANCE_API_KEY in .env} + --host :: --port ${PORT:-8000} --api-key-env RADIANCE_API_KEY --tp 2 --max-num-seqs 8 --max-model-len 65536 --kv-cache-dtype fp8 --num-speculative-tokens auto --max-num-batched-tokens 2048 --temp 1.0 --top-p 0.95 --top-k 64 diff --git a/deploy/compose/gemma4-31b-w4a8-df.yaml b/deploy/compose/gemma4-31b-w4a8-df.yaml index f9e322da..1dbe5a28 100644 --- a/deploy/compose/gemma4-31b-w4a8-df.yaml +++ b/deploy/compose/gemma4-31b-w4a8-df.yaml @@ -12,6 +12,6 @@ services: container_name: radiance-gemma4-31b-w4a8-df command: > --model /models/gemma4-31b-dense-w4a8-df.rad - --host :: --port ${PORT:-8000} --api-key ${RADIANCE_API_KEY:?set RADIANCE_API_KEY in .env} + --host :: --port ${PORT:-8000} --api-key-env RADIANCE_API_KEY --tp 2 --max-num-seqs 8 --max-model-len 65536 --kv-cache-dtype fp8 --num-speculative-tokens auto --max-num-batched-tokens 2048 --temp 1.0 --top-p 0.95 --top-k 64 diff --git a/deploy/compose/gemma4-31b-w4a8-df2-tp4.yaml b/deploy/compose/gemma4-31b-w4a8-df2-tp4.yaml index 120baad2..681af4a2 100644 --- a/deploy/compose/gemma4-31b-w4a8-df2-tp4.yaml +++ b/deploy/compose/gemma4-31b-w4a8-df2-tp4.yaml @@ -28,7 +28,7 @@ services: container_name: radiance-gemma4-31b-w4a8-df2-tp4 command: > --model /models/gemma4-31b-dense-w4a8-df2-qkv.rad - --host :: --port ${PORT:-8000} --api-key ${RADIANCE_API_KEY:?set RADIANCE_API_KEY in .env} + --host :: --port ${PORT:-8000} --api-key-env RADIANCE_API_KEY --tp 4 --max-num-seqs 16 --max-model-len 65536 --kv-cache-dtype fp8 --num-speculative-tokens auto --max-num-batched-tokens 8192 --busy-prefill-chunk 512 --prefill-interleave 1 diff --git a/deploy/compose/gemma4-31b-w4a8-df2b16-tp2.yaml b/deploy/compose/gemma4-31b-w4a8-df2b16-tp2.yaml index 9138028b..43417dbf 100644 --- a/deploy/compose/gemma4-31b-w4a8-df2b16-tp2.yaml +++ b/deploy/compose/gemma4-31b-w4a8-df2b16-tp2.yaml @@ -34,7 +34,7 @@ services: container_name: radiance-gemma4-31b-w4a8-df2b16-tp2 command: > --model /models/gemma4-31b-dense-w4a8-df2b16-qkv.rad - --host :: --port ${PORT:-8000} --api-key ${RADIANCE_API_KEY:?set RADIANCE_API_KEY in .env} + --host :: --port ${PORT:-8000} --api-key-env RADIANCE_API_KEY --tp 2 --max-num-seqs 16 --max-model-len 65536 --kv-cache-dtype fp8 --num-speculative-tokens auto --max-num-batched-tokens 8192 --busy-prefill-chunk 512 --prefill-interleave 1 --gpu-headroom-mib 160 diff --git a/deploy/compose/gemma4-31b-w4a8-df2b16-tp4.yaml b/deploy/compose/gemma4-31b-w4a8-df2b16-tp4.yaml index 6209516d..d9e1b7a0 100644 --- a/deploy/compose/gemma4-31b-w4a8-df2b16-tp4.yaml +++ b/deploy/compose/gemma4-31b-w4a8-df2b16-tp4.yaml @@ -31,7 +31,7 @@ services: container_name: radiance-gemma4-31b-w4a8-df2b16-tp4 command: > --model /models/gemma4-31b-dense-w4a8-df2b16-qkv.rad - --host :: --port ${PORT:-8000} --api-key ${RADIANCE_API_KEY:?set RADIANCE_API_KEY in .env} + --host :: --port ${PORT:-8000} --api-key-env RADIANCE_API_KEY --tp 4 --max-num-seqs 16 --max-model-len 65536 --kv-cache-dtype fp8 --num-speculative-tokens auto --max-num-batched-tokens 8192 --busy-prefill-chunk 512 --prefill-interleave 1 diff --git a/deploy/compose/gemma4-31b-w4a8.yaml b/deploy/compose/gemma4-31b-w4a8.yaml index 3b1d810e..56aaf396 100644 --- a/deploy/compose/gemma4-31b-w4a8.yaml +++ b/deploy/compose/gemma4-31b-w4a8.yaml @@ -11,6 +11,6 @@ services: container_name: radiance-gemma4-31b-w4a8 command: > --model /models/gemma4-31b-w4a8.rad - --host :: --port ${PORT:-8000} --api-key ${RADIANCE_API_KEY:?set RADIANCE_API_KEY in .env} + --host :: --port ${PORT:-8000} --api-key-env RADIANCE_API_KEY --tp 2 --max-num-seqs 8 --max-model-len 65536 --kv-cache-dtype fp8 --num-speculative-tokens 3 --max-num-batched-tokens 2048 --temp 1.0 --top-p 0.95 --top-k 64 diff --git a/deploy/compose/glm53-flash.yaml b/deploy/compose/glm53-flash.yaml index 67210b82..bb6cc2c6 100644 --- a/deploy/compose/glm53-flash.yaml +++ b/deploy/compose/glm53-flash.yaml @@ -14,7 +14,7 @@ services: container_name: radiance-glm53-flash command: > --model /models/glm53-flash-mxfp4.rad - --host :: --port ${PORT:-8000} --api-key ${RADIANCE_API_KEY:?set RADIANCE_API_KEY in .env} + --host :: --port ${PORT:-8000} --api-key-env RADIANCE_API_KEY --tp 8 --placement all_vram --gpu-headroom-mib 1024 --embedding-placement vram --max-num-seqs 8 --max-model-len 32768 --max-num-batched-tokens 4096 --prefill-span 4 diff --git a/deploy/compose/krea-2-raw.yaml b/deploy/compose/krea-2-raw.yaml index 527cadf6..4efdb260 100644 --- a/deploy/compose/krea-2-raw.yaml +++ b/deploy/compose/krea-2-raw.yaml @@ -13,5 +13,5 @@ services: ROCR_VISIBLE_DEVICES: "${RADIANCE_GPU:-0}" command: > --model /models/krea-2-raw-fp8.rad - --host :: --port ${PORT:-8000} --api-key ${RADIANCE_API_KEY:?set RADIANCE_API_KEY in .env} + --host :: --port ${PORT:-8000} --api-key-env RADIANCE_API_KEY --tp 1 diff --git a/deploy/compose/krea-2-turbo.yaml b/deploy/compose/krea-2-turbo.yaml index c15e9223..d66e5007 100644 --- a/deploy/compose/krea-2-turbo.yaml +++ b/deploy/compose/krea-2-turbo.yaml @@ -13,5 +13,5 @@ services: ROCR_VISIBLE_DEVICES: "${RADIANCE_GPU:-0}" command: > --model /models/krea-2-turbo-fp8.rad - --host :: --port ${PORT:-8000} --api-key ${RADIANCE_API_KEY:?set RADIANCE_API_KEY in .env} + --host :: --port ${PORT:-8000} --api-key-env RADIANCE_API_KEY --tp 1 diff --git a/deploy/compose/ltx-2.5.yaml b/deploy/compose/ltx-2.5.yaml index 287f1dd3..a30b9ed7 100644 --- a/deploy/compose/ltx-2.5.yaml +++ b/deploy/compose/ltx-2.5.yaml @@ -15,5 +15,5 @@ services: ROCR_VISIBLE_DEVICES: "${RADIANCE_GPU:-0}" command: > --model /models/ltx-2.5-distilled-fp8.rad - --host :: --port ${PORT:-8000} --api-key ${RADIANCE_API_KEY:?set RADIANCE_API_KEY in .env} + --host :: --port ${PORT:-8000} --api-key-env RADIANCE_API_KEY --tp 1 --vision-tower-placement ram diff --git a/deploy/compose/minicpm5-2b-bf16.yaml b/deploy/compose/minicpm5-2b-bf16.yaml index d29d3a19..087211f0 100644 --- a/deploy/compose/minicpm5-2b-bf16.yaml +++ b/deploy/compose/minicpm5-2b-bf16.yaml @@ -7,6 +7,6 @@ services: container_name: radiance-minicpm5-2b-bf16 command: > --model /models/minicpm5-2b-bf16.rad - --host :: --port ${PORT:-8000} --api-key ${RADIANCE_API_KEY:?set RADIANCE_API_KEY in .env} + --host :: --port ${PORT:-8000} --api-key-env RADIANCE_API_KEY --tp 2 --max-num-seqs 32 --max-model-len 131072 --kv-cache-dtype fp8 --gpu-headroom-mib 160 --max-num-batched-tokens 512 diff --git a/deploy/compose/minicpm5-2b.yaml b/deploy/compose/minicpm5-2b.yaml index fc3d26c8..3b5b0151 100644 --- a/deploy/compose/minicpm5-2b.yaml +++ b/deploy/compose/minicpm5-2b.yaml @@ -7,6 +7,6 @@ services: container_name: radiance-minicpm5-2b command: > --model /models/minicpm5-2b-fp8.rad - --host :: --port ${PORT:-8000} --api-key ${RADIANCE_API_KEY:?set RADIANCE_API_KEY in .env} + --host :: --port ${PORT:-8000} --api-key-env RADIANCE_API_KEY --tp 2 --max-num-seqs 32 --max-model-len 131072 --kv-cache-dtype fp8 --gpu-headroom-mib 160 --max-num-batched-tokens 512 diff --git a/deploy/compose/minimax-h3.yaml b/deploy/compose/minimax-h3.yaml index 548a7e71..a4f65745 100644 --- a/deploy/compose/minimax-h3.yaml +++ b/deploy/compose/minimax-h3.yaml @@ -13,5 +13,5 @@ services: container_name: radiance-minimax-h3 command: > --model /models/minimax-h3-fp8.rad - --host :: --port ${PORT:-8000} --api-key ${RADIANCE_API_KEY:?set RADIANCE_API_KEY in .env} + --host :: --port ${PORT:-8000} --api-key-env RADIANCE_API_KEY --tp 2 --vision-tower-placement ram diff --git a/deploy/compose/minimax-music3.yaml b/deploy/compose/minimax-music3.yaml index acfdc678..22c47a9f 100644 --- a/deploy/compose/minimax-music3.yaml +++ b/deploy/compose/minimax-music3.yaml @@ -8,5 +8,5 @@ services: container_name: radiance-minimax-music3 command: > --model /models/minimax-music3-bf16.rad - --host :: --port ${PORT:-8000} --api-key ${RADIANCE_API_KEY:?set RADIANCE_API_KEY in .env} + --host :: --port ${PORT:-8000} --api-key-env RADIANCE_API_KEY --tp 2 diff --git a/deploy/compose/nemotron-3.5-bolt-e4b-a4-tp1.yaml b/deploy/compose/nemotron-3.5-bolt-e4b-a4-tp1.yaml index b117476e..3f24899c 100644 --- a/deploy/compose/nemotron-3.5-bolt-e4b-a4-tp1.yaml +++ b/deploy/compose/nemotron-3.5-bolt-e4b-a4-tp1.yaml @@ -7,7 +7,7 @@ services: container_name: radiance-nemotron-3.5-bolt-e4b-a4-tp1 command: > --model /models/nemotron-3.5-bolt-e4b-a4.rad - --host :: --port ${PORT:-8000} --api-key ${RADIANCE_API_KEY:?set RADIANCE_API_KEY in .env} + --host :: --port ${PORT:-8000} --api-key-env RADIANCE_API_KEY --tp 1 --max-num-seqs 8 --max-model-len 65536 --kv-cache-dtype bf16 --num-speculative-tokens 7 --mm-max-patches 2520 --vision-tower-placement ram --temp 1.0 --top-p 0.95 --top-k 64 --chat-template-kwargs '{"enable_thinking":false}' diff --git a/deploy/compose/nemotron-3.5-bolt-e4b-a4.yaml b/deploy/compose/nemotron-3.5-bolt-e4b-a4.yaml index 2bfa2cf7..311a011c 100644 --- a/deploy/compose/nemotron-3.5-bolt-e4b-a4.yaml +++ b/deploy/compose/nemotron-3.5-bolt-e4b-a4.yaml @@ -11,7 +11,7 @@ services: container_name: radiance-nemotron-3.5-bolt-e4b-a4 command: > --model /models/nemotron-3.5-bolt-e4b-a4.rad - --host :: --port ${PORT:-8000} --api-key ${RADIANCE_API_KEY:?set RADIANCE_API_KEY in .env} + --host :: --port ${PORT:-8000} --api-key-env RADIANCE_API_KEY --tp 2 --max-num-seqs 8 --max-model-len 65536 --kv-cache-dtype bf16 --num-speculative-tokens 7 --mm-max-patches 2520 --vision-tower-placement ram --temp 1.0 --top-p 0.95 --top-k 64 --chat-template-kwargs '{"enable_thinking":false}' diff --git a/deploy/compose/nemotron-3.5-bolt-e4b-bf16-tp1.yaml b/deploy/compose/nemotron-3.5-bolt-e4b-bf16-tp1.yaml index 26093631..4bfb3df4 100644 --- a/deploy/compose/nemotron-3.5-bolt-e4b-bf16-tp1.yaml +++ b/deploy/compose/nemotron-3.5-bolt-e4b-bf16-tp1.yaml @@ -7,7 +7,7 @@ services: container_name: radiance-nemotron-3.5-bolt-e4b-bf16-tp1 command: > --model /models/nemotron-3.5-bolt-e4b-bf16.rad - --host :: --port ${PORT:-8000} --api-key ${RADIANCE_API_KEY:?set RADIANCE_API_KEY in .env} + --host :: --port ${PORT:-8000} --api-key-env RADIANCE_API_KEY --tp 1 --max-num-seqs 8 --max-model-len 65536 --kv-cache-dtype bf16 --num-speculative-tokens 7 --mm-max-patches 2520 --vision-tower-placement ram --temp 1.0 --top-p 0.95 --top-k 64 --chat-template-kwargs '{"enable_thinking":false}' diff --git a/deploy/compose/nemotron-3.5-bolt-e4b-bf16.yaml b/deploy/compose/nemotron-3.5-bolt-e4b-bf16.yaml index 3e5a0ff3..c4658013 100644 --- a/deploy/compose/nemotron-3.5-bolt-e4b-bf16.yaml +++ b/deploy/compose/nemotron-3.5-bolt-e4b-bf16.yaml @@ -10,7 +10,7 @@ services: container_name: radiance-nemotron-3.5-bolt-e4b-bf16 command: > --model /models/nemotron-3.5-bolt-e4b-bf16.rad - --host :: --port ${PORT:-8000} --api-key ${RADIANCE_API_KEY:?set RADIANCE_API_KEY in .env} + --host :: --port ${PORT:-8000} --api-key-env RADIANCE_API_KEY --tp 2 --max-num-seqs 8 --max-model-len 65536 --kv-cache-dtype bf16 --num-speculative-tokens 7 --mm-max-patches 2520 --vision-tower-placement ram --temp 1.0 --top-p 0.95 --top-k 64 --chat-template-kwargs '{"enable_thinking":false}' diff --git a/deploy/compose/nemotron-3.5-bolt-e4b-i8g-tp1.yaml b/deploy/compose/nemotron-3.5-bolt-e4b-i8g-tp1.yaml index b6a1748e..a39bbd1f 100644 --- a/deploy/compose/nemotron-3.5-bolt-e4b-i8g-tp1.yaml +++ b/deploy/compose/nemotron-3.5-bolt-e4b-i8g-tp1.yaml @@ -7,7 +7,7 @@ services: container_name: radiance-nemotron-3.5-bolt-e4b-i8g-tp1 command: > --model /models/nemotron-3.5-bolt-e4b-i8g.rad - --host :: --port ${PORT:-8000} --api-key ${RADIANCE_API_KEY:?set RADIANCE_API_KEY in .env} + --host :: --port ${PORT:-8000} --api-key-env RADIANCE_API_KEY --tp 1 --max-num-seqs 8 --max-model-len 65536 --kv-cache-dtype bf16 --num-speculative-tokens 7 --mm-max-patches 2520 --vision-tower-placement ram --temp 1.0 --top-p 0.95 --top-k 64 --chat-template-kwargs '{"enable_thinking":false}' diff --git a/deploy/compose/nemotron-3.5-bolt-e4b-i8g.yaml b/deploy/compose/nemotron-3.5-bolt-e4b-i8g.yaml index 68329eb2..0e7d8641 100644 --- a/deploy/compose/nemotron-3.5-bolt-e4b-i8g.yaml +++ b/deploy/compose/nemotron-3.5-bolt-e4b-i8g.yaml @@ -10,7 +10,7 @@ services: container_name: radiance-nemotron-3.5-bolt-e4b-i8g command: > --model /models/nemotron-3.5-bolt-e4b-i8g.rad - --host :: --port ${PORT:-8000} --api-key ${RADIANCE_API_KEY:?set RADIANCE_API_KEY in .env} + --host :: --port ${PORT:-8000} --api-key-env RADIANCE_API_KEY --tp 2 --max-num-seqs 8 --max-model-len 65536 --kv-cache-dtype bf16 --num-speculative-tokens 7 --mm-max-patches 2520 --vision-tower-placement ram --temp 1.0 --top-p 0.95 --top-k 64 --chat-template-kwargs '{"enable_thinking":false}' diff --git a/deploy/compose/ornith-1.5-122b-df2.yaml b/deploy/compose/ornith-1.5-122b-df2.yaml index dfae8855..80322912 100644 --- a/deploy/compose/ornith-1.5-122b-df2.yaml +++ b/deploy/compose/ornith-1.5-122b-df2.yaml @@ -11,7 +11,7 @@ services: container_name: radiance-ornith-1.5-122b-df2 command: > --model /models/ornith-1.5-122b-fp8-dflash2.rad - --host :: --port ${PORT:-8000} --api-key ${RADIANCE_API_KEY:?set RADIANCE_API_KEY in .env} + --host :: --port ${PORT:-8000} --api-key-env RADIANCE_API_KEY --tp 4 --max-num-seqs 8 --max-model-len 262144 --kv-cache-dtype fp8 --placement expert_tiered --host-pool-mib 3072 --vision-tower-placement ram --max-num-batched-tokens 2048 diff --git a/deploy/compose/ornith-1.5-122b-w4a8-df2.yaml b/deploy/compose/ornith-1.5-122b-w4a8-df2.yaml index 4f47d9d3..d841f505 100644 --- a/deploy/compose/ornith-1.5-122b-w4a8-df2.yaml +++ b/deploy/compose/ornith-1.5-122b-w4a8-df2.yaml @@ -10,7 +10,7 @@ services: container_name: radiance-ornith-1.5-122b-w4a8-df2 command: > --model /models/ornith-1.5-122b-w4a8-dflash2.rad - --host :: --port ${PORT:-8000} --api-key ${RADIANCE_API_KEY:?set RADIANCE_API_KEY in .env} + --host :: --port ${PORT:-8000} --api-key-env RADIANCE_API_KEY --tp 4 --max-num-seqs 8 --max-model-len 262144 --kv-cache-dtype fp8 --max-num-batched-tokens 2048 --temp 1.0 --top-p 0.95 --top-k 20 --presence-penalty 1.5 diff --git a/deploy/compose/ornith-1.5-122b-w4a8.yaml b/deploy/compose/ornith-1.5-122b-w4a8.yaml index 8bfcfa8a..68ea31a9 100644 --- a/deploy/compose/ornith-1.5-122b-w4a8.yaml +++ b/deploy/compose/ornith-1.5-122b-w4a8.yaml @@ -9,7 +9,7 @@ services: container_name: radiance-ornith-1.5-122b-w4a8 command: > --model /models/ornith-1.5-122b-w4a8.rad - --host :: --port ${PORT:-8000} --api-key ${RADIANCE_API_KEY:?set RADIANCE_API_KEY in .env} + --host :: --port ${PORT:-8000} --api-key-env RADIANCE_API_KEY --tp 4 --max-num-seqs 8 --max-model-len 262144 --kv-cache-dtype fp8 --num-speculative-tokens 3 --max-num-batched-tokens 2048 --temp 1.0 --top-p 0.95 --top-k 20 --presence-penalty 1.5 diff --git a/deploy/compose/ornith-1.5-122b.yaml b/deploy/compose/ornith-1.5-122b.yaml index 75c1ce3e..2a58ec1a 100644 --- a/deploy/compose/ornith-1.5-122b.yaml +++ b/deploy/compose/ornith-1.5-122b.yaml @@ -11,7 +11,7 @@ services: container_name: radiance-ornith-1.5-122b command: > --model /models/ornith-1.5-122b-fp8.rad - --host :: --port ${PORT:-8000} --api-key ${RADIANCE_API_KEY:?set RADIANCE_API_KEY in .env} + --host :: --port ${PORT:-8000} --api-key-env RADIANCE_API_KEY --tp 4 --max-num-seqs 8 --max-model-len 262144 --kv-cache-dtype fp8 --placement expert_tiered --host-pool-mib 3072 --vision-tower-placement ram --num-speculative-tokens 3 --max-num-batched-tokens 2048 diff --git a/deploy/compose/ornith-1.5-35b-a3b-w4a8-tp1.yaml b/deploy/compose/ornith-1.5-35b-a3b-w4a8-tp1.yaml index 1578ae0b..983c6470 100644 --- a/deploy/compose/ornith-1.5-35b-a3b-w4a8-tp1.yaml +++ b/deploy/compose/ornith-1.5-35b-a3b-w4a8-tp1.yaml @@ -7,7 +7,7 @@ services: container_name: radiance-ornith-1.5-35b-a3b-w4a8-tp1 command: > --model /models/ornith-1.5-35b-a3b-w4a8.rad - --host :: --port ${PORT:-8000} --api-key ${RADIANCE_API_KEY:?set RADIANCE_API_KEY in .env} + --host :: --port ${PORT:-8000} --api-key-env RADIANCE_API_KEY --tp 1 --max-num-seqs 8 --max-model-len 262144 --kv-cache-dtype fp8 --num-speculative-tokens 3 --max-num-batched-tokens 2048 --temp 1.0 --top-p 0.95 --top-k 20 --presence-penalty 1.5 diff --git a/deploy/compose/ornith-1.5-35b-a3b-w4a8.yaml b/deploy/compose/ornith-1.5-35b-a3b-w4a8.yaml index 54d19373..412b0dbe 100644 --- a/deploy/compose/ornith-1.5-35b-a3b-w4a8.yaml +++ b/deploy/compose/ornith-1.5-35b-a3b-w4a8.yaml @@ -8,7 +8,7 @@ services: container_name: radiance-ornith-1.5-35b-a3b-w4a8 command: > --model /models/ornith-1.5-35b-a3b-w4a8.rad - --host :: --port ${PORT:-8000} --api-key ${RADIANCE_API_KEY:?set RADIANCE_API_KEY in .env} + --host :: --port ${PORT:-8000} --api-key-env RADIANCE_API_KEY --tp 2 --max-num-seqs 8 --max-model-len 262144 --kv-cache-dtype fp8 --num-speculative-tokens 3 --max-num-batched-tokens 2048 --temp 1.0 --top-p 0.95 --top-k 20 --presence-penalty 1.5 diff --git a/deploy/compose/ornith-1.5-35b-a3b.yaml b/deploy/compose/ornith-1.5-35b-a3b.yaml index 7b5b6bb4..9687c7c0 100644 --- a/deploy/compose/ornith-1.5-35b-a3b.yaml +++ b/deploy/compose/ornith-1.5-35b-a3b.yaml @@ -8,7 +8,7 @@ services: container_name: radiance-ornith-1.5-35b-a3b command: > --model /models/ornith-1.5-35b-a3b-fp8.rad - --host :: --port ${PORT:-8000} --api-key ${RADIANCE_API_KEY:?set RADIANCE_API_KEY in .env} + --host :: --port ${PORT:-8000} --api-key-env RADIANCE_API_KEY --tp 2 --max-num-seqs 8 --max-model-len 262144 --kv-cache-dtype fp8 --num-speculative-tokens 3 --max-num-batched-tokens 2048 --temp 1.0 --top-p 0.95 --top-k 20 --presence-penalty 1.5 diff --git a/deploy/compose/qwen-image-2.1-turbo.yaml b/deploy/compose/qwen-image-2.1-turbo.yaml index 0df9ae68..b74eafa1 100644 --- a/deploy/compose/qwen-image-2.1-turbo.yaml +++ b/deploy/compose/qwen-image-2.1-turbo.yaml @@ -12,5 +12,5 @@ services: container_name: radiance-qwen-image-turbo command: > --model /models/qwen-image-2.1-turbo-fp8.rad - --host :: --port ${PORT:-8000} --api-key ${RADIANCE_API_KEY:?set RADIANCE_API_KEY in .env} + --host :: --port ${PORT:-8000} --api-key-env RADIANCE_API_KEY --tp 2 --tp-wire wht6 diff --git a/deploy/compose/qwen-image-2.1.yaml b/deploy/compose/qwen-image-2.1.yaml index 3febe137..1017a3e0 100644 --- a/deploy/compose/qwen-image-2.1.yaml +++ b/deploy/compose/qwen-image-2.1.yaml @@ -15,5 +15,5 @@ services: container_name: radiance-qwen-image command: > --model /models/qwen-image-2.1-fp8.rad - --host :: --port ${PORT:-8000} --api-key ${RADIANCE_API_KEY:?set RADIANCE_API_KEY in .env} + --host :: --port ${PORT:-8000} --api-key-env RADIANCE_API_KEY --tp 2 --tp-wire wht6 diff --git a/deploy/compose/qwen3-asr-1.7b.yaml b/deploy/compose/qwen3-asr-1.7b.yaml index 927f4877..8d7d8c47 100644 --- a/deploy/compose/qwen3-asr-1.7b.yaml +++ b/deploy/compose/qwen3-asr-1.7b.yaml @@ -11,5 +11,5 @@ services: ROCR_VISIBLE_DEVICES: "${RADIANCE_GPU:-0}" command: > --model /models/Qwen3-ASR-1.7B-hf - --host :: --port ${PORT:-8000} --api-key ${RADIANCE_API_KEY:?set RADIANCE_API_KEY in .env} + --host :: --port ${PORT:-8000} --api-key-env RADIANCE_API_KEY --tp 1 --max-num-seqs 16 diff --git a/deploy/compose/qwen3.6-35b-a3b.yaml b/deploy/compose/qwen3.6-35b-a3b.yaml index 74c37da1..765ea936 100644 --- a/deploy/compose/qwen3.6-35b-a3b.yaml +++ b/deploy/compose/qwen3.6-35b-a3b.yaml @@ -6,5 +6,5 @@ services: container_name: radiance-qwen3.6-35b-a3b command: > --model /models/qwen3.6-35b-a3b-fp8.rad - --host :: --port ${PORT:-8000} --api-key ${RADIANCE_API_KEY:?set RADIANCE_API_KEY in .env} + --host :: --port ${PORT:-8000} --api-key-env RADIANCE_API_KEY --tp 2 --max-num-seqs 32 --max-model-len 200000 --kv-cache-dtype fp8 diff --git a/deploy/compose/qwen3.8-27b-bf16.yaml b/deploy/compose/qwen3.8-27b-bf16.yaml index 03a42ac6..bde19f3a 100644 --- a/deploy/compose/qwen3.8-27b-bf16.yaml +++ b/deploy/compose/qwen3.8-27b-bf16.yaml @@ -6,5 +6,5 @@ services: container_name: radiance-qwen3.8-27b-bf16 command: > --model /models/qwen3.8-27b-bf16.rad - --host :: --port ${PORT:-8000} --api-key ${RADIANCE_API_KEY:?set RADIANCE_API_KEY in .env} + --host :: --port ${PORT:-8000} --api-key-env RADIANCE_API_KEY --tp 2 --max-num-seqs 8 --max-model-len 200000 --kv-cache-dtype fp8 diff --git a/deploy/compose/qwen3.8-27b-fp8.yaml b/deploy/compose/qwen3.8-27b-fp8.yaml index 7fff4e97..b575c328 100644 --- a/deploy/compose/qwen3.8-27b-fp8.yaml +++ b/deploy/compose/qwen3.8-27b-fp8.yaml @@ -7,5 +7,5 @@ services: container_name: radiance-qwen3.8-27b-fp8 command: > --model /models/qwen3.8-27b-fp8.rad - --host :: --port ${PORT:-8000} --api-key ${RADIANCE_API_KEY:?set RADIANCE_API_KEY in .env} + --host :: --port ${PORT:-8000} --api-key-env RADIANCE_API_KEY --tp 2 --max-num-seqs 32 --max-model-len 200000 --kv-cache-dtype fp8 diff --git a/deploy/compose/qwen3.8-27b-mxfp4.yaml b/deploy/compose/qwen3.8-27b-mxfp4.yaml index 22e689c3..3c16c463 100644 --- a/deploy/compose/qwen3.8-27b-mxfp4.yaml +++ b/deploy/compose/qwen3.8-27b-mxfp4.yaml @@ -8,5 +8,5 @@ services: container_name: radiance-qwen3.8-27b-mxfp4 command: > --model /models/qwen3.8-27b-mxfp4.rad - --host :: --port ${PORT:-8000} --api-key ${RADIANCE_API_KEY:?set RADIANCE_API_KEY in .env} + --host :: --port ${PORT:-8000} --api-key-env RADIANCE_API_KEY --tp 2 --max-num-seqs 32 --max-model-len 200000 --kv-cache-dtype fp8 diff --git a/deploy/compose/qwen3.8-27b-paro.yaml b/deploy/compose/qwen3.8-27b-paro.yaml index ccc0f2c7..3e3bc9f4 100644 --- a/deploy/compose/qwen3.8-27b-paro.yaml +++ b/deploy/compose/qwen3.8-27b-paro.yaml @@ -8,6 +8,6 @@ services: container_name: radiance-qwen3.8-27b-paro command: > --model /models/qwen3.8-27b-paro-int4.rad - --host :: --port ${PORT:-8000} --api-key ${RADIANCE_API_KEY:?set RADIANCE_API_KEY in .env} + --host :: --port ${PORT:-8000} --api-key-env RADIANCE_API_KEY --tp 1 --max-num-seqs 8 --max-model-len 200000 --kv-cache-dtype fp8 --max-num-batched-tokens 2048 --embedding-placement ram --host-pool-mib 3072 diff --git a/deploy/compose/sage-a1.5-df2.yaml b/deploy/compose/sage-a1.5-df2.yaml index 2fae0b59..65b1abb3 100644 --- a/deploy/compose/sage-a1.5-df2.yaml +++ b/deploy/compose/sage-a1.5-df2.yaml @@ -12,7 +12,7 @@ services: container_name: radiance-sage-a1.5-df2 command: > --model /models/sage-a1.5-fp8-df2.rad - --host :: --port ${PORT:-8000} --api-key ${RADIANCE_API_KEY:?set RADIANCE_API_KEY in .env} + --host :: --port ${PORT:-8000} --api-key-env RADIANCE_API_KEY --tp 2 --max-num-seqs 4 --max-model-len 32768 --kv-cache-dtype fp8 --num-speculative-tokens auto --max-num-batched-tokens 2048 --temp 1.0 --top-p 0.95 --top-k 20 --presence-penalty 1.5 diff --git a/deploy/compose/sage-a1.5-mxfp4-df2.yaml b/deploy/compose/sage-a1.5-mxfp4-df2.yaml index db62a6d8..aeefacb2 100644 --- a/deploy/compose/sage-a1.5-mxfp4-df2.yaml +++ b/deploy/compose/sage-a1.5-mxfp4-df2.yaml @@ -14,7 +14,7 @@ services: container_name: radiance-sage-a1.5-mxfp4-df2 command: > --model /models/sage-a1.5-mxfp4-df2.rad - --host :: --port ${PORT:-8000} --api-key ${RADIANCE_API_KEY:?set RADIANCE_API_KEY in .env} + --host :: --port ${PORT:-8000} --api-key-env RADIANCE_API_KEY --tp 2 --max-num-seqs 10 --max-model-len 262144 --kv-cache-dtype fp8 --gpu-headroom-mib 96 --num-speculative-tokens auto --max-num-batched-tokens 2048 diff --git a/deploy/compose/sage-a1.5-tp1.yaml b/deploy/compose/sage-a1.5-tp1.yaml index e54650bb..c4622876 100644 --- a/deploy/compose/sage-a1.5-tp1.yaml +++ b/deploy/compose/sage-a1.5-tp1.yaml @@ -13,7 +13,7 @@ services: container_name: radiance-sage-a1.5-tp1 command: > --model /models/sage-a1.5-fp8.rad - --host :: --port ${PORT:-8000} --api-key ${RADIANCE_API_KEY:?set RADIANCE_API_KEY in .env} + --host :: --port ${PORT:-8000} --api-key-env RADIANCE_API_KEY --tp 1 --max-num-seqs 1 --max-model-len 262144 --kv-cache-dtype fp8 --num-speculative-tokens 3 --max-num-batched-tokens 2048 --placement expert_tiered --host-pool-mib 8192 diff --git a/deploy/compose/sage-a1.5.yaml b/deploy/compose/sage-a1.5.yaml index 80babc0f..25cd11d1 100644 --- a/deploy/compose/sage-a1.5.yaml +++ b/deploy/compose/sage-a1.5.yaml @@ -15,7 +15,7 @@ services: container_name: radiance-sage-a1.5 command: > --model /models/sage-a1.5-fp8.rad - --host :: --port ${PORT:-8000} --api-key ${RADIANCE_API_KEY:?set RADIANCE_API_KEY in .env} + --host :: --port ${PORT:-8000} --api-key-env RADIANCE_API_KEY --tp 2 --max-num-seqs 4 --max-model-len 32768 --kv-cache-dtype fp8 --num-speculative-tokens 3 --max-num-batched-tokens 2048 --temp 1.0 --top-p 0.95 --top-k 20 --presence-penalty 1.5 diff --git a/deploy/compose/sdxl.yaml b/deploy/compose/sdxl.yaml index a7bf5d82..1d4f5427 100644 --- a/deploy/compose/sdxl.yaml +++ b/deploy/compose/sdxl.yaml @@ -11,5 +11,5 @@ services: ROCR_VISIBLE_DEVICES: "${RADIANCE_GPU:-0}" command: > --model /models/illustrious-xl-v2.0-bf16.rad - --host :: --port ${PORT:-8000} --api-key ${RADIANCE_API_KEY:?set RADIANCE_API_KEY in .env} + --host :: --port ${PORT:-8000} --api-key-env RADIANCE_API_KEY --tp 1 diff --git a/deploy/compose/seccomp-radiance.json b/deploy/compose/seccomp-radiance.json new file mode 100644 index 00000000..9539a1b4 --- /dev/null +++ b/deploy/compose/seccomp-radiance.json @@ -0,0 +1,1238 @@ +{ + "comment": "radiance profile: Docker's default seccomp profile (moby/profiles default.json, October 2026) plus io_uring_setup/io_uring_enter/io_uring_register for the n-gram table's reads from the model file, and the NUMA binding calls (mbind, set_mempolicy, get_mempolicy) the ROCm runtime makes for host memory. Nothing else is widened; see the comment in common.yaml for how to adopt it.", + "defaultAction": "SCMP_ACT_ERRNO", + "defaultErrnoRet": 1, + "archMap": [ + { + "architecture": "SCMP_ARCH_X86_64", + "subArchitectures": [ + "SCMP_ARCH_X86", + "SCMP_ARCH_X32" + ] + }, + { + "architecture": "SCMP_ARCH_AARCH64", + "subArchitectures": [ + "SCMP_ARCH_ARM" + ] + }, + { + "architecture": "SCMP_ARCH_MIPS64", + "subArchitectures": [ + "SCMP_ARCH_MIPS", + "SCMP_ARCH_MIPS64N32" + ] + }, + { + "architecture": "SCMP_ARCH_MIPS64N32", + "subArchitectures": [ + "SCMP_ARCH_MIPS", + "SCMP_ARCH_MIPS64" + ] + }, + { + "architecture": "SCMP_ARCH_MIPSEL64", + "subArchitectures": [ + "SCMP_ARCH_MIPSEL", + "SCMP_ARCH_MIPSEL64N32" + ] + }, + { + "architecture": "SCMP_ARCH_MIPSEL64N32", + "subArchitectures": [ + "SCMP_ARCH_MIPSEL", + "SCMP_ARCH_MIPSEL64" + ] + }, + { + "architecture": "SCMP_ARCH_S390X", + "subArchitectures": [ + "SCMP_ARCH_S390" + ] + }, + { + "architecture": "SCMP_ARCH_RISCV64", + "subArchitectures": null + }, + { + "architecture": "SCMP_ARCH_LOONGARCH64", + "subArchitectures": null + } + ], + "syscalls": [ + { + "names": [ + "accept", + "accept4", + "access", + "adjtimex", + "alarm", + "bind", + "brk", + "cachestat", + "capget", + "capset", + "chdir", + "chmod", + "chown", + "chown32", + "clock_adjtime", + "clock_adjtime64", + "clock_getres", + "clock_getres_time64", + "clock_gettime", + "clock_gettime64", + "clock_nanosleep", + "clock_nanosleep_time64", + "close", + "close_range", + "connect", + "copy_file_range", + "creat", + "dup", + "dup2", + "dup3", + "epoll_create", + "epoll_create1", + "epoll_ctl", + "epoll_ctl_old", + "epoll_pwait", + "epoll_pwait2", + "epoll_wait", + "epoll_wait_old", + "eventfd", + "eventfd2", + "execve", + "execveat", + "exit", + "exit_group", + "faccessat", + "faccessat2", + "fadvise64", + "fadvise64_64", + "fallocate", + "fanotify_mark", + "fchdir", + "fchmod", + "fchmodat", + "fchmodat2", + "fchown", + "fchown32", + "fchownat", + "fcntl", + "fcntl64", + "fdatasync", + "fgetxattr", + "flistxattr", + "flock", + "fork", + "fremovexattr", + "fsetxattr", + "fstat", + "fstat64", + "fstatat64", + "fstatfs", + "fstatfs64", + "fsync", + "ftruncate", + "ftruncate64", + "futex", + "futex_requeue", + "futex_time64", + "futex_wait", + "futex_waitv", + "futex_wake", + "futimesat", + "getcpu", + "getcwd", + "getdents", + "getdents64", + "getegid", + "getegid32", + "geteuid", + "geteuid32", + "getgid", + "getgid32", + "getgroups", + "getgroups32", + "getitimer", + "getpeername", + "getpgid", + "getpgrp", + "getpid", + "getppid", + "getpriority", + "getrandom", + "getresgid", + "getresgid32", + "getresuid", + "getresuid32", + "getrlimit", + "get_robust_list", + "getrusage", + "getsid", + "getsockname", + "getsockopt", + "get_thread_area", + "gettid", + "gettimeofday", + "getuid", + "getuid32", + "getxattr", + "getxattrat", + "inotify_add_watch", + "inotify_init", + "inotify_init1", + "inotify_rm_watch", + "io_cancel", + "ioctl", + "io_destroy", + "io_getevents", + "io_pgetevents", + "io_pgetevents_time64", + "ioprio_get", + "ioprio_set", + "io_setup", + "io_submit", + "ipc", + "kill", + "landlock_add_rule", + "landlock_create_ruleset", + "landlock_restrict_self", + "lchown", + "lchown32", + "lgetxattr", + "link", + "linkat", + "listen", + "listmount", + "listxattr", + "listxattrat", + "llistxattr", + "_llseek", + "lremovexattr", + "lseek", + "lsetxattr", + "lstat", + "lstat64", + "madvise", + "map_shadow_stack", + "membarrier", + "memfd_create", + "memfd_secret", + "mincore", + "mkdir", + "mkdirat", + "mknod", + "mknodat", + "mlock", + "mlock2", + "mlockall", + "mmap", + "mmap2", + "mprotect", + "mq_getsetattr", + "mq_notify", + "mq_open", + "mq_timedreceive", + "mq_timedreceive_time64", + "mq_timedsend", + "mq_timedsend_time64", + "mq_unlink", + "mremap", + "mseal", + "msgctl", + "msgget", + "msgrcv", + "msgsnd", + "msync", + "munlock", + "munlockall", + "munmap", + "name_to_handle_at", + "nanosleep", + "newfstatat", + "_newselect", + "open", + "openat", + "openat2", + "pause", + "pidfd_open", + "pidfd_send_signal", + "pipe", + "pipe2", + "pkey_alloc", + "pkey_free", + "pkey_mprotect", + "poll", + "ppoll", + "ppoll_time64", + "prctl", + "pread64", + "preadv", + "preadv2", + "prlimit64", + "process_mrelease", + "pselect6", + "pselect6_time64", + "pwrite64", + "pwritev", + "pwritev2", + "read", + "readahead", + "readlink", + "readlinkat", + "readv", + "recv", + "recvfrom", + "recvmmsg", + "recvmmsg_time64", + "recvmsg", + "remap_file_pages", + "removexattr", + "removexattrat", + "rename", + "renameat", + "renameat2", + "restart_syscall", + "riscv_hwprobe", + "rmdir", + "rseq", + "rt_sigaction", + "rt_sigpending", + "rt_sigprocmask", + "rt_sigqueueinfo", + "rt_sigreturn", + "rt_sigsuspend", + "rt_sigtimedwait", + "rt_sigtimedwait_time64", + "rt_tgsigqueueinfo", + "sched_getaffinity", + "sched_getattr", + "sched_getparam", + "sched_get_priority_max", + "sched_get_priority_min", + "sched_getscheduler", + "sched_rr_get_interval", + "sched_rr_get_interval_time64", + "sched_setaffinity", + "sched_setattr", + "sched_setparam", + "sched_setscheduler", + "sched_yield", + "seccomp", + "select", + "semctl", + "semget", + "semop", + "semtimedop", + "semtimedop_time64", + "send", + "sendfile", + "sendfile64", + "sendmmsg", + "sendmsg", + "sendto", + "setfsgid", + "setfsgid32", + "setfsuid", + "setfsuid32", + "setgid", + "setgid32", + "setgroups", + "setgroups32", + "setitimer", + "setpgid", + "setpriority", + "setregid", + "setregid32", + "setresgid", + "setresgid32", + "setresuid", + "setresuid32", + "setreuid", + "setreuid32", + "setrlimit", + "set_robust_list", + "setsid", + "setsockopt", + "set_thread_area", + "set_tid_address", + "setuid", + "setuid32", + "setxattr", + "setxattrat", + "shmat", + "shmctl", + "shmdt", + "shmget", + "shutdown", + "sigaltstack", + "signalfd", + "signalfd4", + "sigprocmask", + "sigreturn", + "socketcall", + "socketpair", + "splice", + "stat", + "stat64", + "statfs", + "statfs64", + "statmount", + "statx", + "symlink", + "symlinkat", + "sync", + "sync_file_range", + "syncfs", + "sysinfo", + "tee", + "tgkill", + "time", + "timer_create", + "timer_delete", + "timer_getoverrun", + "timer_gettime", + "timer_gettime64", + "timer_settime", + "timer_settime64", + "timerfd_create", + "timerfd_gettime", + "timerfd_gettime64", + "timerfd_settime", + "timerfd_settime64", + "times", + "tkill", + "truncate", + "truncate64", + "ugetrlimit", + "umask", + "uname", + "unlink", + "unlinkat", + "uretprobe", + "utime", + "utimensat", + "utimensat_time64", + "utimes", + "vfork", + "vmsplice", + "wait4", + "waitid", + "waitpid", + "write", + "writev" + ], + "action": "SCMP_ACT_ALLOW" + }, + { + "names": [ + "process_vm_readv", + "process_vm_writev", + "ptrace" + ], + "action": "SCMP_ACT_ALLOW", + "includes": { + "minKernel": "4.8" + } + }, + { + "names": [ + "socket" + ], + "action": "SCMP_ACT_ALLOW", + "args": [ + { + "index": 0, + "value": 3, + "op": "SCMP_CMP_LT" + } + ] + }, + { + "names": [ + "socket" + ], + "action": "SCMP_ACT_ALLOW", + "args": [ + { + "index": 0, + "value": 7, + "op": "SCMP_CMP_EQ" + } + ] + }, + { + "names": [ + "socket" + ], + "action": "SCMP_ACT_ALLOW", + "args": [ + { + "index": 0, + "value": 8, + "op": "SCMP_CMP_EQ" + } + ] + }, + { + "names": [ + "socket" + ], + "action": "SCMP_ACT_ALLOW", + "args": [ + { + "index": 0, + "value": 9, + "op": "SCMP_CMP_EQ" + } + ] + }, + { + "names": [ + "socket" + ], + "action": "SCMP_ACT_ALLOW", + "args": [ + { + "index": 0, + "value": 10, + "op": "SCMP_CMP_EQ" + } + ] + }, + { + "names": [ + "socket" + ], + "action": "SCMP_ACT_ALLOW", + "args": [ + { + "index": 0, + "value": 13, + "op": "SCMP_CMP_EQ" + } + ] + }, + { + "names": [ + "socket" + ], + "action": "SCMP_ACT_ALLOW", + "args": [ + { + "index": 0, + "value": 14, + "op": "SCMP_CMP_EQ" + } + ] + }, + { + "names": [ + "socket" + ], + "action": "SCMP_ACT_ALLOW", + "args": [ + { + "index": 0, + "value": 15, + "op": "SCMP_CMP_EQ" + } + ] + }, + { + "names": [ + "socket" + ], + "action": "SCMP_ACT_ALLOW", + "args": [ + { + "index": 0, + "value": 16, + "op": "SCMP_CMP_EQ" + } + ] + }, + { + "names": [ + "socket" + ], + "action": "SCMP_ACT_ALLOW", + "args": [ + { + "index": 0, + "value": 17, + "op": "SCMP_CMP_EQ" + } + ] + }, + { + "names": [ + "socket" + ], + "action": "SCMP_ACT_ALLOW", + "args": [ + { + "index": 0, + "value": 18, + "op": "SCMP_CMP_EQ" + } + ] + }, + { + "names": [ + "socket" + ], + "action": "SCMP_ACT_ALLOW", + "args": [ + { + "index": 0, + "value": 21, + "op": "SCMP_CMP_EQ" + } + ] + }, + { + "names": [ + "socket" + ], + "action": "SCMP_ACT_ALLOW", + "args": [ + { + "index": 0, + "value": 22, + "op": "SCMP_CMP_EQ" + } + ] + }, + { + "names": [ + "socket" + ], + "action": "SCMP_ACT_ALLOW", + "args": [ + { + "index": 0, + "value": 24, + "op": "SCMP_CMP_EQ" + } + ] + }, + { + "names": [ + "socket" + ], + "action": "SCMP_ACT_ALLOW", + "args": [ + { + "index": 0, + "value": 26, + "op": "SCMP_CMP_EQ" + } + ] + }, + { + "names": [ + "socket" + ], + "action": "SCMP_ACT_ALLOW", + "args": [ + { + "index": 0, + "value": 27, + "op": "SCMP_CMP_EQ" + } + ] + }, + { + "names": [ + "socket" + ], + "action": "SCMP_ACT_ALLOW", + "args": [ + { + "index": 0, + "value": 28, + "op": "SCMP_CMP_EQ" + } + ] + }, + { + "names": [ + "socket" + ], + "action": "SCMP_ACT_ALLOW", + "args": [ + { + "index": 0, + "value": 29, + "op": "SCMP_CMP_EQ" + } + ] + }, + { + "names": [ + "socket" + ], + "action": "SCMP_ACT_ALLOW", + "args": [ + { + "index": 0, + "value": 30, + "op": "SCMP_CMP_EQ" + } + ] + }, + { + "names": [ + "socket" + ], + "action": "SCMP_ACT_ALLOW", + "args": [ + { + "index": 0, + "value": 31, + "op": "SCMP_CMP_EQ" + } + ] + }, + { + "names": [ + "socket" + ], + "action": "SCMP_ACT_ALLOW", + "args": [ + { + "index": 0, + "value": 32, + "op": "SCMP_CMP_EQ" + } + ] + }, + { + "names": [ + "socket" + ], + "action": "SCMP_ACT_ALLOW", + "args": [ + { + "index": 0, + "value": 33, + "op": "SCMP_CMP_EQ" + } + ] + }, + { + "names": [ + "socket" + ], + "action": "SCMP_ACT_ALLOW", + "args": [ + { + "index": 0, + "value": 35, + "op": "SCMP_CMP_EQ" + } + ] + }, + { + "names": [ + "socket" + ], + "action": "SCMP_ACT_ALLOW", + "args": [ + { + "index": 0, + "value": 36, + "op": "SCMP_CMP_EQ" + } + ] + }, + { + "names": [ + "socket" + ], + "action": "SCMP_ACT_ALLOW", + "args": [ + { + "index": 0, + "value": 39, + "op": "SCMP_CMP_EQ" + } + ] + }, + { + "names": [ + "socket" + ], + "action": "SCMP_ACT_ALLOW", + "args": [ + { + "index": 0, + "value": 41, + "op": "SCMP_CMP_EQ" + } + ] + }, + { + "names": [ + "socket" + ], + "action": "SCMP_ACT_ALLOW", + "args": [ + { + "index": 0, + "value": 42, + "op": "SCMP_CMP_EQ" + } + ] + }, + { + "names": [ + "socket" + ], + "action": "SCMP_ACT_ALLOW", + "args": [ + { + "index": 0, + "value": 43, + "op": "SCMP_CMP_EQ" + } + ] + }, + { + "names": [ + "socket" + ], + "action": "SCMP_ACT_ALLOW", + "args": [ + { + "index": 0, + "value": 44, + "op": "SCMP_CMP_EQ" + } + ] + }, + { + "names": [ + "socket" + ], + "action": "SCMP_ACT_ALLOW", + "args": [ + { + "index": 0, + "value": 45, + "op": "SCMP_CMP_EQ" + } + ] + }, + { + "names": [ + "personality" + ], + "action": "SCMP_ACT_ALLOW", + "args": [ + { + "index": 0, + "value": 0, + "op": "SCMP_CMP_EQ" + } + ] + }, + { + "names": [ + "personality" + ], + "action": "SCMP_ACT_ALLOW", + "args": [ + { + "index": 0, + "value": 8, + "op": "SCMP_CMP_EQ" + } + ] + }, + { + "names": [ + "personality" + ], + "action": "SCMP_ACT_ALLOW", + "args": [ + { + "index": 0, + "value": 131072, + "op": "SCMP_CMP_EQ" + } + ] + }, + { + "names": [ + "personality" + ], + "action": "SCMP_ACT_ALLOW", + "args": [ + { + "index": 0, + "value": 131080, + "op": "SCMP_CMP_EQ" + } + ] + }, + { + "names": [ + "personality" + ], + "action": "SCMP_ACT_ALLOW", + "args": [ + { + "index": 0, + "value": 4294967295, + "op": "SCMP_CMP_EQ" + } + ] + }, + { + "names": [ + "sync_file_range2", + "swapcontext" + ], + "action": "SCMP_ACT_ALLOW", + "includes": { + "arches": [ + "ppc64le" + ] + } + }, + { + "names": [ + "arm_fadvise64_64", + "arm_sync_file_range", + "sync_file_range2", + "breakpoint", + "cacheflush", + "set_tls" + ], + "action": "SCMP_ACT_ALLOW", + "includes": { + "arches": [ + "arm", + "arm64" + ] + } + }, + { + "names": [ + "arch_prctl" + ], + "action": "SCMP_ACT_ALLOW", + "includes": { + "arches": [ + "amd64", + "x32" + ] + } + }, + { + "names": [ + "modify_ldt" + ], + "action": "SCMP_ACT_ALLOW", + "includes": { + "arches": [ + "amd64", + "x32", + "x86" + ] + } + }, + { + "names": [ + "s390_pci_mmio_read", + "s390_pci_mmio_write", + "s390_runtime_instr" + ], + "action": "SCMP_ACT_ALLOW", + "includes": { + "arches": [ + "s390", + "s390x" + ] + } + }, + { + "names": [ + "riscv_flush_icache" + ], + "action": "SCMP_ACT_ALLOW", + "includes": { + "arches": [ + "riscv64" + ] + } + }, + { + "names": [ + "open_by_handle_at" + ], + "action": "SCMP_ACT_ALLOW", + "includes": { + "caps": [ + "CAP_DAC_READ_SEARCH" + ] + } + }, + { + "names": [ + "bpf", + "clone", + "clone3", + "fanotify_init", + "fsconfig", + "fsmount", + "fsopen", + "fspick", + "lookup_dcookie", + "lsm_get_self_attr", + "lsm_list_modules", + "lsm_set_self_attr", + "mount", + "mount_setattr", + "move_mount", + "open_tree", + "perf_event_open", + "quotactl", + "quotactl_fd", + "setdomainname", + "sethostname", + "setns", + "syslog", + "umount", + "umount2", + "unshare" + ], + "action": "SCMP_ACT_ALLOW", + "includes": { + "caps": [ + "CAP_SYS_ADMIN" + ] + } + }, + { + "names": [ + "clone" + ], + "action": "SCMP_ACT_ALLOW", + "args": [ + { + "index": 0, + "value": 2114060288, + "op": "SCMP_CMP_MASKED_EQ" + } + ], + "excludes": { + "caps": [ + "CAP_SYS_ADMIN" + ], + "arches": [ + "s390", + "s390x" + ] + } + }, + { + "names": [ + "clone" + ], + "action": "SCMP_ACT_ALLOW", + "args": [ + { + "index": 1, + "value": 2114060288, + "op": "SCMP_CMP_MASKED_EQ" + } + ], + "comment": "s390 parameter ordering for clone is different", + "includes": { + "arches": [ + "s390", + "s390x" + ] + }, + "excludes": { + "caps": [ + "CAP_SYS_ADMIN" + ] + } + }, + { + "names": [ + "clone3" + ], + "action": "SCMP_ACT_ERRNO", + "errnoRet": 38, + "excludes": { + "caps": [ + "CAP_SYS_ADMIN" + ] + } + }, + { + "names": [ + "reboot" + ], + "action": "SCMP_ACT_ALLOW", + "includes": { + "caps": [ + "CAP_SYS_BOOT" + ] + } + }, + { + "names": [ + "chroot" + ], + "action": "SCMP_ACT_ALLOW", + "includes": { + "caps": [ + "CAP_SYS_CHROOT" + ] + } + }, + { + "names": [ + "delete_module", + "init_module", + "finit_module" + ], + "action": "SCMP_ACT_ALLOW", + "includes": { + "caps": [ + "CAP_SYS_MODULE" + ] + } + }, + { + "names": [ + "acct" + ], + "action": "SCMP_ACT_ALLOW", + "includes": { + "caps": [ + "CAP_SYS_PACCT" + ] + } + }, + { + "names": [ + "kcmp", + "pidfd_getfd", + "process_madvise", + "process_vm_readv", + "process_vm_writev", + "ptrace" + ], + "action": "SCMP_ACT_ALLOW", + "includes": { + "caps": [ + "CAP_SYS_PTRACE" + ] + } + }, + { + "names": [ + "iopl", + "ioperm" + ], + "action": "SCMP_ACT_ALLOW", + "includes": { + "caps": [ + "CAP_SYS_RAWIO" + ] + } + }, + { + "names": [ + "settimeofday", + "stime", + "clock_settime", + "clock_settime64" + ], + "action": "SCMP_ACT_ALLOW", + "includes": { + "caps": [ + "CAP_SYS_TIME" + ] + } + }, + { + "names": [ + "vhangup" + ], + "action": "SCMP_ACT_ALLOW", + "includes": { + "caps": [ + "CAP_SYS_TTY_CONFIG" + ] + } + }, + { + "names": [ + "get_mempolicy", + "mbind", + "set_mempolicy", + "set_mempolicy_home_node" + ], + "action": "SCMP_ACT_ALLOW", + "includes": { + "caps": [ + "CAP_SYS_NICE" + ] + } + }, + { + "names": [ + "syslog" + ], + "action": "SCMP_ACT_ALLOW", + "includes": { + "caps": [ + "CAP_SYSLOG" + ] + } + }, + { + "names": [ + "bpf" + ], + "action": "SCMP_ACT_ALLOW", + "includes": { + "caps": [ + "CAP_BPF" + ] + } + }, + { + "names": [ + "perf_event_open" + ], + "action": "SCMP_ACT_ALLOW", + "includes": { + "caps": [ + "CAP_PERFMON" + ] + } + }, + { + "names": [ + "io_uring_setup", + "io_uring_enter", + "io_uring_register", + "mbind", + "set_mempolicy", + "get_mempolicy" + ], + "action": "SCMP_ACT_ALLOW" + } + ] +} diff --git a/deploy/compose/translategemma-27b.yaml b/deploy/compose/translategemma-27b.yaml index 261440b3..05c570d0 100644 --- a/deploy/compose/translategemma-27b.yaml +++ b/deploy/compose/translategemma-27b.yaml @@ -15,6 +15,6 @@ services: - ./gemma3.jinja:/templates/gemma3.jinja:ro command: > --model /models/translategemma-27b-mxfp4-gptq.rad - --host :: --port ${PORT:-8000} --api-key ${RADIANCE_API_KEY:?set RADIANCE_API_KEY in .env} + --host :: --port ${PORT:-8000} --api-key-env RADIANCE_API_KEY --tp 2 --max-num-seqs 8 --max-model-len 16384 --kv-cache-dtype fp8 --override-chat-template /templates/gemma3.jinja diff --git a/deploy/compose/unlimited-ocr-bf16.yaml b/deploy/compose/unlimited-ocr-bf16.yaml index 5396976a..a74197b9 100644 --- a/deploy/compose/unlimited-ocr-bf16.yaml +++ b/deploy/compose/unlimited-ocr-bf16.yaml @@ -19,7 +19,7 @@ services: ROCR_VISIBLE_DEVICES: "${RADIANCE_GPU:-0}" command: > --model /models/unlimited-ocr-bf16.rad - --host :: --port ${PORT:-8000} --api-key ${RADIANCE_API_KEY:?set RADIANCE_API_KEY in .env} + --host :: --port ${PORT:-8000} --api-key-env RADIANCE_API_KEY --tp 1 --max-num-seqs 8 --max-model-len 32768 --kv-cache-dtype fp8 --gpu-headroom-mib 96 --override-chat-template /chat-templates/unlimited-ocr-parser.jinja diff --git a/docs/GUIDE.md b/docs/GUIDE.md index af760829..7cc5ba1a 100644 --- a/docs/GUIDE.md +++ b/docs/GUIDE.md @@ -340,7 +340,13 @@ It needs only `curl` and `jq`. Re-running resumes: a file whose local size match short one is continued. When a repo carries `.safetensors`, other weight formats (`.bin`, ONNX, GGUF, ...) are not fetched. `HF_TOKEN` authenticates a gated or private repo; `HFGET_JOBS` sets concurrency (default 4). A complete fetch records each file's content key (its LFS sha256, or a small file's size) -in `.hfget-manifest`, so the next run also fetches a file that changed at the same size. The +in `.hfget-manifest`, so the next run also fetches a file that changed at the same size. An LFS +file's recorded key is verified, not just claimed: the download is hashed and compared against +the sha256 the listing names before the file is kept. A listing that names a file outside the +destination — an absolute path, a `..` segment — is refused whole rather than half-obeyed. +Fetch what you will serve from a revision you chose: without `--model-revision` a repo id tracks +the repo's `main` branch, so a restart can bring weights nobody reviewed; name a tag or a +commit sha. The free-space check counts only what is still to fetch. `--model` also takes a repo id: @@ -2029,6 +2035,7 @@ by 0.002-0.003 nats. |---|---| | `--model PATH` | required: the `.rad` container, a checkpoint served as it stands (§3.4), or a Hugging Face repo id fetched before startup (§3.1) | | `--download-dir DIR` | where a repo id is fetched to. Default `$XDG_CACHE_HOME/radiance/hf`, else `~/.cache/radiance/hf` | +| `--model-revision REV` | the hub revision a repo id is fetched at — a branch, tag, full commit sha or `refs/pr/N`. Default the repo's moving `main` branch; a deployment that must not restart onto weights nobody reviewed should name a tag or a sha (§3.1) | | `--control-vector off\|on\|disabled` | `disabled` (and no flag at all) loads nothing, declares no projection op and refuses a request that asks; `off` loads the vector found for this model and starts requests off; `on` starts them on. Refused at startup when the model's plugin does not apply control vectors or no compatible file is found (§4.10) | | `--radiance-home DIRS` | where `kernels/`, `architectures/` and `quantizers/` live; homes separated by `:` are searched in order, the first winning (§1.5) | | `--kernels LIST` | the kernel libraries to use, separated by `,` or `:`, first wins; a library not named is not loaded. Default: every library found | @@ -2121,6 +2128,7 @@ by 0.002-0.003 nats. | `--host ADDR` | 0.0.0.0 | listen address | | `--port N` | 8000 | listen port | | `--api-key KEY` | none | require `Authorization: Bearer KEY` or `X-Api-Key: KEY` on every request but `/health`, `/v1/health`, `/ping` and the dashboard page (§6.6); the key must be non-empty | +| `--api-key-env NAME` | — | read the API key from the environment variable `NAME` instead of the command line, where every process on the machine reads it in `ps`; an unset or empty `NAME` refuses startup like an empty `--api-key` | | `--allow-host NAME` | — | a `Host` name the keyless loopback-only routes accept besides the loopback names; repeatable (§6.6) | | `--served-model-name NAME` | container's name | the model id `/v1/models` lists, the metrics carry and a response names when its request named none. A request may name any model; the loaded one serves it | | `--mm-max-patches N` | auto | patches one vision-encoder pass carries, and so the largest image (a patch is 16x16 pixels, 14x14 on GLM-5.3). `auto` is 16384 when the container carries a vision tower; 0 serves text only and keeps the tower off the card. A pass is not one tower invocation: inside it the tower batches at most 8 tiles per weight read, and the pass size may reduce that (4 tiles at the 64-pixel grid with the default 16384 patches); a picture contributes a separate pass per grid. See the concurrency notes for Unlimited-OCR (§5.17) | diff --git a/scripts/hfget.sh b/scripts/hfget.sh index 1951cd0d..8c65e493 100755 --- a/scripts/hfget.sh +++ b/scripts/hfget.sh @@ -12,7 +12,15 @@ # A changed file is fetched again even at the same size. A complete run records each file's content # key (the LFS sha256, or the size for a small file) in /.hfget-manifest, and a later run # compares the listing against it. The manifest is written only when every file arrived, so its -# presence means the directory is a complete copy of some revision. +# presence means the directory is a complete copy of some revision. An LFS file's key is verified: +# the download is hashed and compared against the oid the listing claims before the file is kept, +# so the hub cannot hand back one file for another and a resumed transfer cannot splice into a +# plausible size. +# +# A file whose listed name would land outside the destination -- absolute, carrying a `..` +# segment, holding control characters, or naming hfget's own manifest -- is not a repo listing: +# the whole listing is refused. Skipping such an entry silently would leave a directory that +# reads as complete and is not. # # Exit status: 0 complete; 3 nothing on disk was changed (the listing could not be read, or what is # still to fetch does not fit), so a complete earlier copy is intact; anything else, a transfer @@ -35,6 +43,13 @@ set -e # sh cannot export a function, so each file is a re-entry of this script under `xargs -P`. if [ -n "$HFGET_CHILD" ]; then size=${1%% *}; rest=${1#* }; oid=${rest%% *}; path=${rest#* } + # The parent has vetted every name; this holds anyway, because $out is written straight + # from it and an escape writes outside the directory the operator named. + case "$path" in + ""|/*|*/|.|..|../*|*/../*) + echo "hfget: refusing a file named '$path', which does not land inside the destination" >&2 + exit 1;; + esac key=${oid:-$size} # LFS: sha256, non-LFS: size out=$HFGET_DEST/$path man=$HFGET_DEST/.hfget-manifest @@ -63,6 +78,17 @@ if [ -n "$HFGET_CHILD" ]; then fi got=$(wc -c < "$out") [ "$got" = "$size" ] || { echo "hfget: $path is $got bytes, listing says $size" >&2; exit 1; } + # An LFS name carries the sha256 the hub claims. Believe it only after computing it: the + # size check alone would take a swapped file at the same length, and a spliced resume at a + # resumed length. A mismatch deletes the file -- a fresh transfer is the only repair -- and + # nothing reaches the manifest. + if [ -n "$oid" ]; then + got=$(sha256sum "$out" | awk '{print $1}') + [ "$got" = "${oid#sha256:}" ] || { + echo "hfget: $path hashes to $got, the listing claims ${oid#sha256:}" >&2 + rm -f "$out" + exit 1; } + fi printf '%s\t%s\n' "$key" "$path" >> "$HFGET_MAN_OUT" exit 0 fi @@ -75,6 +101,7 @@ rev=${3:-main} jobs=${HFGET_JOBS:-4} command -v jq >/dev/null || { echo "hfget: jq is required" >&2; exit 2; } command -v curl >/dev/null || { echo "hfget: curl is required" >&2; exit 2; } +command -v sha256sum >/dev/null || { echo "hfget: sha256sum is required to verify LFS files" >&2; exit 2; } echo "hfget: listing $repo@$rev" # The listing is paginated (fifty entries per page, next page in a `Link: ...; rel="next"` @@ -108,6 +135,16 @@ while [ -n "$api" ]; do [ "$page" -gt 200 ] && { echo "hfget: listing did not terminate after 200 pages" >&2; exit 1; } done echo "hfget: $page page(s) of listing" +# A file name that does not land inside the destination is not a listing oddity: an absolute +# path, a `..` segment, a control character (a tab splices one entry into two fields of the +# transfer list), or a name shadowing hfget's own manifest, which the next run would read back +# as its record of verified content. Name the entry and stop; skipping silently would leave a +# directory that reads as complete and is not. +bad=$(printf '%s' "$listing" | jq -r '[.[] | select(.type == "file") + | select((.path | test("(^/|(^|/)\\.\\.(/|$))")) + or (.path | test("[[:cntrl:]]")) + or (.path | test("(^|/)[.]hfget-manifest")))] | map(.path) | join(", ")') +[ -n "$bad" ] && { echo "hfget: the listing names '$bad', which does not land inside the destination" >&2; exit 1; } have_st=$(printf '%s' "$listing" | jq '[.[] | select(.path | endswith(".safetensors"))] | length') sel='.[] | select(.type == "file")' [ "$have_st" -gt 0 ] && sel="$sel"' | select((.path | test("\\.(bin|msgpack|h5|onnx|onnx_data|gguf)$") or test("(^|/)(pytorch_model|consolidated)[^/]*\\.pth$")) | not)' diff --git a/tests/config_test.cpp b/tests/config_test.cpp index 53d25b66..72616748 100644 --- a/tests/config_test.cpp +++ b/tests/config_test.cpp @@ -102,6 +102,21 @@ TEST(an_empty_api_key_is_refused) { CHECK(c.api_key == "k"); } +/* --api-key-env reads the key where `ps` cannot: the empty-value refusal's sibling is the + * never-set one -- a compose environment: or unit Environment= line with a typo'd name must + * refuse at startup, not serve keyless under a guarded-looking command line. */ +TEST(an_api_key_env_that_is_unset_is_refused_and_one_that_is_set_is_the_key) { + unsetenv("RAD_TEST_KEY_ENV"); + CHECK_EQ(parse_fresh({ "--api-key-env", "RAD_TEST_KEY_ENV" }), RAD_E_INVAL); + CHECK_EQ(parse_fresh({ "--api-key-env", "" }), RAD_E_INVAL); + setenv("RAD_TEST_KEY_ENV", "s3cret", 1); + Config c; + CHECK_EQ(parse({ "--api-key-env", "RAD_TEST_KEY_ENV" }, &c), 0); + CHECK(c.api_key == "s3cret"); + CHECK(c.api_key_env == "RAD_TEST_KEY_ENV"); + unsetenv("RAD_TEST_KEY_ENV"); +} + /* --allow-host repeats: the loopback-only routes take the set of names, and an empty one is * a hole cut by a typo, so it is refused like the empty key. */ TEST(allow_host_repeats_and_refuses_the_empty_name) { @@ -467,6 +482,7 @@ std::vector> usage_options() { const std::map>& legal_values() { static const std::map> v = { { "--model", { "/m/y.rad" } }, { "--download-dir", { "/d" } }, + { "--model-revision", { "v1.2" } }, { "--radiance-home", { "/h1:/h2" } }, { "--kernels", { "libref" } }, { "--tp", { "2" } }, { "--tp-wire", { "wht6" } }, { "--tp-wire-min-kb", { "64" } }, { "--tp-attn-split", { "rows" } }, { "--weight-prefetch", { "off" } }, @@ -492,6 +508,7 @@ const std::map>& legal_values() { { "--draft-window", { "fixed" } }, { "--draft-short-from", { "4" } }, { "--draft-coupling", { "on" } }, { "--host", { "127.0.0.1" } }, { "--port", { "8001" } }, { "--api-key", { "k" } }, + { "--api-key-env", { "RAD_KEY_ENV_INVENTORY" } }, { "--allow-host", { "box" } }, { "--served-model-name", { "m" } }, { "--mm-max-patches", { "1024" } }, { "--control-vector", { "off" } }, @@ -549,6 +566,9 @@ const std::map>& legal_values() { * setting. */ TEST(every_listed_option_parses_and_is_reported_as_given) { LogGuard lg; + /* --api-key-env resolves at parse time and fails closed on an unset name, so the inventory + * needs the variable it names to exist. */ + setenv("RAD_KEY_ENV_INVENTORY", "inventory-key", 1); const auto opts = usage_options(); CHECK(opts.size() > 90); const std::vector names = diag::config_option_names(); diff --git a/tests/hf_model_test.cpp b/tests/hf_model_test.cpp index 0990868a..930011be 100644 --- a/tests/hf_model_test.cpp +++ b/tests/hf_model_test.cpp @@ -254,6 +254,146 @@ TEST(a_pth_that_is_not_the_weights_again_is_fetched_beside_the_safetensors) { CHECK(!fs::exists(root.path + "/pytorch_model.bin")); } +/* A listing that names a file outside the destination -- absolute, or a `..` segment -- is not + * a listing of a repo at all, so hfget.sh refuses the whole thing rather than half-obeying it: + * silently skipping the entry would leave a directory that reads as complete and is not, and + * the manifest would certify it. */ +const char* kEscapeListing = + "#!/bin/sh\n" + "for a in \"$@\"; do case \"$a\" in *api/models*)\n" + " printf '[{\"type\":\"file\",\"path\":\"../escape.bin\",\"size\":1}," + "{\"type\":\"file\",\"path\":\"kept.bin\",\"size\":1}]'; exit 0;; esac; done\n" + "exit 22\n"; + +TEST(a_listing_naming_a_path_outside_the_destination_is_refused) { + 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()); + FakeCurl curl(kEscapeListing); + const std::string cmd = "sh '" + hfget_beside_this_binary() + + "' radiance-test-owner/radiance-test-model '" + root.path + + "' >/dev/null 2>'" + root.path + "/err'"; + CHECK(std::system(cmd.c_str()) != 0); + CHECK(!fs::exists(root.path + "/escape.bin")); + CHECK(!fs::exists(root.path + "/kept.bin")); /* the whole listing is refused */ + CHECK(!fs::exists(root.path + "/.hfget-manifest")); + std::string err; + if (FILE* e = std::fopen((root.path + "/err").c_str(), "r")) { + char buf[256]; + size_t n; + while ((n = std::fread(buf, 1, sizeof buf - 1, e)) > 0) { buf[n] = '\0'; err += buf; } + std::fclose(e); + } + CHECK(has(err, "does not land inside the destination")); +} + +/* An LFS file's oid is the hub's claim about its bytes; the download is kept only once those + * bytes hash to it -- the size check alone would take a swapped file of the same length, and a + * spliced resume at any length the hub likes. A mismatch deletes the file and fails the run; + * a match lands in the manifest, which is what makes "warm" mean verified-warm after. */ +const char* kBadOid = + "#!/bin/sh\n" + "out=''; url=''; prev=''\n" + "for a in \"$@\"; do\n" + " [ \"$prev\" = -o ] && out=\"$a\"\n" + " case \"$a\" in https://*) url=\"$a\";; esac\n" + " prev=\"$a\"\n" + "done\n" + "case \"$url\" in *api/models*)\n" + " printf '[{\"type\":\"file\",\"path\":\"big.bin\",\"size\":10," + "\"lfs\":{\"oid\":\"0000000000000000000000000000000000000000000000000000000000000000\"}}]';" + " exit 0;; esac\n" + "[ -n \"$out\" ] && printf 0123456789 > \"$out\"\n" + "exit 0\n"; + +const char* kGoodOid = + "#!/bin/sh\n" + "out=''; url=''; prev=''\n" + "for a in \"$@\"; do\n" + " [ \"$prev\" = -o ] && out=\"$a\"\n" + " case \"$a\" in https://*) url=\"$a\";; esac\n" + " prev=\"$a\"\n" + "done\n" + "case \"$url\" in *api/models*)\n" + " oid=$(printf 0123456789 | sha256sum | cut -d' ' -f1)\n" + " printf '[{\"type\":\"file\",\"path\":\"big.bin\",\"size\":10,\"lfs\":{\"oid\":\"%s\"}}]'" + " \"$oid\"; exit 0;; esac\n" + "[ -n \"$out\" ] && printf 0123456789 > \"$out\"\n" + "exit 0\n"; + +TEST(an_lfs_file_that_does_not_hash_to_its_oid_is_not_kept) { + NEED_ARTIFACT(hfget_beside_this_binary()); + if (!on_path("jq")) SKIP("no jq on PATH, which hfget.sh needs"); + if (!on_path("sha256sum")) SKIP("no sha256sum on PATH, which hfget.sh needs"); + TempDir root; + REQUIRE(!root.path.empty()); + const std::string fetch = "sh '" + hfget_beside_this_binary() + + "' radiance-test-owner/radiance-test-model '" + root.path + + "' >/dev/null 2>'" + root.path + "/err'"; + { + FakeCurl curl(kBadOid); + CHECK(std::system(fetch.c_str()) != 0); + CHECK(!fs::exists(root.path + "/big.bin")); /* deleted, not left to be resumed */ + CHECK(!fs::exists(root.path + "/.hfget-manifest")); + std::string err; + if (FILE* e = std::fopen((root.path + "/err").c_str(), "r")) { + char buf[256]; + size_t n; + while ((n = std::fread(buf, 1, sizeof buf - 1, e)) > 0) { buf[n] = '\0'; err += buf; } + std::fclose(e); + } + CHECK(has(err, "hashes to")); + } + { + FakeCurl curl(kGoodOid); + CHECK_EQ(std::system(fetch.c_str()), 0); + CHECK(fs::exists(root.path + "/big.bin")); + CHECK_EQ(fs::file_size(root.path + "/big.bin"), 10u); + CHECK(fs::exists(root.path + "/.hfget-manifest")); /* the verified copy is certified */ + } +} + +/* --model-revision names the revision the fetch reads: the pinned ref is the one listed, and + * an unpinned fetch reads the repo's moving default branch -- which a deployment must be able + * to refuse outright rather than restart onto. */ +const char* kPinnedOnly = + "#!/bin/sh\n" + "out=''; url=''; prev=''\n" + "for a in \"$@\"; do\n" + " [ \"$prev\" = -o ] && out=\"$a\"\n" + " case \"$a\" in https://*) url=\"$a\";; esac\n" + " prev=\"$a\"\n" + "done\n" + "case \"$url\" in *api/models*/tree/refs/pr/42*)\n" + " printf '[{\"type\":\"file\",\"path\":\"m.rad\",\"size\":10}]'; exit 0;; esac\n" + "case \"$url\" in *api/models*) exit 22;; esac\n" + "[ -n \"$out\" ] && printf 0123456789 > \"$out\"\n" + "exit 0\n"; + +TEST(the_pinned_revision_is_the_revision_fetched) { + 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()); + FakeCurl curl(kPinnedOnly); + const std::string repo = "radiance-test-owner/radiance-test-model"; + auto resolve = [&](const char* rev, std::string* model) { + Config c; + c.model = repo; + c.download_dir = root.path; + if (rev) c.model_revision = rev; + bool ok = false; + stderr_of([&] { ok = resolve_hf_model(c); }); + *model = c.model; + return ok; + }; + std::string model; + CHECK(!resolve(nullptr, &model)); /* main: this hub has nothing there */ + CHECK(resolve("refs/pr/42", &model)); + CHECK_EQ(model, root.path + "/" + repo + "/m.rad"); +} + /* 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) {