engine: --adapt-decay outside 0..1 falls back to 0.7 with a line on stderr (#1284)

--adapt-decay took any number. Above 1 the adaptive tier's usage counts grow without end (inf after a few hundred
adaptations) and the swap gains turn NaN, which breaks the sort that orders the swaps; a negative value flips the counts.
The value is now checked where it is parsed (include/strata/program/adapt_decay.hpp, also in sycl/): a finite value in 0..1
is used exactly as before (0 and 1 included, the range the calibration profile already allows); anything else, NaN and inf
too, runs with the default 0.7 and says so on stderr. A warning instead of the PR's exit 2: a risky pick is reported,
the engine still starts.

adapt_decay_test (25 checks) covers the range, the fallback and finite counts after 100000 adaptations.

Ported from PR #1284 (the check; the refusal became a fallback).
This commit is contained in:
sergqwer authored and Niko1221 committed 2026-10-26 18:35:58 +01:00
1 parent b3db5a1c83
commit 4a7e373da3
5 files changed
+80 -2

No files matched your search

+2 -1
View File
@@ -79,6 +79,7 @@
#include "strata/prefill/moe_mmq.hpp"
#endif
#include "strata/core/native_dense.hpp"
#include "strata/program/adapt_decay.hpp"
#include "strata/program/batch_read.hpp"
#include "strata/program/logits_selection.hpp"
#include "strata/program/conv_cache.hpp"
@@ -2648,7 +2649,7 @@ int main(int argc, char** argv) {
else if (a == "--mtp-window") o.mtp_window = std::atoll(next("--mtp-window"));
else if (a == "--pcie-frac") o.pcie_frac = std::atof(next("--pcie-frac"));
else if (a == "--adapt-every") { o.adapt_every = std::atoi(next("--adapt-every")); o.adapt_every_given = true; }
else if (a == "--adapt-decay") o.adapt_decay = (float) std::atof(next("--adapt-decay"));
else if (a == "--adapt-decay") o.adapt_decay = strata::program::adapt_decay_checked(std::atof(next("--adapt-decay"))); // #1284: outside 0..1 -> 0.7, said
else if (a == "--adapt-min-gain") o.adapt_min_gain = (float) std::atof(next("--adapt-min-gain"));
else if (a == "--adapt-async") { o.adapt_async = std::atoi(next("--adapt-async")) != 0 ? 1 : 0; o.adapt_async_given = o.adapt_async; }
else if (a == "--spec-min-p") o.spec_min_p = std::atof(next("--spec-min-p"));