mirror of
https://github.com/hanzoai/engine.git
synced 2026-11-21 02:36:58 +00:00
New hanzo-router-retrain crate + pipeline that refits the Enso routing heads from the ai routing ledger nightly, gates the candidate on an 80/20 holdout, and publishes only a non-regressing head per scope. - hanzo-router-retrain/: enso-fit binary on the `fit --events --out` contract (drop-in for enso's own fit via $FIT_BIN) + tested core: transform_reward (ai reward tuple -> enso EvalSample), fit_policy (proof.rs (x,p,quality) join -> fit_base), holdout_reward, decide_gate (fail-closed), save_w/load_w (enso-base safetensors: f64 tensor "w", [D*K]). 9 unit tests green. - scripts/router-retrain.sh: one scope (global -> heads-base.safetensors owner "*"; org=<slug> -> heads-<slug>.safetensors owner "<slug>"); pull -> fit -> gate -> promote-or-hold -> log.jsonl -> POST /v1/router/publish-artifact-meta. router-retrain-all.sh sequences global + per-opted-in-org. - deploy/router-retrain/: systemd user timer (04:20 America/Los_Angeles, Persistent) = the live spark scheduler; hanzoai/tasks cron ConfigMap as the in-cluster convergence reference; install.sh; LLM.md with the blocker list. Gate is holdout (RouterBench absent in-repo). DO_RELOAD=0 by default: publish writes the versioned artifact + current pointer but does not restart the engine until it mounts heads (unwired). Rebased onto origin/main; the crate builds against the committed enso primitives (fit_base/ingest/parse_jsonl) and writes the load_learner-compatible safetensors itself. Co-authored-by: Hanzo Dev <[email protected]>
34 lines
1.4 KiB
Bash
34 lines
1.4 KiB
Bash
#!/usr/bin/env bash
|
|
# Install the spark-local nightly retrain as a systemd USER timer. Idempotent.
|
|
set -euo pipefail
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
|
UNIT_DIR="$HOME/.config/systemd/user"
|
|
ENV_DIR="$HOME/.config/router-retrain"
|
|
|
|
export PATH="$HOME/.cargo/bin:$PATH"
|
|
cargo build --release -p hanzo-router-retrain --manifest-path "$ROOT/Cargo.toml"
|
|
|
|
# Linger keeps the user manager (and Persistent= catch-up) running without a login.
|
|
loginctl enable-linger "$USER" || true
|
|
|
|
mkdir -p "$UNIT_DIR" "$ENV_DIR"
|
|
install -m 0644 "$SCRIPT_DIR/router-retrain.service" "$UNIT_DIR/router-retrain.service"
|
|
install -m 0644 "$SCRIPT_DIR/router-retrain.timer" "$UNIT_DIR/router-retrain.timer"
|
|
if [[ ! -f "$ENV_DIR/env" ]]; then
|
|
cat > "$ENV_DIR/env" <<'EOF'
|
|
# router-retrain environment (chmod 600). Fill ROUTER_ADMIN_TOKEN from KMS:
|
|
# ROUTER_ADMIN_TOKEN=$(hanzo kms get hanzo/prod/router-admin-token) # super-admin (IAM admin org)
|
|
ROUTER_ADMIN_TOKEN=
|
|
# Opted-in orgs for the per-org fits (object.ListTrainingContributorOrgs), comma-separated.
|
|
CONTRIB_ORGS=
|
|
# Flip to 1 only after the engine mounts heads-{scope}.safetensors + CI RBAC allows the restart.
|
|
DO_RELOAD=0
|
|
EOF
|
|
chmod 600 "$ENV_DIR/env"
|
|
fi
|
|
|
|
systemctl --user daemon-reload
|
|
systemctl --user enable --now router-retrain.timer
|
|
echo "installed. next run:"; systemctl --user list-timers router-retrain.timer --no-pager || true
|