# Assembles the structured result for run_07e69074dc from measured logs (adapted from prior build_output.py). import json, hashlib, os, time, statistics rd = lambda f: [json.loads(l) for l in open(f)] P, S, C = rd("pilot_log.jsonl"), rd("select_log.jsonl"), rd("confirm_log.jsonl") F = json.load(open("final_numbers.json")); res = F["res"]; sel = json.load(open("selection_frozen.json")) RC = json.load(open("restore_check.json")); CP = json.load(open("correctness_preflight.json")) PR = json.load(open("preflight_results.json")); V = PR["v2"]; LE = json.load(open("loss_eval_record.json")) spec = json.load(open("spec.json")); T_START = 1793804760; T_DEPLOY = 1793805129 # session start 15:06 UTC; fork deploy start cleanup = json.load(open("cleanup.json")) if os.path.exists("cleanup.json") else None st = lambda L, s: [e for e in L if e["stage"] == s] steps = {} for e in st(C, "train_step"): steps.setdefault((e["arm"].split("_s")[-1], e["step"]), set()).add(e["batch_sha256"]) pair_match = sum(len(v) == 1 for v in steps.values()) / len(steps) pt = {e["params_type"] for e in st(C, "train_step") + st(S, "train_step")} types_ok = all(e["params_type"] == ("DimuonParams" if "dimuon" in e["arm"] else "AdamParams") for e in st(C, "train_step") + st(S, "train_step") + st(P, "train_step")) io = {e["arm"]: e for e in st(C, "initial_output") + st(S, "initial_output")} gi = {} for e in st(C, "get_info") + st(S, "get_info"): gi.setdefault(e["arm"], []).append(e) models = {g["model"] for v in gi.values() for g in v} s0 = {e["arm"]: e["path"] for e in st(C, "step0_saved")} carms = json.load(open("confirm_arms.json")) sarms = [{"arm": f"sel_{'adamw' if o == 'adam' else o}_lr{float(lr):g}_s0", "opt": o, "lr": float(lr)} for o in ("adam", "dimuon") for lr in sel[o]["scores"]] arms_prov = [] for a in sarms + carms: n = a["arm"]; ph = "confirm" if n in s0 else "select" r = {"arm": n, "phase": ph, "base_checkpoint": "Qwen/Qwen3.5-2B", "initialization_checkpoint": io[n]["init_path"], "source": "server_response", "before_first_update": True, "restore_count": io[n]["restores"], "optimizer_checks": [{"after_restore": g["restores"], "before_next_update": True, "optimizer": g["optimizer"], "model": g["model"], "rank": g["rank"]} for g in gi[n]], "initial_output_sha256": io[n]["output_sha256"], "evidence_ref": f"{ph}_log.jsonl"} if n in s0: k = f"confirm-{n}-step0" r.update(step0_checkpoint=s0[n], adapter_sha256=RC[k]["adapter_bf16_sha256"], fp32_param_sha256=RC[k]["fp32_param_sha256"], server_checkpoint_optimizer=RC[k]["metadata"]["optimizer"], evidence_ref="restore_check.json") else: r.update(adapter_sha256=None, adapter_note="selection arms all start from saved state select-init-s0; per-arm adapter not downloaded, initial output hash recorded") arms_prov.append(r) pairs_ok = all(io[f"baseline_adamw_s{s}"]["output_sha256"] == io[f"treatment_dimuon_s{s}"]["output_sha256"] and RC[f"confirm-baseline_adamw_s{s}-step0"]["adapter_bf16_sha256"] == RC[f"confirm-treatment_dimuon_s{s}-step0"]["adapter_bf16_sha256"] for s in (0, 1, 2)) ph = lambda L: (st(L, "setup_done")[0]["seconds"], st(L, "train_done")[0]["seconds"], st(L, "eval_done")[0]["seconds"]) pp, sp, cp = ph(P), ph(S), ph(C) now = cleanup["t"] if cleanup else time.time(); wall = now - T_START; gpu_h = (now - T_DEPLOY) / 3600 src = "fork_config.py trainer_gpus_per_node=1 (single trainer GPU; inference min replicas 0)" meas = lambda sec, u, pu, smp: {"seconds": sec, "units": u, "planned_units": pu, "samples": smp, "gpu_count": 1, "allocation_source": src} eff = {**spec["feasibility"]["effective_config"], "n_ifeval_secondary": 0, "pilot_arms": 2, "pilot_steps": 10, "note": "IFEval dropped (downsizing step 1); LR grid, selection steps, seeds, test NLL unchanged"} feas = {"config": spec["feasibility"]["effective_config"], "effective_config": eff, "primary_endpoint": "no_robots_test_token_mean_nll_at_step_100", "source": "pilot_log.jsonl (10-step 2-arm pilot, measured before the sweep); select_log.jsonl and confirm_log.jsonl measured", "measurements": {"setup_fork_deploy": meas(19.0, 1, 1, 1), "setup_pilot": meas(pp[0], 2, 2, 2), "training_pilot": meas(pp[1], 20, 20, 640), "heldout_eval_pilot": meas(pp[2], 1000, 1000, 1000), "setup_selection": meas(sp[0], 6, 6, 6), "training_selection": meas(sp[1], 240, 240, 7680), "heldout_eval_selection": meas(sp[2], 3000, 3000, 3000), "setup_confirmation": meas(cp[0], 6, 6, 6), "training_confirmation": meas(cp[1], 600, 600, 19200), "heldout_eval_confirmation": meas(cp[2], 3000, 3000, 3000)}, "generation": None, "recovery": {"seconds": max(0.0, 150 * 60 - wall), "gpu_count": 1, "allocation_source": src}} metrics = {"arms": F["arms"]} complete = "mean" in res if complete: metrics.update(primary_mean_adamw_minus_dimuon=res["mean"], primary_ci95_low=res["lo"], primary_ci95_high=res["hi"], primary_sd=res["sd"], margin=0.02) for i, d in enumerate(res["diffs_adamw_minus_dimuon"]): metrics[f"diff_adamw_minus_dimuon_s{i}"] = d metrics.update(selected_lr_adamw=sel["adam"]["selected_lr"], selected_lr_dimuon=sel["dimuon"]["selected_lr"], paired_batch_hash_match_confirmation=pair_match, wall_minutes=wall / 60, trainer_gpu_hours=gpu_h) files = [] def add(name, kind, path=None): b = open(path or name, "rb").read(); files.append({"name": name, "kind": kind, "content": b.decode(), "sha256": hashlib.sha256(b).hexdigest()}) for n in ("run.py", "common.py", "fork_config.py", "probe_shared.py", "smoke.py", "preflight.py", "analyze_preflight.py", "analyze2.py", "local_parity.py", "loadlib.py", "build_preflight.py", "launch_confirm.py", "restore_check.py", "final_analysis.py", "loss_eval.py", "loss_report.py", "build_result.py", "dimuon_candidate.py"): add(n, "script") add("launch-instructions.md", "instructions", "../launch-instructions.md") json.dump(eff, open("effective-config.json", "w"), indent=1); add("effective-config.json", "effective_config") open("code-revision.txt", "w").write("fork app: spindle-fork-run_07e69074dc (env research-exchange-runs)\nmodal-projects/spindle 5148cb62a019862ef9b50d76b7be55cddb288e8a (branch claude/dimuon-spindle-wiring, PR #85) + spindle_fork.patch\nmodal-projects/miles 228b59d90074e6cec48090e033202c5a4aff3ff3 (branch dimuon-lite, PR #17), mounted via SPINDLE_MILES_TREE\nshared Spindle (not used for arms): rejects DimuonOptimizerConfig (HTTP 400 'optimizer family dimuon is not supported')\nAaron reference: dimuon_candidate.py sha256 " + hashlib.sha256(open("dimuon_candidate.py", "rb").read()).hexdigest() + "\n") add("code-revision.txt", "code_revision"); add("spindle_fork.patch", "code_patch", "../../prior_739/spindle_fork.patch") add("predictions-confirm-test.jsonl", "predictions"); add("scored-observations-final.jsonl", "metrics") for n in ("select_log.jsonl", "confirm_log.jsonl", "pilot_log.jsonl", "preflight_log.json", "probe_shared_log.json", "correctness_preflight.json", "preflight_results.json", "local_parity.json", "restore_check.json", "selection_frozen.json", "final_numbers.json", "loss_eval_record.json", "spec.json"): add(n, "metrics") if cleanup: add("cleanup.json", "metrics") ck = [{"arm": e["arm"], "step": e["step"], "uri": e["final_state"]} for e in st(C, "eval") + st(S, "eval")] edge = bool(sel["adam"]["edge"] or sel["dimuon"]["edge"]) sr, drop = PR["dimuon_B_stable_rank_step1"], st(P, "train_step") dd = [e for e in drop if "dimuon" in e["arm"]]; drop = dd[0]["train_token_mean_nll"] - dd[-1]["train_token_mean_nll"] gate_ok = models == {"Qwen/Qwen3.5-2B"} and types_ok and 0.6 <= sr <= 1.05 and pair_match == 1.0 and drop > 0 out = {"status": "succeeded" if complete else "failed", "metrics": metrics, "completed_arms": [e["arm"] for e in st(S, "eval") + st(C, "eval")], "original_hypothesis_tested": True, "deviations": [ {"field": "endpoint", "original": "shared Spindle TINKER_BASE_URL", "effective": "throwaway fork spindle-fork-run_07e69074dc (env research-exchange-runs), Spindle 5148cb62 + spindle_fork.patch, Miles 228b59d", "reason": "Shared Spindle rejects DimuonOptimizerConfig with HTTP 400 'optimizer family dimuon is not supported'; instructions permit a throwaway fork. Both arms ran on the fork."}, {"field": "evaluator", "original": "primary held-out NLL + secondary IFEval strict accuracy (541 prompts, greedy, 1024 tokens; descriptive only)", "effective": "IFEval dropped; primary 500-item no_robots test token-mean NLL unchanged", "reason": "Spec downsizing order step 1, decided after the feasibility pilot and before the sweep, to keep the 2.0 GPU-hour / 150-minute budget with recovery reserve."}], "correctness_preflight": {**CP, "paths": [{**CP["paths"][0], "reference_update_note": ( "errors.reference_update compares the deployed Miles Dimuon code against Aaron's reference on bitwise-identical fp32 inputs (passes). " f"Server-executed update vs reference (measured this run): with bf16-persisted momentum as input max_abs {V['reference_update_own_bf16_momentum']['max_abs_error']:.3g}, cosine {V['reference_update_own_bf16_momentum']['cosine_similarity']:.6f}, {V['reference_update_own_bf16_momentum']['n_fail']} of {V['reference_update_own_bf16_momentum']['n_elements']} elements outside atol 1e-5/rtol 1e-2; " f"with another client's fp32 gradient max_abs {V['reference_update_other_client_fp32_grad']['max_abs_error']:.3g}, {V['reference_update_other_client_fp32_grad']['n_fail']} elements outside. " f"Create-save-restore replay vs uninterrupted step 2: rel L2 {V['restore_replay_update']['relative_l2_error']:.4f}, cosine {V['restore_replay_update']['cosine_similarity']:.6f}, {V['restore_replay_update']['n_fail']} elements outside atol 1e-5/rtol 1e-2 (attributed, not proven, to bf16 optimizer-state persistence; no arm restores optimizer state mid-training)."), "restore_replay_update_vs_uninterrupted": V["restore_replay_update"], "restore_replay_momentum": V["restore_replay_momentum"]}]}, "activation_calibration": {"note": "Measured on the fork before full training: stable rank = ||dB||_F^2/(||dB||_2^2 r) of the preflight step-1 Dimuon LoRA-B update (lr 1e-3, seed-0 batch 1, downloaded checkpoints, mean over 97 B blocks; AdamW same fixture 0.148); NLL drop = 10-step Dimuon lr 1e-3 pilot train token-mean NLL at step 1 (pre-update) minus step 10; batch hash match over all 100 confirmation steps per seed pair; step types logged client-side.", "values": {"executed_base_model": ",".join(sorted(models)), "executed_optimizer_step_types": ",".join(sorted(pt)), "dimuon_B_update_normalized_stable_rank_step1": sr, "adamw_B_update_normalized_stable_rank_step1": PR["adamw_B_stable_rank_step1"], "batch_hash_match_across_arms": pair_match, "pilot_train_nll_drop_dimuon_10steps": drop, "activation_gate_passed": "true" if gate_ok else "false"}}, "initialization_provenance": {"version": 1, "arms": arms_prov, "paired_init_matched_all_seeds": pairs_ok}, "feasibility": feas, "loss_eval": LE, "evaluation": {"version": 1, "evaluators": {F["eid"]: F["prov"]}, "scores": F["scores"], "comparisons": [{"metric": "no_robots_test_token_mean_nll_at_step_100", "arms": ["baseline", "treatment"]}]}, "decision": {"version": 1, "observations_file": {"name": "scored-observations-final.jsonl", "sha256": F["obs_sha"]}, "selection": {"frozen_before_confirmation": True, "selection_split": "500 held-out no_robots train rows (Random(1234) shuffle, first 500), disjoint from training and test rows", "selection_steps": 40, "adamw": sel["adam"], "dimuon": sel["dimuon"], "grid_edge_selected": edge}}, "evidence": {"version": 1, "files": files, "checkpoints": ck, "per_arm_metrics": F["arms"]}} if complete and gate_ok and pairs_ok: verdict = "supported" if res["lo"] > 0.02 else "refuted" where = "entirely below" if res["hi"] < 0.02 else "entirely above" if res["lo"] > 0.02 else "across" out.update(verdict=verdict, outcome_reason=verdict, confidence="weak", effect=res["mean"], margin=0.02, ci=[res["lo"], res["hi"]], seeds=3, grid_edge=edge, summary=(f"On fork spindle-fork-run_07e69074dc, 100-step rank-32 LoRA SFT of Qwen3.5-2B on no_robots gave AdamW-minus-Dimuon test token-mean NLL {res['mean']:+.5f} nats " f"(per-seed {', '.join(f'{d:+.5f}' for d in res['diffs_adamw_minus_dimuon'])}; 95% paired-t CI [{res['lo']:+.5f}, {res['hi']:+.5f}], 3 seeds) at frozen LRs AdamW {sel['adam']['selected_lr']:g} / Dimuon {sel['dimuon']['selected_lr']:g}. " f"The CI lies {where} the 0.02-nat margin, so the hypothesis is {verdict}; confidence weak because both selected LRs sit at the upper grid edge. IFEval secondary dropped for budget."), reasoning=(f"Measured: Dimuon beat AdamW by {res['mean']:.5f} nats on 500 test items in all 3 seeds, but the 95% paired-t interval [{res['lo']:.5f}, {res['hi']:.5f}] is entirely below the 0.02-nat success margin, so the prespecified criterion is not met (refuted). " "Inferred limits: both frozen LRs (AdamW 2e-4, Dimuon 3e-3) are at the top of their grids, so a larger LR could change the gap; the restore-replay optimizer-state check showed ~1% relative differences from bf16 state persistence (not exercised by this design).")) else: out.update(outcome_reason="incomplete_execution", status="failed", summary="Comparison not completed or a required gate failed; no verdict.") if cleanup: out["cleanup_record"] = cleanup json.dump(out, open("final_output.json", "w"), allow_nan=False) print(out.get("verdict"), gate_ok, pairs_ok, pair_match, models, sr, drop, round(wall / 60, 1), round(gpu_h, 2), sum(len(f["content"]) for f in files) / 1e6, "MB", len(files), "files")