Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/census-watch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ jobs:
echo " !! UNCOVERED SimulatedForTestingClass (new class): 1 model(s), e.g. example/simulated" >> /tmp/census-watch.log
rc=1
fi
lines=$(grep -E "UNCOVERED|UNVERIFIABLE" /tmp/census-watch.log | tr -d '`@' | head -n 40 | base64 -w0)
lines=$(grep -E "UNCOVERED|UNVERIFIABLE|REMOTE-CODE" /tmp/census-watch.log | tr -d '`@' | head -n 40 | base64 -w0)
echo "lines=$lines" >> "$GITHUB_OUTPUT"
if [ $rc -ne 0 ]; then echo "alert=true" >> "$GITHUB_OUTPUT"; fi
exit $rc
Expand Down
18 changes: 13 additions & 5 deletions docs/registry.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,19 @@ per-model fetch and no compiled probe: the registry is generated data, keyed by
architecture class the census counts.

Exit 0 means every newest model is mapped; **exit 1 is the alert** — a class arrived that
no backend accepts. It is run daily at 04:30 UTC (ahead of the 05:17 sweep) by the systemd
timer on the development box (`scripts/1bit-census-watch.{service,timer}`, from the
`~/census-main` worktree that tracks `origin/main`). The timer marks its unit failed, and
every run lands in `~/.1bit/logs/census-watch-*.log`. A GitHub Actions path that files an
alert issue needs `issues: write`, so it waits for an RFC.
no backend accepts. One kind of unmapped class is reported without the alert: a class whose
models all load through custom modeling code (`auto_map` in the config, so Transformers has
no implementation of it either) and that fewer than 3 uploaders publish. Research one-offs
like that arrive every day. It alerts once 3 uploaders use it, and a reviewed class
(`registry/significant.json`) always alerts.

