|
31 | 31 | #include <list> |
32 | 32 | #include <regex> |
33 | 33 | #include <set> |
| 34 | +#include <sstream> |
34 | 35 | #include <string> |
35 | 36 | #include <thread> // for hardware_concurrency |
36 | 37 | #include <vector> |
@@ -1310,6 +1311,81 @@ common_params_context common_params_parser_init(common_params & params, llama_ex |
1310 | 1311 | params.cache_ram_mib = value; |
1311 | 1312 | } |
1312 | 1313 | ).set_env("LLAMA_ARG_CACHE_RAM").set_examples({LLAMA_EXAMPLE_SERVER, LLAMA_EXAMPLE_CLI})); |
| 1314 | + add_opt(common_arg( |
| 1315 | + {"--kv-tiered"}, "VRAM%,RAM%,SSD%", |
| 1316 | + "enable tiered KV cache with percentages for VRAM, RAM, SSD (e.g., 25,25,50 for 25% VRAM, 25% RAM, 50% SSD)", |
| 1317 | + [](common_params & params, const std::string & value) { |
| 1318 | + params.kv_tiered_enabled = true; |
| 1319 | + // Parse the percentage string |
| 1320 | + std::vector<std::string> parts; |
| 1321 | + std::stringstream ss(value); |
| 1322 | + std::string part; |
| 1323 | + while (std::getline(ss, part, ',')) { |
| 1324 | + parts.push_back(part); |
| 1325 | + } |
| 1326 | + if (parts.size() == 3) { |
| 1327 | + params.kv_tier_hot_pct = std::stof(parts[0]); |
| 1328 | + params.kv_tier_warm_pct = std::stof(parts[1]); |
| 1329 | + params.kv_tier_cold_pct = std::stof(parts[2]); |
| 1330 | + } |
| 1331 | + } |
| 1332 | + ).set_env("LLAMA_ARG_KT_TIERED").set_examples({LLAMA_EXAMPLE_SERVER})); |
| 1333 | + add_opt(common_arg( |
| 1334 | + {"--tier-ssd-path"}, "PATH", |
| 1335 | + "directory for cold tier (SSD) storage", |
| 1336 | + [](common_params & params, const std::string & value) { |
| 1337 | + params.kv_tier_ssd_path = value; |
| 1338 | + } |
| 1339 | + ).set_env("LLAMA_ARG_TIER_SSD_PATH").set_examples({LLAMA_EXAMPLE_SERVER})); |
| 1340 | + add_opt(common_arg( |
| 1341 | + {"--tier-eviction-policy"}, "POLICY", |
| 1342 | + "eviction policy: 0=LRU, 1=LFU, 2=attention, 3=hybrid (default)", |
| 1343 | + [](common_params & params, int value) { |
| 1344 | + params.kv_tier_eviction_policy = value; |
| 1345 | + } |
| 1346 | + ).set_env("LLAMA_ARG_TIER_EVICTION_POLICY").set_examples({LLAMA_EXAMPLE_SERVER})); |
| 1347 | + add_opt(common_arg( |
| 1348 | + {"--tier-compression"}, "TYPE", |
| 1349 | + "compression type: 0=none, 1=int4, 2=int8, 3=lz4, 4=quantized", |
| 1350 | + [](common_params & params, int value) { |
| 1351 | + params.kv_tier_compression = value; |
| 1352 | + } |
| 1353 | + ).set_env("LLAMA_ARG_TIER_COMPRESSION").set_examples({LLAMA_EXAMPLE_SERVER})); |
| 1354 | + add_opt(common_arg( |
| 1355 | + {"--tier-attention-threshold"}, "THRESH", |
| 1356 | + "attention threshold for eviction (0.0-1.0, default: 0.1)", |
| 1357 | + [](common_params & params, int value) { |
| 1358 | + params.kv_tier_attention_threshold = float(value) / 100.0f; |
| 1359 | + } |
| 1360 | + ).set_env("LLAMA_ARG_TIER_ATTENTION_THRESHOLD").set_examples({LLAMA_EXAMPLE_SERVER})); |
| 1361 | + add_opt(common_arg( |
| 1362 | + {"--kv-warm-device"}, "DEVICE", |
| 1363 | + "HIP device index to use as warm KV cache tier (e.g. 1 for 6900XT eGPU); requires --kv-tiered", |
| 1364 | + [](common_params & params, int value) { |
| 1365 | + params.kv_warm_device = value; |
| 1366 | + } |
| 1367 | + ).set_env("LLAMA_ARG_KV_WARM_DEVICE").set_examples({LLAMA_EXAMPLE_SERVER})); |
| 1368 | + add_opt(common_arg( |
| 1369 | + {"--kv-semantic-index"}, "PATH", |
| 1370 | + "path to embedding model (GGUF) for semantic KV cache indexing (e.g. bge-small); empty = disabled", |
| 1371 | + [](common_params & params, const std::string & value) { |
| 1372 | + params.kv_semantic_index = value; |
| 1373 | + } |
| 1374 | + ).set_env("LLAMA_ARG_KV_SEMANTIC_INDEX").set_examples({LLAMA_EXAMPLE_SERVER})); |
| 1375 | + add_opt(common_arg( |
| 1376 | + {"--kv-semantic-threshold"}, "THRESHOLD", |
| 1377 | + "minimum cosine similarity threshold for semantic prefetch hints (default: 0.65)", |
| 1378 | + [](common_params & params, const std::string & value) { |
| 1379 | + params.kv_semantic_threshold = std::stof(value); |
| 1380 | + } |
| 1381 | + ).set_env("LLAMA_ARG_KV_SEMANTIC_THRESHOLD").set_examples({LLAMA_EXAMPLE_SERVER})); |
| 1382 | + add_opt(common_arg( |
| 1383 | + {"--kv-semantic-topk"}, "K", |
| 1384 | + "number of prefetch hints to return (default: 5)", |
| 1385 | + [](common_params & params, int value) { |
| 1386 | + params.kv_semantic_top_k = value; |
| 1387 | + } |
| 1388 | + ).set_env("LLAMA_ARG_KV_SEMANTIC_TOPK").set_examples({LLAMA_EXAMPLE_SERVER})); |
1313 | 1389 | add_opt(common_arg( |
1314 | 1390 | {"-kvu", "--kv-unified"}, |
1315 | 1391 | {"-no-kvu", "--no-kv-unified"}, |
@@ -2354,6 +2430,27 @@ common_params_context common_params_parser_init(common_params & params, llama_ex |
2354 | 2430 | } |
2355 | 2431 | } |
2356 | 2432 | ).set_env("LLAMA_ARG_N_GPU_LAYERS")); |
| 2433 | + add_opt(common_arg( |
| 2434 | + {"--weight-paging"}, |
| 2435 | + "enable NVMe→VRAM demand paging for model weights (allows models larger than VRAM)", |
| 2436 | + [](common_params & params) { |
| 2437 | + params.weight_paging_enabled = true; |
| 2438 | + } |
| 2439 | + ).set_examples({LLAMA_EXAMPLE_SERVER, LLAMA_EXAMPLE_CLI}).set_env("LLAMA_ARG_WEIGHT_PAGING")); |
| 2440 | + add_opt(common_arg( |
| 2441 | + {"--weight-paging-slots"}, "N", |
| 2442 | + "number of VRAM slots for weight paging (-1 = auto, default: -1)", |
| 2443 | + [](common_params & params, const std::string & value) { |
| 2444 | + params.weight_paging_slots = std::stoi(value); |
| 2445 | + } |
| 2446 | + ).set_examples({LLAMA_EXAMPLE_SERVER, LLAMA_EXAMPLE_CLI}).set_env("LLAMA_ARG_WEIGHT_PAGING_SLOTS")); |
| 2447 | + add_opt(common_arg( |
| 2448 | + {"--weight-paging-prefetch"}, |
| 2449 | + "enable async prefetch of next layer (default: enabled)", |
| 2450 | + [](common_params & params) { |
| 2451 | + params.weight_paging_prefetch = true; |
| 2452 | + } |
| 2453 | + ).set_examples({LLAMA_EXAMPLE_SERVER, LLAMA_EXAMPLE_CLI}).set_env("LLAMA_ARG_WEIGHT_PAGING_PREFETCH")); |
2357 | 2454 | add_opt(common_arg( |
2358 | 2455 | {"-sm", "--split-mode"}, "{none,layer,row,tensor}", |
2359 | 2456 | "how to split the model across multiple GPUs, one of:\n" |
|
0 commit comments