Archived
config: --gpu-memory-mib, the inverse of --gpu-headroom-mib
N claims that many MiB of every card; headroom is the rest. The two flags cannot be combined. vLLM's utilisation fraction, written in MiB.
This commit is contained in:
1 parent
aa182fc156
commit
9cb04f62a8
10 files changed
+164
-22
No files matched your search
+18
-4
@@ -87,7 +87,10 @@ static const Flag g_flags[] = {
|
||||
{ "--rope-scaling", "SPEC", "yarn:FACTOR[:ORIG]: static YaRN over the container's own rotary\n"
|
||||
"keys, no reconvert (docs/YARN.md); none: off" },
|
||||
|
||||
{ "--gpu-headroom-mib", "N", "VRAM left unclaimed on every card (default 96)" },
|
||||
{ "--gpu-memory-mib", "N", "VRAM claimed on every card; the rest is left unclaimed.\n"
|
||||
"Not with --gpu-headroom-mib" },
|
||||
{ "--gpu-headroom-mib", "N", "VRAM left unclaimed on every card (default 96).\n"
|
||||
"Not with --gpu-memory-mib" },
|
||||
{ "--kv-cache-dtype", "T", "bf16 | fp8 | fp8_v4 | k6_v4 -- fp8 halves what a token of\n"
|
||||
"context costs; fp8_v4 keeps V in 4 bits (0.78 of fp8), k6_v4\n"
|
||||
"also K in 6 (0.69); both Qwen3.8-27B and -Flash-Next" },
|
||||
@@ -587,14 +590,15 @@ int config_parse(int argc, char** argv, Config* c) {
|
||||
* old launch lines at the flags that move the split. */
|
||||
else if (S("--vram-weights-mib") || S("--vram-kv-mib")) {
|
||||
RAD_ERR("%s was removed: the card is split between the weights and the cache from what "
|
||||
"the model needs. --gpu-headroom-mib takes card space away, --max-model-len and "
|
||||
"--max-num-seqs bound the cache, and --host-pool-mib decides which experts stay "
|
||||
"on the card", a.c_str());
|
||||
"the model needs. --gpu-headroom-mib or --gpu-memory-mib take card space away, "
|
||||
"--max-model-len and --max-num-seqs bound the cache, and --host-pool-mib "
|
||||
"decides which experts stay on the card", a.c_str());
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
/* --gpu-headroom is accepted as an alias of --gpu-headroom-mib. */
|
||||
else if (S("--gpu-headroom-mib") || S("--gpu-headroom"))
|
||||
{ if (!num(0, INT64_MAX, &c->gpu_headroom_mib)) return RAD_E_INVAL; }
|
||||
else if (S("--gpu-memory-mib")) { if (!num(1, INT64_MAX, &c->gpu_memory_mib)) return RAD_E_INVAL; }
|
||||
else if (S("--host-headroom-mib")) { if (!num(0, INT64_MAX, &c->host_headroom_mib)) return RAD_E_INVAL; }
|
||||
else if (S("--kv-cache-dtype")) {
|
||||
if (!(v = need(i))) return RAD_E_INVAL;
|
||||
@@ -1130,6 +1134,14 @@ int config_parse(int argc, char** argv, Config* c) {
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
|
||||
/* --gpu-memory-mib claims the card; --gpu-headroom-mib leaves it unclaimed. The alias
|
||||
* --gpu-headroom is recorded as --gpu-headroom-mib, so it is covered. */
|
||||
if (c->given.count("--gpu-memory-mib") && c->given.count("--gpu-headroom-mib")) {
|
||||
RAD_ERR("--gpu-memory-mib claims the card and --gpu-headroom-mib leaves it unclaimed; "
|
||||
"give one");
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
|
||||
/* Prompt lookup alone: the window is its K, stated once. */
|
||||
if (c->spec_ngram_min > c->spec_ngram_max) {
|
||||
RAD_ERR("--spec-ngram-min %d is longer than --spec-ngram-max %d", c->spec_ngram_min,
|
||||
@@ -1328,6 +1340,8 @@ const ShowRow kShow[] = {
|
||||
{ "--max-model-len", [](const Config& c) {
|
||||
return c.max_ctx ? num(c.max_ctx) : std::string("0 (the model's training context)"); } },
|
||||
{ "--rope-scaling", [](const Config& c) { return or_none(c.rope_scaling, "the checkpoint's own"); } },
|
||||
{ "--gpu-memory-mib", [](const Config& c) {
|
||||
return c.gpu_memory_mib ? num(c.gpu_memory_mib) : std::string("0 (use --gpu-headroom-mib)"); } },
|
||||
{ "--gpu-headroom-mib", [](const Config& c) { return num(c.gpu_headroom_mib); } },
|
||||
{ "--kv-cache-dtype", [](const Config& c) { return c.kv_cache_dtype; } },
|
||||
{ "--state-cache-dtype", [](const Config& c) { return c.state_cache_dtype; } },
|
||||
|
||||
@@ -4133,10 +4133,16 @@ int Engine::start() {
|
||||
: fmt("%s --gpu-headroom-mib", humanb(want).c_str());
|
||||
if (room < allowance) {
|
||||
const int64_t raise_mib = (allowance - room + MiB - 1) / MiB;
|
||||
const int64_t need_head = std::max<int64_t>(cfg_.gpu_headroom_mib, 0) + raise_mib;
|
||||
const std::string fix = cfg_.gpu_memory_mib > 0
|
||||
? fmt("Set --gpu-memory-mib to at most %lld: what is left here falls with it one "
|
||||
"for one.",
|
||||
(long long)(props.vram_bytes / MiB - need_head))
|
||||
: fmt("Set --gpu-headroom-mib to at least %lld: what is left here rises with it "
|
||||
"one for one.", (long long)need_head);
|
||||
RAD_WARN("card %d settled at %s free against %s, which leaves %s for a kernel's first "
|
||||
"launch to load its code object and size its scratch in -- under the %s this "
|
||||
"engine allows for its own. %s Set --gpu-headroom-mib to at least %lld: what "
|
||||
"is left here rises with it one for one.",
|
||||
"engine allows for its own. %s %s",
|
||||
r->device, humanb(got).c_str(), asked.c_str(),
|
||||
humanb(std::max<int64_t>(room, 0)).c_str(), humanb(allowance).c_str(),
|
||||
got < want
|
||||
@@ -4144,7 +4150,7 @@ int Engine::start() {
|
||||
"another process on it or an allocation the budget does not "
|
||||
"count.", humanb(want - got).c_str()).c_str()
|
||||
: "",
|
||||
(long long)(std::max<int64_t>(cfg_.gpu_headroom_mib, 0) + raise_mib));
|
||||
fix.c_str());
|
||||
} else if (got < want) {
|
||||
RAD_INFO("card %d settled at %s free against %s: %s of the headroom was taken after "
|
||||
"the budget read the card, by another process on it or an allocation the "
|
||||
|
||||
+4
-4
@@ -524,8 +524,8 @@ int KVManager::carve_into(Pool& kv_pool) {
|
||||
" vram_kv %10s\n"
|
||||
" short by %10s\n"
|
||||
"Lower --max-num-seqs, or give the cache more of the card: a smaller "
|
||||
"--gpu-headroom-mib or a larger --host-pool-mib. The engine will not shrink one of "
|
||||
"them for you (spec §6).",
|
||||
"--gpu-headroom-mib, a larger --gpu-memory-mib, or a larger --host-pool-mib. The "
|
||||
"engine will not shrink one of them for you (spec §6).",
|
||||
humanb(fixed).c_str(), (long long)max_seqs_, humanb(budget_bytes).c_str(),
|
||||
humanb(fixed - budget_bytes + 1).c_str());
|
||||
return RAD_E_NOMEM;
|
||||
@@ -554,8 +554,8 @@ int KVManager::carve_into(Pool& kv_pool) {
|
||||
}
|
||||
if (p.n_blocks <= 0) {
|
||||
RAD_ERR("KV group '%s': a %s KV pool leaves 0 blocks (%s a page) after the fixed "
|
||||
"linear/conv costs of %s. Raise --host-pool-mib or lower --gpu-headroom-mib, or "
|
||||
"lower --max-num-seqs.",
|
||||
"linear/conv costs of %s. Raise --host-pool-mib or --gpu-memory-mib, or lower "
|
||||
"--gpu-headroom-mib or --max-num-seqs.",
|
||||
p.name.c_str(), humanb(budget_bytes).c_str(),
|
||||
humanb(p.bytes_per_block).c_str(), humanb(fixed).c_str());
|
||||
return RAD_E_NOMEM;
|
||||
|
||||
@@ -76,6 +76,21 @@ static int resolve(Config& cfg, const std::vector<VramFacts>& per_rank, VramBudg
|
||||
if (f.unified) b.host_pinned = std::max(b.host_pinned, f.host_pinned);
|
||||
}
|
||||
if (!b.unified) b.host_pinned = 0;
|
||||
/* --gpu-memory-mib is the inverse of --gpu-headroom-mib: N + headroom = the card, in MiB.
|
||||
* Convert once the smallest rank capacity is known. A device that reports no capacity has
|
||||
* nothing to claim, so the flag does not apply. */
|
||||
if (b.capacity > 0 && cfg.gpu_memory_mib > 0) {
|
||||
const int64_t cap_mib = b.capacity / kMiB;
|
||||
if (cfg.gpu_memory_mib > cap_mib) {
|
||||
b.report = fmt("--gpu-memory-mib %lld is above this card's %lld MiB",
|
||||
(long long)cfg.gpu_memory_mib, (long long)cap_mib);
|
||||
if (log) RAD_ERR("%s", b.report.c_str());
|
||||
if (out) *out = b;
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
cfg.gpu_headroom_mib = cap_mib - cfg.gpu_memory_mib;
|
||||
cfg.given["--gpu-headroom-mib"] = "derived from --gpu-memory-mib";
|
||||
}
|
||||
b.headroom = std::max<int64_t>(cfg.gpu_headroom_mib, 0) * kMiB;
|
||||
int64_t host_reserve = 0;
|
||||
for (const VramFacts& f : per_rank) host_reserve = std::max(host_reserve, f.host_reserve);
|
||||
@@ -116,6 +131,11 @@ static int resolve(Config& cfg, const std::vector<VramFacts>& per_rank, VramBudg
|
||||
b.queues + b.prefetch + b.host_pinned);
|
||||
|
||||
if (b.claimable < 0) {
|
||||
const char* how = cfg.gpu_memory_mib > 0
|
||||
? "Raise --gpu-memory-mib, lower --max-num-batched-tokens (the arena scales with it), "
|
||||
"or free the card.\n"
|
||||
: "Lower --gpu-headroom-mib, lower --max-num-batched-tokens (the arena scales with it), "
|
||||
"or free the card.\n";
|
||||
b.report = fmt(
|
||||
"VRAM does not cover the fixed costs before a single pool is sized:\n"
|
||||
" card total %10s\n"
|
||||
@@ -128,12 +148,11 @@ static int resolve(Config& cfg, const std::vector<VramFacts>& per_rank, VramBudg
|
||||
" expert prefetch %10s (its ring of expert units and buffers)\n"
|
||||
" ------------------------------\n"
|
||||
" short by %10s\n"
|
||||
"Lower --gpu-headroom-mib, lower --max-num-batched-tokens (the arena scales with it), "
|
||||
"or free the card.\n",
|
||||
"%s",
|
||||
humanb(b.capacity).c_str(), humanb(b.already_held).c_str(), humanb(b.drift).c_str(),
|
||||
humanb(b.headroom).c_str(), humanb(b.arena).c_str(), humanb(b.staging).c_str(),
|
||||
humanb(b.queues).c_str(), b.n_queues, humanb(b.queue_bytes).c_str(),
|
||||
humanb(b.prefetch).c_str(), humanb(-b.claimable).c_str());
|
||||
humanb(b.prefetch).c_str(), humanb(-b.claimable).c_str(), how);
|
||||
if (log) RAD_ERR("%s", b.report.c_str());
|
||||
if (out) *out = b;
|
||||
return RAD_E_NOMEM;
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
* loaded code. The only observed term, printed on its own line so a
|
||||
* desktop on the card shows up there instead of shrinking a pool.
|
||||
* --gpu-headroom-mib what the operator leaves alone (default 96 MiB).
|
||||
* --gpu-memory-mib the inverse: claim this much of the card; headroom is the rest.
|
||||
* Not with --gpu-headroom-mib.
|
||||
* arena activation arena plus scratch, from arena_plan_bytes() on the buffer
|
||||
* plan, the same call that later allocates it.
|
||||
*
|
||||
@@ -32,9 +34,9 @@
|
||||
* KVManager::ceiling; the experts at the whole plane) and one side's excess goes to the other.
|
||||
*
|
||||
* No flag states a pool size: unbudgeted VRAM is unusable, and on a model whose experts do not
|
||||
* fit every unbudgeted GiB costs decode time. Operators move the inputs instead: --gpu-headroom-mib,
|
||||
* --max-model-len and --max-num-seqs (cache bound), --host-pool-mib (which experts must stay on
|
||||
* the card).
|
||||
* fit every unbudgeted GiB costs decode time. Operators move the inputs instead: --gpu-headroom-mib
|
||||
* or --gpu-memory-mib, --max-model-len and --max-num-seqs (cache bound), --host-pool-mib (which
|
||||
* experts must stay on the card).
|
||||
*
|
||||
* The host backend uses half the machine's memory as its capacity (host_vram_bytes) and splits it
|
||||
* like a card; its weights pool holds what a host kernel cannot read where the container stores it
|
||||
|
||||
@@ -859,6 +859,9 @@ struct Config {
|
||||
int64_t vram_weights_mib = 0;
|
||||
int64_t vram_kv_mib = 0;
|
||||
int64_t gpu_headroom_mib = 96; /* --gpu-headroom-mib, left unclaimed on every card */
|
||||
/* --gpu-memory-mib: claim this much of every card; 0 uses gpu_headroom_mib. Inverse of
|
||||
* headroom: N + headroom = the card, in MiB. Not with --gpu-headroom-mib. */
|
||||
int64_t gpu_memory_mib = 0;
|
||||
/* --kv-cache-dtype bf16|fp8|fp8_v4|k6_v4. fp8 is an E4M3 cache with per-(sequence, head)
|
||||
* descales; it halves the per-token cost, most of the KV pool at production context. fp8_v4
|
||||
* keeps K as E4M3 and V as int4 in groups of 32, k6_v4 also K as int6 (RadBuildCtx::kv_quant),
|
||||
|
||||
Reference in new issue
Block a user