The watch runs daily at 04:30 UTC (ahead of the 05:17 sweep) in two places:
- GitHub Actions (`.github/workflows/census-watch.yml`, [RFC #246](https://github.com/1bit-MONSTER/engine/discussions/246)), which files one deduped
`census-watch` issue. Only its alert job holds `issues: write`, and that job runs no
repository code.
- the systemd timer on the development box (`scripts/1bit-census-watch.{service,timer}`, from
the `~/census-main` worktree that tracks `origin/main`), which marks its unit failed and
logs every run to `~/.1bit/logs/census-watch-*.log`.

A class the watcher flags is one of two things, and the run says which:

Expand Down
19 changes: 18 additions & 1 deletion tests/census_watch_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,14 @@ def check(name, cond):
failures.append(name)


def model(mid, arch=None, tags=(), library=None):
def model(mid, arch=None, tags=(), library=None, remote=False):
m = {"id": mid, "tags": list(tags)}
if library:
m["library_name"] = library
if arch:
m["config"] = {"architectures": [arch]}
if remote:
m["config"]["auto_map"] = {"AutoModelForCausalLM": "modeling_x.XForCausalLM"}
return m


Expand Down Expand Up @@ -95,6 +97,21 @@ def text_of(models, archs=ARCHS, sig=SIG, seen=()):
check("significant class -> uncovered, exit 1", rc == 1)
check("significant class is labeled", res["significant"] == ["Qwen3_5MVLAAbsorbedForCausalLM"])

# 4b. A custom-code class (auto_map) from fewer than REMOTE_CODE_SPREAD uploaders is reported,
# not an alert: research one-offs arrive daily and no backend could map them.
rc, text = text_of([model("lab/hyper-a", "HyperLlamaForCausalLM", remote=True),
model("lab/hyper-b", "HyperLlamaForCausalLM", remote=True)])
check("remote-code class, one uploader -> exit 0", rc == 0)
check("remote-code class is still reported", "REMOTE-CODE HyperLlamaForCausalLM" in text)
rc, res = rc_of([model(f"u{i}/sol", "Sol2ForCausalLM", remote=True) for i in range(cw.REMOTE_CODE_SPREAD)])
check("remote-code class from REMOTE_CODE_SPREAD uploaders -> exit 1", rc == 1 and res["remote_code"] == [])
rc, res = rc_of([model("v/one", "MixForCausalLM", remote=True), model("v/two", "MixForCausalLM")])
check("a class with one native (no auto_map) model alerts", rc == 1)
rc, res = rc_of([model("w/one", "Qwen3_5MVLAAbsorbedForCausalLM", remote=True)])
check("a reviewed class alerts even with custom code", rc == 1)
rc, res = rc_of([model("x/one", "OneOffForCausalLM", remote=True), model("x/two", "NimbusMindForCausalLM")])
check("a remote-code one-off does not hide a native arrival", rc == 1 and res["remote_code"] == ["OneOffForCausalLM"])

# 5. A derivative with no config is expected, not an alert.
rc, res = rc_of([model("e/five", tags=["gguf", "text-generation"])])
check("derivative -> no alert, not unverifiable",
Expand Down
31 changes: 28 additions & 3 deletions tools/census_watch.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,14 @@
usage: tools/census_watch.py [--limit N] [--state PATH]

Exit codes (the alert contract):
0 no uncovered classes among the newest models
0 no uncovered class among the newest models that warrants an alert
1 an uncovered class arrived (the alert)

A class whose models all load through custom modeling code (`auto_map` in the config, so
Transformers itself has no implementation either) and that fewer than REMOTE_CODE_SPREAD
uploaders publish is reported but does not alert: research one-offs like that arrive every
day and are not something a backend could map. Once REMOTE_CODE_SPREAD uploaders use it, or
it is a reviewed class (registry/significant.json), it alerts like any other.
* runtime failure (no network, unreadable registry, ...)

State (the model ids already classified) lives outside the checkout, at
Expand All @@ -59,6 +65,7 @@
DEFAULT_LIMIT = 120
DEFAULT_STATE = os.path.join(os.path.expanduser("~"), ".1bit", "census-watch-state.json")
MAX_SEEN = 5000 # cap state growth; oldest dropped
REMOTE_CODE_SPREAD = 3 # uploaders before a custom-code class alerts
_NEXT = re.compile(r'<([^>]+)>;\s*rel="next"')

# A derivative carries no config.json of its own by design (a quantized GGUF, a LoRA
Expand Down Expand Up @@ -103,6 +110,12 @@ def architectures_of(model):
return archs[0] if archs and isinstance(archs[0], str) else ""


def is_remote_code(model):
"""True when the config loads the model through custom code (`auto_map`)."""
cfg = model.get("config") or {}
return bool(cfg.get("auto_map"))


def is_derivative(model):
tags = model.get("tags") or []
return (model.get("library_name") == "peft"
Expand All @@ -122,6 +135,7 @@ def classify(models, archs, sig, previously_seen=()):
out = {COVERED: [], UNCOVERED: [], UNVERIFIABLE: [], DERIVATIVE: []}
reasons = {} # model id -> why it could not be classified
classes = {} # uncovered class -> [model ids]
native = set() # uncovered classes with at least one model that needs no custom code
for m in models:
mid = m.get("id", "")
arch = architectures_of(m)
Expand All @@ -139,9 +153,15 @@ def classify(models, archs, sig, previously_seen=()):
continue
out[UNCOVERED].append(mid)
classes.setdefault(arch, []).append(mid)
if not is_remote_code(m):
native.add(arch)
out["classes"] = classes
out["reasons"] = reasons
out["significant"] = sorted(c for c in classes if c in sig)
# custom-code classes from fewer than REMOTE_CODE_SPREAD uploaders: reported, no alert
out["remote_code"] = sorted(
c for c, ids in classes.items()
if c not in sig and c not in native and len({i.split("/")[0] for i in ids}) < REMOTE_CODE_SPREAD)
return out


Expand Down Expand Up @@ -214,8 +234,13 @@ def report(models, res, previously_seen):
if not models:
print(f"census-watch: nothing new since the last run "
f"({len(previously_seen)} models already classified)")
quiet = set(res.get("remote_code", ()))
for cls, ids in sorted(res["classes"].items(), key=lambda kv: (-len(kv[1]), kv[0])):
if cls in res["significant"]:
if cls in quiet:
owners = len({i.split("/")[0] for i in ids})
print(f" . REMOTE-CODE {cls}: {len(ids)} model(s) from {owners} uploader(s), e.g. {ids[0]}")
print(f" -> custom modeling code (auto_map); alerts once {REMOTE_CODE_SPREAD} uploaders use it")
elif cls in res["significant"]:
print(f" !! UNCOVERED {cls} (reviewed, not an alias — docs/arch-gaps.md): "
f"{len(ids)} model(s), e.g. {ids[0]}")
print(f" -> needs real engine support, not a mapping; if a backend starts "
Expand All @@ -227,7 +252,7 @@ def report(models, res, previously_seen):
for mid in sorted(res[UNVERIFIABLE]):
print(f" ? UNVERIFIABLE {mid} ({res['reasons'][mid]}) — gated repos need a token; "
f"retried next run")
return 1 if res["classes"] else 0
return 1 if any(c not in quiet for c in res["classes"]) else 0


def main():
Expand Down
Loading