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

+22 -1
View File
@@ -507,7 +507,8 @@ const std::map<std::string, std::vector<std::string>>& legal_values() {
{ "--preempt-wait-ms", { "5000" } },
{ "--max-num-seqs", { "4" } },
{ "--max-model-len", { "4096" } }, { "--rope-scaling", { "yarn:4" } },
{ "--gpu-headroom-mib", { "128" } }, { "--kv-cache-dtype", { "fp8" } },
{ "--gpu-memory-mib", { "16384" } }, { "--gpu-headroom-mib", { "128" } },
{ "--kv-cache-dtype", { "fp8" } },
{ "--state-cache-dtype", { "f16" } }, { "--attn-prefill-fp8", { "both" } },
{ "--kv-resident", { "65536" } },
{ "--host-pool-mib", { "1024" } }, { "--host-headroom-mib", { "2048" } },
@@ -1387,6 +1388,26 @@ TEST(gpu_headroom_parses_under_both_spellings) {
CHECK_EQ(d.gpu_headroom_mib, 96ll);
}
/* --gpu-memory-mib is the inverse of --gpu-headroom-mib; they cannot be combined. The default
* headroom is not "given", so memory alone is legal and leaves the default until the resolver. */
TEST(gpu_memory_mib_parses_and_excludes_headroom) {
Config a;
CHECK_EQ(parse({ "--gpu-memory-mib", "28000" }, &a), RAD_OK);
CHECK_EQ(a.gpu_memory_mib, 28000ll);
CHECK_EQ(a.gpu_headroom_mib, 96ll);
CHECK(a.given.count("--gpu-memory-mib"));
CHECK(!a.given.count("--gpu-headroom-mib"));
Config z;
CHECK_EQ(parse({ "--gpu-memory-mib", "0" }, &z), RAD_E_INVAL);
CHECK_EQ(parse({ "--gpu-memory-mib", "-1" }, &z), RAD_E_INVAL);
CHECK_EQ(parse({ "--gpu-memory-mib", "8x" }, &z), RAD_E_INVAL);
Config b, c;
CHECK_EQ(parse({ "--gpu-memory-mib", "28000", "--gpu-headroom-mib", "96" }, &b), RAD_E_INVAL);
CHECK_EQ(parse({ "--gpu-memory-mib", "28000", "--gpu-headroom", "96" }, &c), RAD_E_INVAL);
}
TEST(the_kernel_hierarchy_is_separated_by_commas_or_colons_and_ordered) {
Config c;
CHECK_EQ(parse({ "--kernels", "libr4d.so,libref.so" }, &c), RAD_OK);
+70
View File
@@ -7273,6 +7273,76 @@ TEST(the_prefill_stage_is_two_layers_of_what_the_card_leaves_off) {
}
}
/* --gpu-memory-mib N is --gpu-headroom-mib (card - N): the same split, the same pools. Over the
* card is a named refuse, and the trial still writes nothing. */
TEST(gpu_memory_mib_is_the_inverse_of_gpu_headroom_mib) {
constexpr int64_t MiB = 1 << 20;
constexpr int64_t cap_mib = 16384;
{
Config via_head = derive_config();
via_head.gpu_headroom_mib = 256;
Config via_mem = derive_config();
via_mem.gpu_memory_mib = cap_mib - 256;
VramBudget bh, bm;
int rc_h = 0, rc_m = 0;
stderr_of([&] {
rc_h = vram_budget_resolve(via_head, { hand_facts(false) }, &bh);
rc_m = vram_budget_resolve(via_mem, { hand_facts(false) }, &bm);
});
CHECK_OK(rc_h);
CHECK_OK(rc_m);
CHECK_EQ(bh.headroom, bm.headroom);
CHECK_EQ(bh.claimable, bm.claimable);
CHECK_EQ(via_head.vram_weights_mib, via_mem.vram_weights_mib);
CHECK_EQ(via_head.vram_kv_mib, via_mem.vram_kv_mib);
CHECK_EQ(via_mem.gpu_headroom_mib, 256ll);
CHECK_EQ(via_mem.given["--gpu-headroom-mib"], std::string("derived from --gpu-memory-mib"));
}
{
Config c = derive_config();
c.gpu_memory_mib = cap_mib; /* headroom 0 */
VramBudget b;
int rc = 0;
stderr_of([&] { rc = vram_budget_resolve(c, { hand_facts(false) }, &b); });
CHECK_OK(rc);
CHECK_EQ(c.gpu_headroom_mib, 0ll);
CHECK_EQ(b.headroom, 0ll);
CHECK_EQ(b.claimable, (15096 + 96) * MiB);
}
{
Config c = derive_config();
c.gpu_memory_mib = cap_mib + 1;
VramBudget b;
int rc = 0;
stderr_of([&] { rc = vram_budget_resolve(c, { hand_facts(false) }, &b); });
CHECK_EQ(rc, RAD_E_INVAL);
CHECK(has(b.report, "--gpu-memory-mib"));
CHECK_EQ(c.gpu_headroom_mib, 96ll); /* not rewritten on refuse */
}
{
Config c = derive_config();
c.gpu_memory_mib = cap_mib - 256;
const Config before = c;
VramBudget t;
CHECK_OK(vram_budget_trial(c, { hand_facts(false) }, &t));
CHECK_EQ(c.gpu_headroom_mib, before.gpu_headroom_mib);
CHECK_EQ(c.vram_weights_mib, before.vram_weights_mib);
CHECK_EQ(c.vram_kv_mib, before.vram_kv_mib);
CHECK_EQ(t.headroom, 256 * MiB);
}
/* A device with no capacity has nothing to claim: the flag is ignored. */
{
Config c = derive_config();
c.gpu_memory_mib = 4096;
VramFacts f{};
f.kv_ceiling = 300LL << 20;
VramBudget b;
CHECK_OK(vram_budget_resolve(c, { f }, &b));
CHECK_EQ(c.gpu_headroom_mib, 96ll);
CHECK_EQ(c.vram_kv_mib, 300ll);
}
}
/* Over random cards and programs the split either refuses by name or hands out no more than the
* card: every granted pool plus every fixed term fits the capacity, with at most the MiB each of
* the two pools may round into the headroom. The shares add up to the elastic part, the static