|
| 1 | +# Auto-Marginalization Experiments Log |
| 2 | + |
| 3 | +All commands are assumed to be run from the repo root with the experiments |
| 4 | +project: `julia --project=JuliaBUGS/experiments …`. |
| 5 | + |
| 6 | +## 2024-09-24 — HMM marginal logp check |
| 7 | + |
| 8 | +- Script: `JuliaBUGS/experiments/scripts/hmm_marginal_logp.jl` |
| 9 | +- Default config (`AM_SEED=1`, `AM_T=50`, `K=2`). |
| 10 | +- Output: |
| 11 | + - Auto-marg logp: `-44.994096` |
| 12 | + - Forward reference: `-44.994096` |
| 13 | + - Delta: `-4.97e-14` |
| 14 | +- Notes: First deterministic check; script reads env vars `AM_SEED`, `AM_T`. |
| 15 | + |
| 16 | +## 2024-09-24 — HMM correctness sweep |
| 17 | + |
| 18 | +- Script: `JuliaBUGS/experiments/scripts/hmm_correctness_sweep.jl` |
| 19 | +- Config: defaults (`AM_SWEEP_SEEDS=1`, `AM_SWEEP_K=2,4`, `AM_SWEEP_T=50,200`). |
| 20 | +- Outputs (seed,K,T,logp_autmarg,logp_forward,diff): |
| 21 | + - `1,2,50,-79.870504305836,-79.870504305836,5.684e-14` |
| 22 | + - `1,2,200,-278.627031832427,-278.627031832427,-4.547e-13` |
| 23 | + - `1,4,50,-71.473518232377,-71.473518232377,1.421e-14` |
| 24 | + - `1,4,200,-275.848467761660,-275.848467761659,-2.274e-13` |
| 25 | +- Notes: Confirms auto-marg matches forward algorithm across plan’s grid. |
| 26 | + |
| 27 | +## 2024-09-24 — GMM correctness sweep |
| 28 | + |
| 29 | +- Script: `JuliaBUGS/experiments/scripts/gmm_correctness_sweep.jl` |
| 30 | +- Config: defaults (`AG_SWEEP_SEEDS=1`, `AG_SWEEP_K=2,4`, `AG_SWEEP_N=100,1000`). |
| 31 | +- Outputs (seed,K,N,logp_autmarg,logp_closed_form,diff): |
| 32 | + - `1,2,100,-204.416329424201,-204.416329424201,-5.684e-14` |
| 33 | + - `1,2,1000,-1970.291568636987,-1970.291568637027,4.047e-11` |
| 34 | + - `1,4,100,-203.586552750729,-203.586552750729,-2.558e-13` |
| 35 | + - `1,4,1000,-1948.173739898702,-1948.173739898751,4.843e-11` |
| 36 | +- Notes: Analytic marginal and auto-marg agree up to numerical precision. |
| 37 | + |
| 38 | +## 2024-09-24 — HMM gradient verification (AutoMarg target) |
| 39 | + |
| 40 | +- Script: `JuliaBUGS/experiments/scripts/hmm_gradient_check.jl` |
| 41 | +- Config: defaults (`AGC_SEED=1`, `AGC_K=2`, `AGC_T=50`). |
| 42 | +- Output (excerpt): |
| 43 | + - `logp = -126.799281599876` |
| 44 | + - `θ[1]: autodiff=1.438140e+02 fd=1.438140e+02 diff=-2.41e-09` |
| 45 | + - `θ[2]: autodiff=-8.204939e+01 fd=-8.204939e+01 diff=3.40e-09` |
| 46 | + - `θ[3]: autodiff=8.965588e+00 fd=8.965588e+00 diff=6.22e-10` |
| 47 | + - `θ[4]: autodiff=4.711574e+00 fd=4.711574e+00 diff=1.37e-09` |
| 48 | +- Notes: Gradients from ForwardDiff match central finite differences to ~1e-9. |
| 49 | + |
| 50 | +## 2024-09-24 — HMM gradient verification (sweep-enabled, default run) |
| 51 | + |
| 52 | +- Script: `JuliaBUGS/experiments/scripts/hmm_gradient_check.jl` |
| 53 | +- Config: defaults (`AGC_SEED=1`, `AGC_K=2`, `AGC_T=50`, `AGC_EPS=1e-5`, `AGC_VERBOSE=0`). |
| 54 | +- Summary: |
| 55 | + - `logp = -80.444277269128` |
| 56 | + - `max_abs_diff = 2.422e-09`, `max_rel_diff = 8.995e-10` |
| 57 | +- Notes: Script now supports sweeps via `AGC_SWEEP_SEEDS`, `AGC_SWEEP_K`, `AGC_SWEEP_T` and per‑θ verbose output via `AGC_VERBOSE=1`. |
| 58 | + |
| 59 | +## 2024-09-24 — GMM gradient verification |
| 60 | + |
| 61 | +- Script: `JuliaBUGS/experiments/scripts/gmm_gradient_check.jl` |
| 62 | +- Config: defaults (`AGG_SEED=1`, `AGG_K=2`, `AGG_N=200`, `AGG_EPS=1e-5`, `AGG_VERBOSE=0`). |
| 63 | +- Summary: |
| 64 | + - `logp = -468.030155527501` |
| 65 | + - `max_abs_diff = 6.644e-08`, `max_rel_diff = 4.846e-08` |
| 66 | +- Notes: Validates gradients w.r.t. continuous parameters (`mu`, `log_sigma`) under auto‑marginalization with fixed uniform weights; sweep supported via `AGG_SWEEP_*`. |
| 67 | + |
| 68 | +## 2024-09-24 — HMM scaling benchmark (auto-marginalization) |
| 69 | + |
| 70 | +- Script: `JuliaBUGS/experiments/scripts/hmm_scaling_bench.jl` |
| 71 | +- Config: defaults (`AS_SWEEP_SEEDS=1`, `AS_SWEEP_K=2,4`, `AS_SWEEP_T=50,200`, `AS_TRIALS=5`). |
| 72 | +- Output (seed,K,T,trials,mean_time_sec,logp,max_frontier,mean_frontier,sum_frontier): |
| 73 | + - `1,2,50,5,1.747571e-02,-79.870504305836,1,0.990,99` |
| 74 | + - `1,2,200,5,3.401337e-02,-278.627031832427,1,0.998,399` |
| 75 | + - `1,4,50,5,1.657132e-02,-71.473518232377,1,0.990,99` |
| 76 | + - `1,4,200,5,3.799386e-02,-275.848467761660,1,0.998,399` |
| 77 | +- Notes: Mean times grow roughly linearly in T. Frontier metrics reflect interleaved‑like minimal width (max_frontier≈1) under the model’s cached order. |
| 78 | + |
| 79 | +## 2024-09-24 — HMM scaling sweep (interleaved order) |
| 80 | + |
| 81 | +- Script: `JuliaBUGS/experiments/scripts/hmm_scaling_bench.jl` |
| 82 | +- Config: `AS_SWEEP_SEEDS=1`, `AS_SWEEP_K=2,4,8`, `AS_SWEEP_T=50,100,200,400,800`, `AS_TRIALS=5`. |
| 83 | +- Output (seed,K,T,trials,mean_time_sec,logp,max_frontier,mean_frontier,sum_frontier): |
| 84 | + - `1,2,50,5,1.725919e-02,-79.870504305836,1,0.990,99` |
| 85 | + - `1,2,100,5,2.026912e-02,-145.761382159410,1,0.995,199` |
| 86 | + - `1,2,200,5,2.251455e-02,-278.627031832427,1,0.998,399` |
| 87 | + - `1,2,400,5,9.836627e-02,-528.062883321577,1,0.999,799` |
| 88 | + - `1,2,800,5,3.282191e-01,-1049.936193752744,1,0.999,1599` |
| 89 | + - `1,4,50,5,1.502275e-02,-71.473518232377,1,0.990,99` |
| 90 | + - `1,4,100,5,7.704333e-03,-137.896475262787,1,0.995,199` |
| 91 | + - `1,4,200,5,2.397348e-02,-275.848467761660,1,0.998,399` |
| 92 | + - `1,4,400,5,8.882374e-02,-525.491535975989,1,0.999,799` |
| 93 | + - `1,4,800,5,3.479876e-01,-1045.351313078216,1,0.999,1599` |
| 94 | + - `1,8,50,5,5.099008e-03,-68.367716912908,1,0.990,99` |
| 95 | + - `1,8,100,5,1.158021e-02,-134.566394931630,1,0.995,199` |
| 96 | + - `1,8,200,5,3.383068e-02,-268.884504181967,1,0.998,399` |
| 97 | + - `1,8,400,5,1.070151e-01,-507.899254715377,1,0.999,799` |
| 98 | + - `1,8,800,5,4.041233e-01,-1014.031647189991,1,0.999,1599` |
| 99 | + |
| 100 | +## 2024-09-24 — HMM scaling sweep (min_time_sec, interleaved order) |
| 101 | + |
| 102 | +- Script: `JuliaBUGS/experiments/scripts/hmm_scaling_bench.jl` |
| 103 | +- Config: `AS_SWEEP_SEEDS=1`, `AS_SWEEP_K=2,4,8`, `AS_SWEEP_T=50,100,200,400,800`, `AS_TRIALS=5`. |
| 104 | +- Output (seed,K,T,trials,min_time_sec,logp,max_frontier,mean_frontier,sum_frontier): |
| 105 | + - `1,2,50,5,1.822208e-03,-79.870504305836,1,0.990,99` |
| 106 | + - `1,2,100,5,5.764750e-03,-145.761382159410,1,0.995,199` |
| 107 | + - `1,2,200,5,2.135263e-02,-278.627031832427,1,0.998,399` |
| 108 | + - `1,2,400,5,8.513233e-02,-528.062883321577,1,0.999,799` |
| 109 | + - `1,2,800,5,3.454963e-01,-1049.936193752744,1,0.999,1599` |
| 110 | + - `1,4,50,5,2.201750e-03,-71.473518232377,1,0.990,99` |
| 111 | + - `1,4,100,5,6.811584e-03,-137.896475262787,1,0.995,199` |
| 112 | + - `1,4,200,5,2.401713e-02,-275.848467761660,1,0.998,399` |
| 113 | + - `1,4,400,5,9.021662e-02,-525.491535975989,1,0.999,799` |
| 114 | + - `1,4,800,5,3.536854e-01,-1045.351313078216,1,0.999,1599` |
| 115 | + - `1,8,50,5,4.020833e-03,-68.367716912908,1,0.990,99` |
| 116 | + - `1,8,100,5,1.082317e-02,-134.566394931630,1,0.995,199` |
| 117 | + - `1,8,200,5,3.241446e-02,-268.884504181967,1,0.998,399` |
| 118 | + - `1,8,400,5,1.081037e-01,-507.899254715377,1,0.999,799` |
| 119 | + - `1,8,800,5,3.867681e-01,-1014.031647189991,1,0.999,1599` |
| 120 | + |
| 121 | +## 2024-09-24 — HMM scaling (K^2 normalization, interleaved order) |
| 122 | + |
| 123 | +- Script: `JuliaBUGS/experiments/scripts/hmm_scaling_bench.jl` |
| 124 | +- Config: `AS_SWEEP_SEEDS=1`, `AS_SWEEP_K=8,16,32,64`, `AS_SWEEP_T=400`, `AS_TRIALS=20`. |
| 125 | +- Derived metric: `time_over_TK2 = mean_time_sec / (T*K^2)`. |
| 126 | +- Results: |
| 127 | + - `K=8, T=400, trials=20, mean_time_sec=1.221838e-01, time_over_TK2=4.772805e-06` |
| 128 | + - `K=16, T=400, trials=20, mean_time_sec=1.921807e-01, time_over_TK2=1.876765e-06` |
| 129 | + - `K=32, T=400, trials=20, mean_time_sec=4.844382e-01, time_over_TK2=1.182710e-06` |
| 130 | + - `K=64, T=400, trials=20, mean_time_sec=1.484085e+00, time_over_TK2=9.058136e-07` |
| 131 | + |
| 132 | +## 2024-09-24 — HMM scaling (larger K, min_time_sec) |
| 133 | + |
| 134 | +- Script: `JuliaBUGS/experiments/scripts/hmm_scaling_bench.jl` |
| 135 | +- Config: `AS_SWEEP_SEEDS=1`, `AS_SWEEP_K=8,16,32,64,128`, `AS_SWEEP_T=400`, `AS_TRIALS=10`. |
| 136 | +- Results (normalized with `time_over_TK2 = min_time_sec/(T*K^2)`): |
| 137 | + - `K=8, T=400, min_time_sec=1.040547e-01, time_over_TK2=4.064637e-06` |
| 138 | + - `K=16, T=400, min_time_sec=1.634169e-01, time_over_TK2=1.595868e-06` |
| 139 | + - `K=32, T=400, min_time_sec=4.772193e-01, time_over_TK2=1.165086e-06` |
| 140 | + - `K=64, T=400, min_time_sec=1.436576e+00, time_over_TK2=8.768164e-07` |
| 141 | + - `K=128, T=400, min_time_sec=5.412097e+00, time_over_TK2=8.258205e-07` |
| 142 | + |
| 143 | +## 2024-09-24 — HMM scaling (very large K, min_time_sec) |
| 144 | + |
| 145 | +- Script: `JuliaBUGS/experiments/scripts/hmm_scaling_bench.jl` |
| 146 | +- Config: `AS_SWEEP_SEEDS=1`, `AS_SWEEP_K=256,512`, `AS_SWEEP_T=400`, `AS_TRIALS=5` (K=512 used 3 trials). |
| 147 | +- Results (normalized with `time_over_TK2 = min_time_sec/(T*K^2)`): |
| 148 | + - `K=256, T=400, min_time_sec=2.061049e+01, time_over_TK2=7.862278e-07` |
| 149 | + - `K=512, T=400, min_time_sec=8.741909e+01, time_over_TK2=8.336934e-07` |
| 150 | + |
| 151 | +## 2025-09-24 — FHMM order comparison (tiny T; consistent orders) |
| 152 | + |
| 153 | +- Script: `JuliaBUGS/experiments/scripts/fhmm_order_comparison.jl` |
| 154 | +- Config: `AFH_MODE=timed`, `AFH_C=2`, `AFH_K=2`, `AFH_TRIALS=20`. |
| 155 | +- Orders: `interleaved` (good), `states_then_y` (all z’s then all y; bad). |
| 156 | + |
| 157 | +Results (order,max_frontier,mean_frontier,sum_frontier,log_cost_proxy,min_time_sec,logp): |
| 158 | + |
| 159 | +- T=5 |
| 160 | + - `states_then_y,10,5.200,130,8.397e+00,9.741708e-03,-11.605424781297` |
| 161 | + - `interleaved,2,1.880,47,4.554e+00,2.232500e-04,-11.605424781297` |
| 162 | + |
| 163 | +- T=8 |
| 164 | + - `states_then_y,16,8.200,328,1.256e+01,1.142920e+00,-21.198978101373` |
| 165 | + - `interleaved,2,1.925,77,5.043e+00,4.742500e-04,-21.198978101373` |
| 166 | + |
| 167 | +- T=10 |
| 168 | + - `states_then_y,20,10.200,510,1.533e+01,2.566664e+01,-23.230717049023` |
| 169 | + - `interleaved,2,1.940,97,5.273e+00,5.868750e-04,-23.230717049023` |
| 170 | + |
| 171 | +Notes: |
| 172 | +- Both orders agree on logp for the same data; differences are purely computational. |
| 173 | +- The frontier lens explains tractability: interleaved keeps max_frontier≈C, while |
| 174 | + states_then_y grows roughly with T, making Σ K^{width} explode quickly. |
| 175 | +- New env var `AFH_ORDERS` allows selecting orders to run, e.g. `AFH_ORDERS=interleaved` |
| 176 | + or `AFH_ORDERS=states_then_y`. |
| 177 | + |
| 178 | + |
| 179 | +## 2025-09-24 — HDP-HMM correctness (finite truncation, sticky optional) |
| 180 | + |
| 181 | +- Script: `JuliaBUGS/experiments/scripts/hdphmm_correctness_fixed.jl` |
| 182 | +- Config: `AHDPC_SEEDS=1`, `AHDPC_K=5,10`, `AHDPC_T=100,200`, `AHDPC_ALPHA=5.0`, `AHDPC_GAMMA=1.0`, `AHDPC_KAPPA=0.0`. |
| 183 | +- Output (seed,K,T,alpha,gamma,logp_autmarg,logp_forward,diff): |
| 184 | + - `1,5,100,5.000,1.000,-132.648742618434,-132.648742618434,0.000e+00` |
| 185 | + - `1,5,200,5.000,1.000,-263.448999241194,-263.448999241194,1.137e-13` |
| 186 | + - `1,10,100,5.000,1.000,-94.917105497644,-94.917105497644,-7.105e-14` |
| 187 | + - `1,10,200,5.000,1.000,-175.671119347952,-175.671119347951,-9.095e-13` |
| 188 | +- Notes: Auto-marginalized log p(y|β,π,μ,σ) matches forward reference up to numerical precision. Sticky variant supported via `AHDPC_KAPPA` (default 0.0). |
| 189 | + |
| 190 | +## 2025-09-24 — HDP-HMM gradient verification |
| 191 | + |
| 192 | +- Script: `JuliaBUGS/experiments/scripts/hdphmm_gradient_check.jl` |
| 193 | +- Config: `AHDPG_SEED=1`, `AHDPG_K=5`, `AHDPG_T=200`, `AHDPG_ALPHA=5.0`, `AHDPG_GAMMA=1.0`, `AHDPG_EPS=5e-6`. |
| 194 | +- Summary: |
| 195 | + - `logp = -403.142155296914` |
| 196 | + - `max_abs_diff = 4.926e-08`, `max_rel_diff = 1.388e-03` |
| 197 | +- Notes: Gradients validated for μ, log σ, stick v, and π rows under Dirichlet(α·β). Sticky κ is used in the correctness script; gradient script uses non‑sticky rows to satisfy BUGS single‑assignment constraints. |
| 198 | + |
| 199 | +## 2025-09-24 — HDP-HMM gradient verification (sticky) |
| 200 | + |
| 201 | +- Script: `JuliaBUGS/experiments/scripts/hdphmm_gradient_check.jl` |
| 202 | +- Config: `AHDPG_SEED=1`, `AHDPG_K=5`, `AHDPG_T=120`, `AHDPG_ALPHA=5.0`, `AHDPG_GAMMA=1.0`, `AHDPG_KAPPA=5.0`, `AHDPG_EPS=5e-6`. |
| 203 | +- Summary: |
| 204 | + - `logp = -236.450382897373` |
| 205 | + - `max_abs_diff = 9.347e-08`, `max_rel_diff = 1.402e-03` |
| 206 | +- Notes: Implemented sticky prior in-gradient via deterministic `diagshift` primitive to keep single-assignment and AD friendliness; validates end‑to‑end gradients with z marginalized. |
0 commit comments