Non-autoregressive System 1 decision engine. Typed choice, score and yes/no decisions over any text in a single forward pass, in 100+ languages, with a router that picks the right checkpoint per request.
Python calibrationclassificationdecision-modelhuggingfacejevmodernbertmultilingualnlppythonpytorchroutingtyped-decisionszero-shot
fix(nix): reach the two server knobs the module could not set
Aashishfe707808da0e
diff --git a/nix/laya-serve.nix b/nix/laya-serve.nixindex 8aa2cd6d..7bec06ea 100644--- a/nix/laya-serve.nix+++ b/nix/laya-serve.nix@@ -90,6 +90,38 @@ in'';};+ logLevel = lib.mkOption {+ type = lib.types.nullOr lib.types.str;+ default = null;+ example = "warning";+ description = ''+ uvicorn's log level (sets `LAYA_LOG_LEVEL`), one of `critical`, `error`,+ `warning`, `info`, `debug`, `trace`. `info`, which the server uses when+ this is unset, logs a line per request, so on a busy decision endpoint it+ is most of the unit's journal traffic; `warning` keeps startup and errors.+ Not an `enum` over those names: uvicorn checks the value, and a copy here+ could only fall behind it. null leaves the server's own default.+ '';+ };++ maxConcurrent = lib.mkOption {+ type = lib.types.nullOr lib.types.ints.positive;+ default = null;+ example = 4;+ description = ''+ Cap on requests admitted at once (sets `LAYA_MAX_CONCURRENT`). A request+ that arrives with every slot taken is refused with HTTP 503 right away+ rather than queued, which is what keeps the bodies held in memory+ bounded. Lower it on a host where a queue of forwards is worse+ than a refusal — measured on the `english` checkpoint, CPU, 16+ simultaneous requests: the median accepted request answered in 64 ms at a+ cap of 1 and 542 ms at 16, and 15 of 16 were refused in under 0.1 ms at+ that cap against none at 16. So the knob trades the latency of the+ requests that get through against the number turned away, and a host+ needs to be able to pick. null leaves the server's own default.+ '';+ };+autoTaskDetection = lib.mkOption {type = lib.types.bool;default = false;@@ -137,6 +169,10 @@ in} // lib.optionalAttrs (cfg.threads != null) {LAYA_THREADS = toString cfg.threads;OMP_NUM_THREADS = toString cfg.threads;+ } // lib.optionalAttrs (cfg.logLevel != null) {+ LAYA_LOG_LEVEL = cfg.logLevel;+ } // lib.optionalAttrs (cfg.maxConcurrent != null) {+ LAYA_MAX_CONCURRENT = toString cfg.maxConcurrent;} // {HF_HOME = "/var/lib/${cfg.stateDirectory}/huggingface";# torch-bin bundles its own CUDA runtime but still needs the hostdiff --git a/tests/test_packaging.py b/tests/test_packaging.pyindex 795134f6..ca1a3511 100644--- a/tests/test_packaging.py+++ b/tests/test_packaging.py@@ -284,6 +284,61 @@ check_true("nix/module still joins models into LAYA_MODELS",re.search(r'LAYA_MODELS = lib\.concatStringsSep "," cfg\.models;', nix_module) is not None,"the models option no longer feeds LAYA_MODELS; these checks need retargeting")+# ---- every knob the server reads from the environment has to be reachable from the module+# `laya.serve` has no config file and no CLI flag for any of it: it configures itself from LAYA_*+# and nothing else. On a NixOS host the unit's environment is the only thing that can hand those+# variables over, so a name the module never assigns is a control that host cannot ask for. Two+# were missing: `LAYA_LOG_LEVEL`, and `LAYA_MAX_CONCURRENT` -- the admission bound, which is what+# keeps the bodies buffered in memory bounded and refuses the excess with 503.+serve_src = read(os.path.join("laya", "serve.py"))+served = sorted(+ set(re.findall(r'environ\.get\("(LAYA_[A-Z_]+)"', serve_src))+ | set(re.findall(r'_env_bool\("(LAYA_[A-Z_]+)"', serve_src))+)+# Non-vacuity again: if the derivation found nothing, both directions below pass for free.+check_true("nix/serve.py's environment reads were found", len(served) >= 5,+ "got %r -- retarget this if laya/serve.py changes shape" % (served,))++# An assignment only. The `models` description names `LAYA_MODELS` in prose, and prose that+# mentions a variable sets nothing.+assigned = sorted(set(re.findall(r'\b(LAYA_[A-Z_]+)\s*=', nix_module))+ | set(re.findall(r'export (LAYA_[A-Z_]+)=', nix_module)))+check("nix/module reaches every env var laya.serve reads",+ [n for n in served if n not in assigned], [])+# The other direction is the silent failure: a misspelled name is a perfectly good string,+# systemd exports it, no Python ever looks at it, and the operator's setting does nothing.+check("nix/module assigns no env var laya.serve never reads",+ [n for n in assigned if n not in served], [])++# An option that nothing reads is a promise the unit does not keep, and the mirror case -- a+# setting the unit applies with no option to turn it -- is a host that cannot change it.+declared = re.findall(r"^ ([a-zA-Z]+) = lib\.mkOption \{", nix_module, re.M)+check_true("nix/module's options were found", len(declared) >= 5,+ "got %r -- retarget this if the option block changes shape" % (declared,))+check("nix/every declared option is used by the unit",+ [n for n in declared if "cfg.%s" % n not in nix_module], [])++# Both new options are opt-in: unset means the unit exports nothing and the server's own default+# applies, so a host that ignores them gets today's behaviour byte for byte.+for opt in ("logLevel", "maxConcurrent"):+ _b = re.search(r"^ %s = lib\.mkOption \{(.*?)\n \};" % opt, nix_module, re.S | re.M)+ check_true("nix/module declares %s" % opt, _b is not None, "option not found")+ _t = _b.group(1) if _b else ""+ check_true("nix/%s is opt-in (nullOr, default null)" % opt,+ _t.count("nullOr") == 1 and re.search(r"^\s*default = null;", _t, re.M) is not None,+ _t.strip()[:120])+ check_true("nix/%s is guarded by a != null optionalAttrs" % opt,+ re.search(r"lib\.optionalAttrs \(cfg\.%s != null\)" % opt, nix_module) is not None,+ "the unit would export the variable even when the host left it unset")++# The same lesson as `models`, stated for the whole module: no option may carry a closed list of+# names that somebody else validates. uvicorn checks the log level, laya checks the checkpoint+# name, and a copy here can only fall behind them -- which is how the module came to refuse ten+# spellings of a value the server accepts.+check_true("nix/module declares no closed enum over names it does not own",+ "types.enum" not in nix_module, "an enum in this module is a copy of someone "+ "else's list; defer to the thing that validates the value")+# --------------------------------------------------------------- declared extras# The runtime error in laya/structured.py tells users to install `laya[structured]`, and the# docs and README repeat it. A reference to an extra pyproject.toml does not declare is a dead