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:
Constantin authored and StillDeadcode committed 2026-11-03 19:02:52 +01:00
1 parent aa182fc156
commit 9cb04f62a8
10 files changed
+164 -22

No files matched your search

+4 -4
View File
@@ -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;
+22 -3
View File
@@ -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;
+5 -3
View File
@@ -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