Skip to content

armgit / laya

Public Imported from GitHub
0

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.

chore: wire the merged env vars, extras and suites through nix, docs and CI guards

Nandakishor794c5fd3bceb
diff --git a/docs/docker.md b/docs/docker.md
index 90bc52f0..99696d21 100644
--- a/docs/docker.md
+++ b/docs/docker.md
@@ -72,6 +72,7 @@ work with `docker run -e`; Compose-only settings are identified below.
| `LAYA_CPU_AMP` | unset | `bf16` opts the CPU forward into bf16; anything else leaves it fp32 |
| `LAYA_MODEL` | `auto` | Router alias: `auto`, `english`, `multilingual`, `typed-decisions` |
| `LAYA_MODEL_PATH` | unset | Compatible checkpoint path inside the container |
+| `LAYA_REVISION` | unset | Hub commit, branch or tag used for every checkpoint download, or `reviewed` for the reviewed SHAs in `laya/revisions.py`; a `revision=` argument still wins |
| `LAYA_REQUEST_FILE` | bundled request | JSON request path inside the container |
| `OMP_NUM_THREADS` | `4` | CPU threads; keep within available cores |
| `HF_TOKEN` / `HF_TOKEN_FILE` | unset | Optional Hugging Face credential |
diff --git a/nix/laya-serve.nix b/nix/laya-serve.nix
index 105eeddb..a3c80398 100644
--- a/nix/laya-serve.nix
+++ b/nix/laya-serve.nix
@@ -192,6 +192,41 @@ in
'';
};
+ maxLoaded = lib.mkOption {
+ type = lib.types.nullOr lib.types.ints.positive;
+ default = null;
+ example = 3;
+ description = ''
+ Checkpoints kept resident at once (sets `LAYA_MAX_LOADED`). The Router
+ keeps two by default, the number automatic routing chooses between;
+ with `autoTaskDetection` a third one becomes reachable on demand, and a
+ cap below what routing chooses rebuilds a checkpoint on every switch.
+ null leaves the Router's own default.
+ '';
+ };
+
+ maxTokenBudget = lib.mkOption {
+ type = lib.types.nullOr lib.types.ints.positive;
+ default = null;
+ example = 4096;
+ description = ''
+ Ceiling on the per-request `max_len` / `head_max_len` a client may ask
+ for (sets `LAYA_MAX_TOKEN_BUDGET`); a larger value is refused with 422.
+ null leaves the server's own default.
+ '';
+ };
+
+ revision = lib.mkOption {
+ type = lib.types.nullOr (lib.types.strMatching "[A-Za-z0-9._/-]+");
+ default = null;
+ example = "reviewed";
+ description = ''
+ Hub commit, branch or tag every checkpoint is downloaded at (sets
+ `LAYA_REVISION`), or `reviewed` for the reviewed commit SHAs laya ships.
+ null keeps huggingface_hub's default revision and any existing cache.
+ '';
+ };
+
autoTaskDetection = lib.mkOption {
type = lib.types.bool;
default = false;
@@ -249,6 +284,12 @@ in
LAYA_CPU_AMP = cfg.cpuAmp;
} // lib.optionalAttrs (cfg.mpsAmpMinRows != null) {
LAYA_MPS_AMP_MIN_ROWS = toString cfg.mpsAmpMinRows;
+ } // lib.optionalAttrs (cfg.maxLoaded != null) {
+ LAYA_MAX_LOADED = toString cfg.maxLoaded;
+ } // lib.optionalAttrs (cfg.maxTokenBudget != null) {
+ LAYA_MAX_TOKEN_BUDGET = toString cfg.maxTokenBudget;
+ } // lib.optionalAttrs (cfg.revision != null) {
+ LAYA_REVISION = cfg.revision;
} // {
HF_HOME = "/var/lib/${cfg.stateDirectory}/huggingface";
# torch-bin bundles its own CUDA runtime but still needs the host
diff --git a/tests/test_audit_scope.py b/tests/test_audit_scope.py
index 33f913f6..9913858e 100644
--- a/tests/test_audit_scope.py
+++ b/tests/test_audit_scope.py
@@ -80,14 +80,15 @@ if len(od) > 1:
check_true("pyproject/core parses", len(core) == 5, core)
check("pyproject/extra tables found", sorted(extras),
- ["fast", "langchain", "langgraph", "mcp", "onnx", "serve", "structured"])
+ ["crewai", "fast", "langchain", "langgraph", "llamaindex", "mcp", "onnx", "serve",
+ "structured"])
declared = list(core) + [s for names in extras.values() for s in names]
expected = sorted(set(declared))
check("pyproject/extras add names the core does not have",
sorted({re.split(r"[<>=!;\[ ]", s)[0] for s in declared}
- {re.split(r"[<>=!;\[ ]", s)[0] for s in core}),
- ["fastapi", "langchain-core", "langgraph", "mcp", "onnx", "onnxruntime", "pydantic",
- "python-multipart", "tilelang", "uvicorn"])
+ ["crewai", "fastapi", "langchain-core", "langgraph", "llama-index-core", "mcp", "onnx",
+ "onnxruntime", "onnxscript", "pydantic", "python-multipart", "tilelang", "uvicorn"])
# ---------------------------------------------------------------- the job's own extractor
deps_job = "\n".join(section(read(os.path.join(".github", "workflows", "security.yml")),
diff --git a/tests/test_packaging.py b/tests/test_packaging.py
index 09b63e38..4633f226 100644
--- a/tests/test_packaging.py
+++ b/tests/test_packaging.py
@@ -391,8 +391,10 @@ check_true("nix/module still joins models into LAYA_MODELS",
#
# Both regexes carry `[A-Z0-9_]` for the same reason: `LAYA_SHA256_DIGESTS`. `[A-Z_]+` matches a
# prefix of that name, so a narrower pattern reports no gap rather than the one it cannot see.
+# `_ENV_KEY = "LAYA_DEVICE"` is how laya/mcp/device.py names the one variable it reads, and since
+# #574 laya.serve reads the device through it, so the constant counts as a read.
_READ_PATTERNS = (r'environ\.get\("(LAYA_[A-Z0-9_]+)"', r'_env_bool\("(LAYA_[A-Z0-9_]+)"',
- r'environ\["(LAYA_[A-Z0-9_]+)"\]')
+ r'environ\["(LAYA_[A-Z0-9_]+)"\]', r'_ENV_KEY = "(LAYA_[A-Z0-9_]+)"')
def env_reads():
@@ -468,7 +470,8 @@ def option_type(opt):
# Every new knob is opt-in: unset means the unit exports nothing and the runtime's own default
# applies, so a host that ignores them gets today's behaviour byte for byte.
-for opt in ("logLevel", "maxConcurrent", "cudaAmp", "cpuAmp", "mpsAmpMinRows"):
+for opt in ("logLevel", "maxConcurrent", "cudaAmp", "cpuAmp", "mpsAmpMinRows",
+ "maxLoaded", "maxTokenBudget", "revision"):
_t = option_text(opt)
check_true("nix/module declares %s" % opt, _t != "", "option not found")
check_true("nix/%s is opt-in (nullOr, default null)" % opt,