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.

docs(evals): retire a comment describing thresholds the module deleted

Aashish64034e7e10b8
diff --git a/laya/evidence.py b/laya/evidence.py
index 811a5853..375a748f 100644
--- a/laya/evidence.py
+++ b/laya/evidence.py
@@ -24,11 +24,7 @@ INSUFFICIENT = "INSUFFICIENT"
UNKNOWN = "UNKNOWN"
INCOMPARABLE = "INCOMPARABLE"
-# Documented upstream floors/thresholds. `laya.calibrate.MIN_TYPE_N` and
-# `laya.train.CALIB_WARN_N` live in modules that import torch at module scope, so a
-# read-only command cannot import them without pulling torch in. We prefer the live
-# constants when torch is importable and fall back to the documented values with an
-# explicit provenance note when it is not; we never silently duplicate.
+
def _entry(state: str, reason: str, detail: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
out = {"state": state, "reason": reason}
if detail:
@@ -55,7 +51,10 @@ def inspect_calibration(config: Dict[str, Any]) -> Dict[str, Any]:
continue
# Persisted issues are the authoritative limitation text (#933 writes
# not-fitted/below-floor/clamped/unchanged-fit there); we do not keep a
- # second numeric source of truth.
+ # second numeric source of truth. `laya/calibrate.py::MIN_TYPE_N` and
+ # `laya/train.py::CALIB_WARN_N` could not be imported here even if a recomputed
+ # floor were wanted: both modules import torch at module scope, and this read-only
+ # path has to run without it.
issues = entry.get("issues")
if not isinstance(issues, list):
types[name] = _entry(UNKNOWN, "calibration entry has no issues list; cannot tell limitations")
diff --git a/tests/test_evidence.py b/tests/test_evidence.py
index 11e1458a..da9b6fbf 100644
--- a/tests/test_evidence.py
+++ b/tests/test_evidence.py
@@ -2,6 +2,7 @@
Run: python tests/test_evidence.py
"""
+import inspect
import json
import os
import sys
@@ -41,11 +42,11 @@ check("zero items -> MISSING", zero["types"]["choice"]["state"], evidence.MISSIN
low = calib({"training": {"laya_train_calibration": {"choice": {"items": 5, "temperature": 1.0,
"issues": ["not fitted: 5 calibration items, fewer than 10, so the temperature stays 1.0"]}}}})
-check("below MIN_TYPE_N -> INSUFFICIENT", low["types"]["choice"]["state"], evidence.INSUFFICIENT)
+check("upstream below-MIN_TYPE_N limitation -> INSUFFICIENT", low["types"]["choice"]["state"], evidence.INSUFFICIENT)
warned = calib({"training": {"laya_train_calibration": {"choice": {"items": 30, "temperature": 1.2,
"issues": ["fitted on only 30 calibration items"]}}}})
-check("fitted below CALIB_WARN_N -> INSUFFICIENT", warned["types"]["choice"]["state"], evidence.INSUFFICIENT)
+check("upstream below-CALIB_WARN_N limitation -> INSUFFICIENT", warned["types"]["choice"]["state"], evidence.INSUFFICIENT)
clamped = calib({"training": {"laya_train_calibration": {"choice": {"items": 200, "temperature": 0.5,
"issues": ["the fitted temperature 0.5 is on the [0.5, 3] clamp"]}}}})
@@ -63,6 +64,35 @@ check("mixed types overall -> INSUFFICIENT", mixed["state"], evidence.INSUFFICIE
malformed = calib({"training": {"laya_train_calibration": {"choice": {"temperature": 1.0}}}})
check("malformed entry -> UNKNOWN", malformed["types"]["choice"]["state"], evidence.UNKNOWN)
+# ------------------------------------------------------ one numeric source of truth
+# `items` is reported here, never judged: #964 deleted the local `_thresholds()` that compared it
+# against copies of `MIN_TYPE_N`/`CALIB_WARN_N`, and the comment describing that mechanism stayed
+# behind. These are the checks the deleted mechanism never had -- a re-introduced floor has to
+# survive all of them, on both sides of both upstream floors.
+for _n in (1, 5, 9, 10, 49, 50, 300, 5000):
+ _t = calib({"training": {"laya_train_calibration": {
+ "choice": {"items": _n, "temperature": 1.1, "issues": []}}}})
+ check("items=%d with no recorded issue -> PRESENT" % _n, _t["types"]["choice"]["state"], evidence.PRESENT)
+
+# The same counts with a limitation recorded, and the state flips -- so the loop above shows that
+# `issues` decides, not that a large `items` does.
+_states = {calib({"training": {"laya_train_calibration": {
+ "choice": {"items": _n, "temperature": 1.1,
+ "issues": ["fitted on only %d calibration items" % _n]}}}})["types"]["choice"]["state"]
+ for _n in (5, 9, 10, 49, 50, 300)}
+check("the limitation text alone decides, at every count", _states, {evidence.INSUFFICIENT})
+
+# The deleted mechanism also exported where its numbers came from. Nothing in this module's result
+# may claim a threshold provenance, because there is no threshold to have a provenance about.
+check("no threshold provenance in the result",
+ "threshold_source" in calib({"training": {"laya_train_calibration": {
+ "choice": {"items": 400, "temperature": 1.1, "issues": []}}}}), False)
+
+_src = inspect.getsource(evidence)
+check_true("the module comments name the artifact as the authority", "second numeric source of truth" in _src)
+check_true("no comment still promises the deleted fallback",
+ "_FALLBACK" not in _src and "fall back to the documented values" not in _src)
+
# ------------------------------------------------------ report identity
full_report = {"config": {"schema": "laya-evals-report/1", "dataset_sha256": "a",
"questions_sha256": "b", "laya_version": "0.3.28"}, "overall": {}}