Skip to content

WIP: R2 — schedule inference for historic replay / off-policy (draft, do not merge)#2607

Draft
jucor wants to merge 13 commits into
edgefrom
jc/r2-schedule-inference
Draft

WIP: R2 — schedule inference for historic replay / off-policy (draft, do not merge)#2607
jucor wants to merge 13 commits into
edgefrom
jc/r2-schedule-inference

Conversation

@jucor

@jucor jucor commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

WIP / DRAFT — not for merge. Pushed to protect and make visible the R2
schedule-inference research chain (previously living only in the local
r2-inference jj workspace, unbacked-up).

What this is

R2 = replaying historic conversations for off-policy learning when the real
recompute schedule that actually took place is unknown and must be inferred
(unlike R1, which uses synthetic schedules we define). See
delphi/docs/REPLAY_HARNESS_DESIGN.md §1.3 / §10 for the framing.

Contents (bottom → top)

  • docs(delphi): replay — R2 schedule-inference implementation plan
  • Core types (VoteEvent, ReplayDataset, Schedule)
  • Prefix stats + era A/B priority weights (the pre-2025 constant-priority
    era vs later eras)
  • PL mark likelihood with incremental availability
  • Synthetic generator with poller physics + ground truth
  • L0 physics (forced cuts, candidate lattice)
  • L1 exact changepoint DP (fwd/bwd, MAP, sampling) vs brute-force oracle
  • L1a pipeline (renewal prior, emission delay); e2e recovery green
  • L2 self-normalized importance-sampling correction (delta + endpoint potential)
  • Real-data loader, vw semi-synthetic (time-localized), smoke + perf guard
  • Cadence experiment suite (fixed/poisson/time/bursty generators, soundness
    checks, metrics, CLI) + committed 60-run grid results

Code lives under delphi/polismath/replay/.

Status

Prototype/research — algorithms validated on synthetic + semi-synthetic data,
not yet wired to the Clojure-legacy Python engine (powerit-pca / sequential-bits
port). Kept as a draft PR for backup + visibility, rebased onto current edge.

jucor added 13 commits July 10, 2026 12:39
…2e recovery green

Iteration findings (probed on synthetic ground truth):
- emission delay: votes during a recompute are served under the PREVIOUS
  weights; at 30s compute this is a whole segment — modeled as the delta-shift
  from the R2 design (emission changepoint = state changepoint + delay)
- soft renewal idle prior: an up worker with pending votes recomputes at the
  first free poll; exponential penalty on unexplained idleness (soft = robust
  to unknown stalls; hard bound would be unsound)
- count-constrained inference uses the dense lattice (thinning + spacing +
  exact count creates spurious infeasibility -> InfeasibleScheduleError)
- honest metrics: posterior localization (median 1 vote, p90 2) and
  coverage@3 (>=0.92) both eras; MAP is a fragile summary in emission-flat
  stretches (single insertion cascades in sorted pairing)
…lized), smoke, perf guard

vw finding: bursty real traffic (median inter-vote gap 0s) means localization
must be judged in TIME — the irreducible uncertainty is the compute-jitter
window. Achieved 9.8s median / 21s p90 on the vw skeleton (physics-limited).
…bursty generators, soundness checks, metrics, CLI) + smoke tests
@jucor jucor force-pushed the jc/r2-schedule-inference branch from d340500 to 683d295 Compare July 10, 2026 11:40
@github-actions

Copy link
Copy Markdown

Delphi Coverage Report

File Stmts Miss Cover
init.py 2 0 100%
benchmarks/bench_pca.py 128 107 16%
benchmarks/bench_repness.py 81 65 20%
benchmarks/bench_update_votes.py 38 28 26%
benchmarks/benchmark_utils.py 34 24 29%
components/init.py 1 0 100%
components/config.py 165 133 19%
conversation/init.py 2 0 100%
conversation/conversation.py 1108 259 77%
conversation/manager.py 131 42 68%
database/init.py 1 0 100%
database/dynamodb.py 395 189 52%
database/postgres.py 306 206 33%
pca_kmeans_rep/init.py 5 0 100%
pca_kmeans_rep/clusters.py 257 21 92%
pca_kmeans_rep/corr.py 98 17 83%
pca_kmeans_rep/pca.py 135 18 87%
pca_kmeans_rep/repness.py 208 9 96%
regression/init.py 4 0 100%
regression/clojure_comparer.py 188 20 89%
regression/comparer.py 887 720 19%
regression/datasets.py 135 27 80%
regression/recorder.py 36 27 25%
regression/utils.py 138 94 32%
replay/init.py 2 0 100%
replay/correction.py 34 0 100%
replay/dp.py 255 10 96%
replay/emission.py 96 2 98%
replay/experiments/cadence.py 277 6 98%
replay/experiments/run_cadence.py 101 8 92%
replay/physics.py 38 1 97%
replay/real_data.py 19 2 89%
replay/scan.py 39 0 100%
replay/synthetic.py 151 2 99%
replay/types.py 65 0 100%
replay/weights.py 69 1 99%
run_math_pipeline.py 261 114 56%
umap_narrative/500_generate_embedding_umap_cluster.py 210 109 48%
umap_narrative/501_calculate_comment_extremity.py 112 53 53%
umap_narrative/502_calculate_priorities.py 135 135 0%
umap_narrative/700_datamapplot_for_layer.py 502 502 0%
umap_narrative/701_static_datamapplot_for_layer.py 310 310 0%
umap_narrative/702_consensus_divisive_datamapplot.py 432 432 0%
umap_narrative/801_narrative_report_batch.py 785 785 0%
umap_narrative/802_process_batch_results.py 268 268 0%
umap_narrative/803_check_batch_status.py 183 183 0%
umap_narrative/llm_factory_constructor/init.py 2 2 0%
umap_narrative/llm_factory_constructor/model_provider.py 192 192 0%
umap_narrative/polismath_commentgraph/init.py 1 0 100%
umap_narrative/polismath_commentgraph/cli.py 270 270 0%
umap_narrative/polismath_commentgraph/core/init.py 3 3 0%
umap_narrative/polismath_commentgraph/core/clustering.py 108 108 0%
umap_narrative/polismath_commentgraph/core/embedding.py 104 104 0%
umap_narrative/polismath_commentgraph/lambda_handler.py 219 219 0%
umap_narrative/polismath_commentgraph/schemas/init.py 2 0 100%
umap_narrative/polismath_commentgraph/schemas/dynamo_models.py 160 9 94%
umap_narrative/polismath_commentgraph/tests/conftest.py 17 17 0%
umap_narrative/polismath_commentgraph/tests/test_clustering.py 74 74 0%
umap_narrative/polismath_commentgraph/tests/test_embedding.py 55 55 0%
umap_narrative/polismath_commentgraph/tests/test_storage.py 87 87 0%
umap_narrative/polismath_commentgraph/utils/init.py 3 0 100%
umap_narrative/polismath_commentgraph/utils/converter.py 283 237 16%
umap_narrative/polismath_commentgraph/utils/group_data.py 354 336 5%
umap_narrative/polismath_commentgraph/utils/storage.py 584 518 11%
umap_narrative/reset_conversation.py 159 50 69%
umap_narrative/run_pipeline.py 453 312 31%
utils/general.py 62 41 34%
Total 12019 7563 37%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant