:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(signals): run the nn training schedule by default on US cloud (#117677)
posthog[bot]9fdd58eb2a8f
diff --git a/products/signals/dags/inbox_ranking/AGENTS.md b/products/signals/dags/inbox_ranking/AGENTS.mdindex 913a35cbf030..fc00b06d4caa 100644--- a/products/signals/dags/inbox_ranking/AGENTS.md+++ b/products/signals/dags/inbox_ranking/AGENTS.md@@ -35,7 +35,7 @@ Read `README.md` first for what the dataset is and how partitions behave. This f- The manifest schema and the object keys live in `products/signals/backend/ranking/serving_manifest.py`, next to the feature contract, because the dag writes them and the sweep reads them. Its validators run at write time, so the dag refuses a manifest the sweep could not act on; the entry cap is the `ranking_score` artefact's, so a manifest can never produce a row the artefact refuses.- Publishing order is load-bearing. Every model copy finishes before `manifest.json` is written, so a failed copy leaves the previous manifest and the previous models serving. A model version is immutable, so a version whose `metadata.json` is already at the target is not copied again. A run with nothing to publish, and no champion for the served family is the case today, writes nothing rather than an empty manifest.- When a manifest entry has `reads_project_vectors`, the dt=D `inbox_project_vectors` day is copied to `serving/project_vectors/<D>/` before `manifest.json`, and the manifest names it in `project_vectors`. A missing day fails the publish, like a missing model file. Never copy project vectors to the mirror: they are per-team data of this deployment, so the mirror's manifest names none. Training and serving build the `project` and `has_history` inputs through the one `project_inputs` in `features.py`; keep `PROJECT_VECTOR_KINDS` and `MIN_PROJECT_HISTORY_REPORTS` there.-- `nn` is trained by the `signals_ml` location (`nn/dag.py`), never by the main one. torch is imported only inside the candidate asset's body (through `nn/train.py` and `multihead/network.py`). `signals_ml` must import without torch, and `test_multihead_network.py` pins that. Its champion goes through `decide_family_champion`, the same rule and gate as the boosters, graded through the incumbent's `model.holdout.onnx`. Keep `signals_ml` commented out in `.dagster_home/workspace.yaml`, and keep its schedule (04:30 UTC) stopped by default.+- `nn` is trained by the `signals_ml` location (`nn/dag.py`), never by the main one. torch is imported only inside the candidate asset's body (through `nn/train.py` and `multihead/network.py`). `signals_ml` must import without torch, and `test_multihead_network.py` pins that. Its champion goes through `decide_family_champion`, the same rule and gate as the boosters, graded through the incumbent's `model.holdout.onnx`. Keep `signals_ml` commented out in `.dagster_home/workspace.yaml`, and keep its schedule (04:30 UTC) running by default on prod US only.## Invariants — do not breakdiff --git a/products/signals/dags/inbox_ranking/README.md b/products/signals/dags/inbox_ranking/README.mdindex 1fdf88f05b88..ad41003397b7 100644--- a/products/signals/dags/inbox_ranking/README.md+++ b/products/signals/dags/inbox_ranking/README.md@@ -376,7 +376,7 @@ s3://<bucket>/<prefix>/- **Candidate**: the network trains on the rows in no head's holdout and is graded on each head's own holdout through the same `head_metrics` the boosters use, so `metadata.json` carries the same per-head fields (pooled and within-team AUC, average precision, ECE, readability, row counts, example window). Readability uses the boosters' permutation null: three networks fit on permuted labels. `model.onnx` is a refit on every labeled row, and `model.holdout.onnx` is the train-only fit. `metadata.json` has `model_kind: onnx`, `feature_set: report_embeddings`, and `output_heads`, the graph's column order.- **Champion**: the same rule, overrides and `INBOX_RANKING_AUTO_PROMOTE` gate as the other families (`decide_family_champion`). The incumbent is graded through its `model.holdout.onnx` on the candidate's holdout, with `onnxruntime`.- **A missing partition is a skip.** If the dt=D state, labels or embeddings snapshot is missing, each asset logs and writes nothing, so the partition keeps the objects it holds.-- **Schedule**: 04:30 UTC, after the dataset job's 2h budget (02:30 UTC start) and before the 05:00 UTC training job when the run is short enough. A champion that lands after that day's manifest is published by the next day's manifest. The schedule is stopped by default in every environment.+- **Schedule**: 04:30 UTC, after the dataset job's 2h budget (02:30 UTC start) and before the 05:00 UTC training job when the run is short enough. A champion that lands after that day's manifest is published by the next day's manifest. The schedule runs by default on prod US and is stopped everywhere else.To run it locally, install the group (`uv sync --group inbox-ranking`), sync the snapshots with `INBOX_RANKING_SYNC_EMBEDDINGS=1` as in [Running the training job locally](#running-the-training-job-locally), and uncomment `posthog.dags.locations.signals_ml` in `.dagster_home/workspace.yaml`. The entry is commented out because most developers do not have torch installed. Then launch the job:diff --git a/products/signals/dags/inbox_ranking/nn/dag.py b/products/signals/dags/inbox_ranking/nn/dag.pyindex 376c7460d057..904b2ef76cac 100644--- a/products/signals/dags/inbox_ranking/nn/dag.py+++ b/products/signals/dags/inbox_ranking/nn/dag.py@@ -340,13 +340,14 @@ inbox_ranking_nn_training_job = dagster.define_asset_job(# After the dataset job's 2h budget (02:30 UTC start), so the dt=D-1 snapshots exist, and before the# main training job (05:00 UTC) where the run is short enough. A champion that lands after that-# job's manifest is published by the next day's manifest. Stopped everywhere until the location is-# deployed on the image with torch.+# job's manifest is published by the next day's manifest.@dagster.schedule(cron_schedule="30 4 * * *",job=inbox_ranking_nn_training_job,execution_timezone="UTC",- default_status=dagster.DefaultScheduleStatus.STOPPED,+ default_status=dagster.DefaultScheduleStatus.RUNNING+ if settings.CLOUD_DEPLOYMENT == "US"+ else dagster.DefaultScheduleStatus.STOPPED,tags=owner_tags,)def inbox_ranking_nn_training_schedule(