Merge branch 'f-1402-d2' into f-1402

This commit is contained in:
Niko1221 committed 2026-10-07 04:05:01 +02:00
commit 1be32e9c7b
14 files changed
+1744 -8

No files matched your search

+27
View File
@@ -647,6 +647,9 @@ void usage() {
" --pack DIR the pack directory (default pack/full)\n"
" --tokens LIST the prompt as comma-separated token IDS (required)\n"
" --tokens-file PATH pretokenized prompt, commas or whitespace (alternative to --tokens)\n"
" --gpu LIST run on these GPUs, comma-separated nvidia-smi/PCI indices (default: every\n"
" visible one); sets CUDA_VISIBLE_DEVICES/CUDA_DEVICE_ORDER inside the engine,\n"
" so a caller never has to export environment variables\n"
" --ple-gguf PATH required PLE table (original second GGUF shard); with --native, the model's\n"
" shard that holds per_layer_token_embd.weight when not given\n"
" --no-ple explicit diagnostic ablation of the PLE layer\n"
@@ -1530,6 +1533,29 @@ int main(int argc, char** argv) {
setenv("CUDA_MODULE_LOADING", "EAGER", 0);
#endif
}
// --gpu LIST pins the visible GPUs (nvidia-smi/PCI order) from the command line instead of the caller's
// environment: CUDA_VISIBLE_DEVICES is read at the first CUDA call, so this has to happen here, before
// anything else. The value itself is consumed again by the option loop below.
for (int i = 1; i + 1 < argc; ++i) {
if (std::string(argv[i]) != "--gpu") continue;
// The caller's own environment is overridden, so say so (a stale CUDA_VISIBLE_DEVICES from a launcher
// would otherwise silently lose to the flag).
const char* envname = "CUDA_VISIBLE_DEVICES";
#if defined(STRATA_USE_HIP) || defined(STRATA_HIP_GFX906)
envname = "HIP_VISIBLE_DEVICES"; // the AMD runtime ignores CUDA_VISIBLE_DEVICES (serve/server.py sets this one)
#endif
const char* prev = std::getenv(envname);
if (prev && prev[0] && std::string(prev) != argv[i + 1])
std::fprintf(stderr, "warning: --gpu %s overrides %s=%s from the environment\n", argv[i + 1], envname, prev);
#if defined(_WIN32)
_putenv_s("CUDA_DEVICE_ORDER", "PCI_BUS_ID");
_putenv_s(envname, argv[i + 1]);
#else
setenv("CUDA_DEVICE_ORDER", "PCI_BUS_ID", 1);
setenv(envname, argv[i + 1], 1);
#endif
break;
}
Options o;
bool have_tokens = false;
bool have_logits_stride = false;
@@ -1541,6 +1567,7 @@ int main(int argc, char** argv) {
};
bool parsed = true;
if (a == "--help" || a == "-h") { usage(); return 0; }
else if (a == "--gpu") { (void) next("--gpu"); } // applied at startup, before any CUDA call
else if (a == "--pack") o.pack = next("--pack");
else if (a == "--tokens") {
if (have_tokens) { std::fprintf(stderr, "supply one token input only\n"); return 2; }