Training length, stability, and the staged sex warm start¶

Not a manuscript figure. This page documents how the number of training epochs was chosen, what is and is not reproducible across batches and random seeds, and why the fit is staged. Every setting here is tuned to the dataset. It concerns the level stage of the model (health component, frailty, PC-excluded scores; 20 signatures, 348 diseases, no polygenic age slope), which is the first stage of the manuscript backbone. The manuscript's figures use the 300-epoch recipe without the warmup described in section 8. Instructions: training notes.

Model. Level triplet on 348 diseases (UK Biobank): 20 disease signatures plus a health component, a per-person frailty, and 36 polygenic scores residualised on ancestry plus sex as covariates. $\lambda_{ik}(t)=r_k(t)+G_i\gamma_k+\delta_{ik}(t)$, $\theta=\mathrm{softmax}_k\lambda$. Fitted in 40 batches of 10,000 people, 300 epochs each. The stopping rule and the staged fit are written out in the training notes.

What this notebook builds up, in order.

  1. How many epochs: the held-out curve from both sides, and where calibration is best.
  2. Why the stopping epoch is the regulariser: the prior weight, learning rate and schedule sweeps.
  3. $\gamma$'s size depends on the stopping epoch; the box plots for the named cells.
  4. $\gamma$ across batches and across seeds, with the polygenic rows and the sex row kept apart.
  5. What is stable: signatures, and a person's trajectory under a pooled backbone.
  6. Why stage the fit: one seed in three, and two batches in forty, place disease-free people in sex-specific signatures.
  7. The staged fit: hold the sex coefficient for the first 150 epochs. Seeds, the new stopping epoch, discrimination, the worst batch.
  8. A scoring caution, and what is and is not established.

Every table below is read from a results file written by a script in src/. Group-level numbers only.

1. How many epochs: the held-out curve from both sides¶

Protocol. Train batch 0. Freeze the backbone ($\gamma,\psi,\epsilon$) at an epoch. On disjoint batch 1, refit only $\delta$ and frailty for 200 steps, then score the years after enrolment: forward Bernoulli NLL (lower is better), observed over expected (1 is calibrated), and the paper's 1-year and 10-year AUC on 28 disease groups. Checkpoints at 50 to 250 come from a local rerun of the same fit; 300 to 2000 from the three-seed run.

healthy mass at 40 held-out NLL O/E 1-yr AUC (washout 0) 10-yr AUC
epoch
50 0.3028 0.0094 2.8346 0.7835 0.6589
100 0.2489 0.0090 1.9406 0.8075 0.6726
150 0.2547 0.0087 1.4313 0.8441 0.6758
200 0.5706 0.0087 1.3035 0.8770 0.6800
250 0.8154 0.0087 1.2101 0.9205 0.6785
300 0.8956 0.0087 1.1186 0.9394 0.6781
600 0.9326 0.0088 0.7999 0.9632 0.6721
1000 0.9147 0.0091 0.6064 0.9678 0.6716
1500 0.8927 0.0095 0.4794 0.9715 0.6647
2000 0.8785 0.0098 0.4263 0.9709 0.6601
No description has been provided for this image

Reading. Held-out NLL is flat from 150 to 300 and higher by 600. The 10-year AUC is flat from 200 to 300 and lower after. O/E descends to about 1.1 at 300 and is below 1 by 600. The health component only fills between 200 and 300. This table has no epochs between 300 and 600; section 3 fills that gap and shows that calibration passes through 1 near 400. So 300 is the first epoch at which the model is complete and where the 10-year AUC is highest, with calibration still about 12 percent off. The training loss (panel A) falls throughout and would choose 2000.

The 1-year AUC rises with epochs. It is scored in the enrolment year, which the refit fits by design, so it measures how sharply the refit fits and cannot rank backbones. Read it only alongside NLL, O/E and the 10-year AUC.

2. The stopping epoch is the regulariser¶

The prior on $\delta$ has weight $W=10^{-4}$ and does not bind at 300 epochs, so what limits $\delta$ is when training stops. These are the sweeps that fixed the recipe. They were run on the earlier non-centered backbone, before the health component, frailty and ancestry exclusion were added.

is_selected sd of delta ||gamma|| gamma cosine vs selected sign agreement vs selected last_epoch
W
1e-05 False 1.005 27.771 0.437 0.803 299
5e-05 False 0.509 18.549 0.940 0.911 299
0.0001 True 0.336 16.321 1.000 1.000 299
0.0005 False 0.122 12.013 0.689 0.805 299
0.001 False 0.105 11.924 0.633 0.797 299
0.01 False 0.100 7.663 0.741 0.779 220
last_epoch final_loss mean_abs_gamma mean_abs_delta
config
nok_lr005_300 299 49.800 0.290 0.161
nok_lr01_300 299 46.226 0.169 0.175
nok_lr01_500 499 40.565 0.133 0.264
nok_lr01_clip300 299 46.226 0.169 0.175
nok_lr01_cos300 299 53.630 0.161 0.107
nok_lr01_cos500 499 47.574 0.166 0.157
nok_lr02_200 199 49.366 0.154 0.130
disease groups constant better median AUC constant median AUC cosine
horizon
dynamic_10yr 28 18 0.639 0.650
dynamic_1yr 28 27 0.844 0.728
static_10yr 28 24 0.659 0.655

Reading. A stronger prior ($5\times10^{-4}$ and up) shrinks $\delta$ about threefold and rotates $\gamma$ (cosine 0.63 to 0.74 against the selected fit). A weaker one lets $\delta$ grow. So a binding prior of this form is not a substitute for the stop. On learning rate and schedule: a cosine schedule ends with a higher loss because its rate has decayed to 0.001, which is an earlier stop under another name; clipping changes nothing; 500 epochs gives a lower training loss, which is the trap section 1 describes. Held out, constant is better than cosine in 24 of 28 disease groups on the static 10-year AUC and in 27 of 28 on the dynamic 1-year AUC. On the dynamic 10-year AUC it is better in 18 of 28, with a slightly lower median.

3. Where calibration is best, for the current recipe and for the warmed one¶

The same held-out curve on a finer grid, for two recipes: the current one, and the one with the sex coefficient held for the first 150 epochs (section 8). Both are batch 0, seed 0, scored on batch 1 with the same scorer. The current recipe's epochs between 300 and 600 come from a rerun of the same fit with extra checkpoints (run_current_recipe_midgrid_348.sh); its 300 reproduces the original score.

fwd_oe current fwd_nll current theta_health40 current fwd_oe warmup fwd_nll warmup theta_health40 warmup
epoch
50 2.8346 0.0094 0.3028 NaN NaN NaN
100 1.9406 0.0090 0.2489 NaN NaN NaN
150 1.4313 0.0087 0.2547 NaN NaN NaN
200 1.3035 0.0087 0.5706 1.3314 0.0088 0.3833
250 1.2101 0.0087 0.8154 1.2679 0.0088 0.7113
300 1.1189 0.0087 0.8956 1.1618 0.0087 0.8853
350 1.0507 0.0087 0.9242 1.0336 0.0087 0.9275
375 NaN NaN NaN 0.9945 0.0087 0.9336
400 0.9922 0.0087 0.9316 0.9571 0.0087 0.9368
450 0.9423 0.0087 0.9320 0.8888 0.0087 0.9393
500 0.9053 0.0087 0.9292 0.8284 0.0087 0.9403
600 0.7999 0.0088 0.9326 0.7346 0.0088 0.9410
1000 0.6064 0.0091 0.9147 NaN NaN NaN
1500 0.4794 0.0095 0.8927 NaN NaN NaN
2000 0.4263 0.0098 0.8785 NaN NaN NaN
current: 10-yr AUC, median over diseases warmup: 10-yr AUC, median over diseases
epoch
300 0.6494 0.6427
350 0.6446 0.6443
375 NaN 0.6452
400 0.6416 0.6415
450 0.6366 0.6388
500 0.6296 0.6379
three random starts under the warmup at 375 epochs, held out:
healthy mass at 40 held-out NLL O/E 1-yr AUC 10-yr AUC
seed
0 0.9336 0.0087 0.9945 0.9577 0.6452
1 0.9340 0.0087 0.9897 0.9648 0.6407
2 0.9350 0.0087 0.9927 0.9595 0.6423
No description has been provided for this image
current: O/E crosses 1 between epoch 350 and 400
warmup: O/E crosses 1 between epoch 350 and 375

Reading. Both recipes have the same shape: O/E starts well above 1, comes down through 1, and keeps falling as the model begins to over-predict. They pass through 1 at nearly the same point: the current recipe at about 400 epochs, the warmed recipe at about 375. So the warmup does not delay calibration. The held-out NLL does not separate epochs anywhere from 150 to 500. The 10-year AUC is highest near 300 for the current recipe and declines slowly after; for the warmed recipe it is flat from 300 to 400.

So the stop is a choice inside a plateau of about 300 to 400 epochs. At 300 the current recipe has its highest AUC and under-predicts by about 12 percent. Near 375 to 400 either recipe is calibrated, and there the warmed recipe has the slightly higher AUC. Under the warmup three random starts agree at 375 on every held-out measure, with O/E of 0.99 in each. All of this is one training batch scored on one group of held-out people.

4. $\gamma$'s size depends on the stopping epoch¶

Three starts, one path. The same fit started with the polygenic and sex rows of $\gamma$ at zero, at a quarter, and at the usual regression start.

epoch 0 50 100 200 300 400 600
run
scale 0 2.68 14.61 10.36 6.93 3.70 2.96 1.98
scale 0.25 2.72 14.66 11.05 6.70 3.62 2.72 1.90
scale 1 (production init) 2.86 14.85 10.00 6.34 3.41 2.72 2.47
No description has been provided for this image

Reading. All three starts overshoot by epoch 50 and then descend on one shared curve. At 300 they agree, so $\gamma$ at a given epoch is reproducible. But the curve never flattens: the size at 600 is smaller than at 300. The second panel measures agreement with the production fit at 300, so its peak there is built in; it shows a shared path, not a preferred epoch.

The named cells. Boxes are the 40 production batches at 300 epochs. Points are three seeds on batch 0 at 300 to 2000 epochs.

batch_mean batch_sd s0_e300 s0_e600 s0_e2000 s2_e300 s2_e600
cell
CAD->S5 0.209 0.038 0.253 0.182 0.206 0.411 0.262
T1D->S15 0.108 0.134 0.303 0.095 0.106 0.430 0.294
T2D->S15 0.949 0.138 1.007 0.477 0.569 1.199 0.963
BC->S19 0.184 0.058 0.173 0.080 0.086 0.197 0.068
BC->S6 0.203 0.133 0.103 0.053 0.011 0.366 0.056
AF->S0 0.243 0.052 0.247 0.173 0.152 0.243 0.189
LDL_SF->S5 0.102 0.029 0.132 0.106 0.107 0.255 0.159
SCZ->S9 0.006 0.051 -0.044 -0.011 -0.009 -0.157 0.006
No description has been provided for this image

Reading. At 300 seeds 0 and 1 sit inside the batch boxes. From 300 to 600 the strong cells shrink (type 2 diabetes on S15 roughly halves). So a tight box shows that the pipeline is reproducible at 300, not that the value has settled. A magnitude is quoted with its epoch.

5. $\gamma$ across batches and across seeds¶

$\gamma$ has 36 polygenic rows and one sex row. They behave differently, so they are reported apart.

r_mean r_min r_max
block comparison
PRS rows (36 x 20) batches, triplet (39 batches, 741 pairs) 0.233 -0.020 0.463
seeds 0 vs 1, same people (batch 0) 0.932 NaN NaN
seeds 0 vs 2, same people (batch 0) 0.707 NaN NaN
seeds 1 vs 2, same people (batch 0) 0.720 NaN NaN
batches, bar version (40 batches) 0.211 -0.072 0.425
sex row (1 x 20) batches, triplet (39 batches, 741 pairs) 0.800 0.449 0.989
seeds 0 vs 1, same people (batch 0) 0.980 NaN NaN
seeds 0 vs 2, same people (batch 0) 0.625 NaN NaN
seeds 1 vs 2, same people (batch 0) 0.739 NaN NaN
batches, bar version (40 batches) 0.863 0.408 0.999
PRS + sex (37 x 20) batches, triplet (39 batches, 741 pairs) 0.603 0.387 0.797
seeds 0 vs 1, same people (batch 0) 0.963 NaN NaN
seeds 0 vs 2, same people (batch 0) 0.655 NaN NaN
seeds 1 vs 2, same people (batch 0) 0.729 NaN NaN
batches, bar version (40 batches) 0.715 0.359 0.911
PRS rows, strongest 5% of cells batches, triplet (39 batches) 0.603 0.121 0.865
PRS rows, strongest 10% of cells batches, triplet (39 batches) 0.516 0.120 0.786
PRS rows, strongest 25% of cells batches, triplet (39 batches) 0.361 0.062 0.638
PRS rows (36 x 20) reliability of the 39-batch mean (Spearman-Brown) 0.922 NaN NaN
n median_abs_pooled sign_agreement share_cells_ge90pct median_snr
model cells
triplet strongest 5% 36 0.120 0.851 0.417 1.162
strongest 10% 72 0.090 0.818 0.347 0.904
strongest 25% 180 0.048 0.747 0.211 0.550
middle 50% 360 0.016 0.646 0.008 0.333
weakest 25% 180 0.004 0.533 0.000 0.067
all cells 720 0.016 0.643 0.057 0.288
bar version strongest 5% 36 0.212 0.940 0.806 2.020
strongest 10% 72 0.177 0.941 0.861 1.762
strongest 25% 180 0.135 0.860 0.511 1.177
middle 50% 360 0.046 0.688 0.008 0.441
weakest 25% 180 0.013 0.538 0.000 0.117
all cells 720 0.046 0.694 0.132 0.400
mean sd snr batches_with_pooled_sign n_batches
cell model
CAD -> S5 triplet 0.210 0.037 5.706 39 39
bar version 0.266 0.081 3.294 40 40
T2D -> S15 triplet 0.962 0.113 8.528 39 39
bar version 1.179 0.129 9.164 40 40
BC -> S19 triplet 0.187 0.055 3.375 39 39
bar version 0.202 0.145 1.398 39 40
AF -> S0 triplet 0.245 0.049 5.021 39 39
bar version 0.317 0.079 3.988 40 40
LDL_SF -> S5 triplet 0.102 0.029 3.507 39 39
bar version 0.114 0.108 1.054 33 40
T1D -> S15 triplet 0.111 0.132 0.840 31 39
bar version 0.137 0.117 1.176 35 40

Reading.

  • Polygenic rows. Two seeds on the same people agree at about 0.93 when they land in the same basin and about 0.71 when they do not. Two batches of different people agree at only about 0.23 over all 720 cells, and about 0.60 on the strongest 5% of cells. So batch-sampling noise is much larger than seed noise. One batch pins only the strong cells. The estimate is the mean over 39 batches, whose reliability is about 0.92.
  • Sign. The pooled sign is matched by about 85% of batches for the strongest cells and by about half, which is chance, for the weakest. The named cells keep their sign in every batch except type 1 diabetes on S15.
  • Triplet against the earlier model without the health component (bar version in the tables). Whole-block agreement between batches is the same in both (about 0.2). Across all cells the bar version has somewhat higher signal-to-noise and sign agreement. For the named cells the triplet is tighter: smaller spread for coronary disease, breast, atrial fibrillation and LDL. Separately, the spread of $\psi$ between batches is larger under the triplet.

6. What is stable: signatures, and a person's trajectory under a pooled backbone¶

348 diseases, 40 batches
diseases share
same signature in at least
40 of 40 batches 274 0.787
39 of 40 batches 297 0.853
36 of 40 batches 326 0.937
30 of 40 batches 338 0.971
No description has been provided for this image
group batch outlier pooled_loo pooled_vs_single seed seed_vs_batch
r_theta_median 0.993 0.982 1.000 0.995 0.971 0.977
r_theta_disease_rows_median 0.882 0.690 1.000 0.916 0.430 0.640
r_healthy_row_median 0.998 0.969 1.000 0.998 0.988 0.987
argmax_agree_60 0.447 0.283 0.973 0.538 0.083 0.265
risk10_r_CAD 0.965 0.931 1.000 0.978 0.960 0.940
risk10_r_T2D 0.891 0.814 1.000 0.913 0.943 0.819
risk10_r_AF 0.952 0.854 1.000 0.965 0.964 0.934
risk10_r_breast 0.888 0.639 1.000 0.939 0.981 0.891
risk10_r_prostate 0.947 0.865 1.000 0.961 0.899 0.941

Reading. Which signature a disease belongs to is the same in every batch for about four diseases in five, and for every named disease. The $\phi(t)$ curves overlay closely; batch 39, an outlier fit, is the top line in every panel. For a person: under two single-batch backbones their trajectory correlates at 0.99 overall and about 0.88 on the disease components, but their single top signature at age 60 agrees less than half the time, because loading is spread over many signatures and the top one is a near tie. Under two leave-one-out pooled backbones (pooled_loo) everything agrees to three decimals. So person-level results use the pooled backbone, and a person is described by the whole vector, never by one top signature.

7. Why stage the fit: health and sex can both explain a disease-free person¶

A disease-free person has to be placed somewhere. There are two ways to explain them: the health component, or a large sex coefficient that parks men in one quiet signature and women in another. Both fit the training data about equally. The health component fills late (between epochs 200 and 300) while $\gamma$ moves early, so small differences decide which explanation gets there first.

Across seeds, same people. Three random starts on batch 0, no fix.

sex_norm sex_on_healthy sex_S12 sex_S18 sex_S13 healthy_col_norm prs_norm train_loss
fit
production batch 0 (seed 0), no fix 4.354 -0.071 0.811 -0.719 2.808 0.297 3.421 48.782
seed 1, no fix 4.333 -0.083 1.451 -0.889 2.823 0.297 3.471 48.595
seed 2, no fix 9.170 -1.118 6.597 -3.912 2.249 1.207 4.487 49.052
healthy mass at 40 held-out NLL O/E 10-yr AUC, median over diseases
seed epoch
0 300 0.9017 0.0087 1.1144 0.6493
2000 0.8785 0.0098 0.4247 0.5948
1 300 0.9025 0.0087 1.1028 0.6476
2000 0.8209 0.0097 0.4714 0.5933
2 300 0.6348 0.0087 1.2961 0.6476
2000 0.5400 0.0127 29.4126 0.6346

Reading. Seed 2 has a sex coefficient more than twice the size of the others, large and opposite on S12 and S18, and strongly negative on the health component. At 300 its held-out NLL and 10-year AUC match the other seeds, with worse calibration and a much lower healthy mass. Trained on, it collapses in the opposite direction from the others: it under-predicts while they over-predict. The polygenic rows are barely involved.

Across batches, same seed. The share of loading on the health component and on the three parking signatures, for each of the 40 production fits.

rebuild vs trainer log, largest difference in healthy share: 3.5762786865234375e-07
women: healthy women: S18 men: healthy men: S13 sex coefficient norm train loss
50% 0.686 0.009 0.637 0.052 4.139 49.075
25% 0.669 0.008 0.606 0.027 3.729 48.782
75% 0.696 0.015 0.656 0.065 4.526 49.402
min 0.632 0.005 0.413 0.020 3.055 48.129
max 0.717 0.078 0.702 0.321 6.907 50.409
batches with the most male parking, then the outlier fit:
healthy_sex1 S13_sex1 healthy_sex0 S18_sex0 gsex_norm final_loss
batch
32 0.413 0.321 0.686 0.017 6.907 50.409
3 0.457 0.210 0.715 0.060 5.849 50.059
0 0.582 0.108 0.701 0.009 4.354 48.782
28 0.622 0.107 0.681 0.023 4.036 49.075
39 0.861 0.010 0.856 0.006 1.225 28.627
No description has been provided for this image

Reading. Women are consistent: the health component declines with age the same way in every batch and S18 never holds more than about 8% of their loading. Men are not. In batches 32 and 3 the S13 band widens with age until it carries about half of men's loading after 70. S13 also carries prostate disease, so some S13 loading in older men is real; the typical batch shows that level, and the excess in two batches is the parking. So the problem is graded, not all or nothing: no production fit is fully in the seed-2 state, and two of forty are partway. Batch 39 is a different failure, a fit whose person-level terms ran away.

8. The staged fit: hold the sex coefficient for the first 150 epochs¶

Only the sex row of $\gamma$ is held at its starting value; the polygenic rows learn from the first epoch. This does not make the health component fill sooner. It keeps the sex route closed while the health component fills on its usual schedule, and then releases sex. It is the same kind of fix as removing the ancestry components, which had opened an ancestry sink; sex cannot be removed, so it is delayed. An opt-in flag (SEX_WARMUP=150); unset, the trainer is unchanged.

Seeds. The same three starts, with the warmup, and with $\gamma$ fixed at the pooled value as a second approach.

sex_norm sex_on_healthy sex_S12 sex_S18 sex_S13 healthy_col_norm prs_norm train_loss
fit
production batch 0 (seed 0), no fix 4.354 -0.071 0.811 -0.719 2.808 0.297 3.421 48.782
seed 1, no fix 4.333 -0.083 1.451 -0.889 2.823 0.297 3.471 48.595
seed 2, no fix 9.170 -1.118 6.597 -3.912 2.249 1.207 4.487 49.052
seed 0, sex warmup 150 2.858 -0.047 -0.097 -0.531 1.656 0.280 5.360 51.012
seed 1, sex warmup 150 2.745 0.042 -0.311 -0.739 1.743 0.316 5.358 50.613
seed 2, sex warmup 150 2.729 0.000 -0.274 -0.557 1.684 0.287 5.430 51.017
seed 0, gamma fixed at pool 3.761 -0.017 1.234 -1.032 1.908 0.118 1.508 45.011
seed 2, gamma fixed at pool 3.761 -0.017 1.234 -1.032 1.908 0.118 1.508 44.991
epoch healthy mass at 40 held-out NLL O/E 10-yr AUC, median over diseases
recipe seed
no fix 0 300 0.9017 0.0087 1.1144 0.6493
1 300 0.9025 0.0087 1.1028 0.6476
2 300 0.6348 0.0087 1.2961 0.6476
sex warmup 150 0 300 0.8839 0.0087 1.1602 0.6427
1 300 0.8898 0.0087 1.1348 0.6410
2 300 0.8933 0.0087 1.1655 0.6402
gamma fixed at pool 0 300 0.9214 0.0087 1.1074 0.6476
2 300 0.9214 0.0087 1.1060 0.6484
No description has been provided for this image

Reading. With the warmup all three seeds agree on every row, in training and on held-out people, and seed 2's healthy mass on held-out people returns to the others' level. With $\gamma$ fixed the two seeds are the same fit. In the figure, row 2 is the unfixed seed 2 and the rows below it are the fixes; the pattern is the same in every ancestry group. At 300 neither recipe is calibrated yet (section 3); the warmed fits there have a slightly higher training loss and O/E than the current recipe.

Discrimination, scored within sex. The same held-out people, 10-year AUC per disease, computed over everyone and within each sex.

label production warmup300 warmup350 fixedgamma
n_diseases 221.0000 221.0000 221.0000 221.0000
median, over everyone 0.6537 0.6443 0.6481 0.6551
median, within sex 0.6299 0.6293 0.6303 0.6328
named six, over everyone 0.7332 0.7027 0.7016 0.7457
named six, within sex 0.6532 0.6568 0.6517 0.6698
production | within sex warmup300 | within sex warmup350 | within sex fixedgamma | within sex
coronary disease 0.690 0.682 0.687 0.694
type 2 diabetes 0.690 0.665 0.667 0.712
atrial fibrillation 0.698 0.685 0.696 0.697
breast cancer 0.506 0.522 0.491 0.535
prostate cancer 0.672 0.712 0.701 0.706
cerebral infarction 0.663 0.675 0.667 0.675
production | over everyone warmup300 | over everyone warmup350 | over everyone fixedgamma | over everyone
coronary disease 0.728 0.720 0.725 0.731
type 2 diabetes 0.706 0.673 0.676 0.728
atrial fibrillation 0.723 0.710 0.722 0.724
breast cancer 0.723 0.576 0.563 0.745
prostate cancer 0.850 0.857 0.852 0.863
cerebral infarction 0.669 0.681 0.673 0.684
warmup300   minus production, within sex: mean -0.0010 over 221 diseases; higher in 104
warmup350   minus production, within sex: mean -0.0010 over 221 diseases; higher in 90
fixedgamma  minus production, within sex: mean +0.0036 over 221 diseases; higher in 154

Reading. Scored over everyone, the warmed fit looks about 0.03 worse on the named six. Scored within sex it matches the current recipe: the mean difference over 221 diseases is about $-0.001$, with type 2 diabetes slightly lower and prostate cancer slightly higher. The apparent loss is breast cancer scored over both sexes, where a larger sex coefficient earns AUC by separating men from women. Fixed $\gamma$ is slightly higher within sex.

With pooled backbones, as used for prediction. Held-out batch 1 again, now scored under a backbone averaged over batches: four warmed fits (batches 0, 3, 5, 32), the same four batches' original fits, and the 38-batch production pool.

label pool_orig38 pool_orig4 pool_warm4
n_diseases 221.0000 221.0000 221.0000
median AUC within sex 0.6333 0.6315 0.6308
named six within sex 0.6682 0.6608 0.6602
median AUC over everyone 0.6539 0.6514 0.6480
held-out NLL 0.0087 0.0087 0.0087
O/E 1.1328 1.1325 1.0355
healthy mass at 40 0.9211 0.8958 0.9370
pool_orig38 pool_orig4 pool_warm4
coronary disease 0.696 0.694 0.690
type 2 diabetes 0.708 0.700 0.687
atrial fibrillation 0.701 0.696 0.705
breast cancer 0.527 0.520 0.504
prostate cancer 0.703 0.683 0.702
cerebral infarction 0.674 0.671 0.672
pool_warm4 minus pool_orig4, within sex: mean -0.0018 over 221 diseases; higher in 92
pool_warm4 minus pool_orig38, within sex: mean -0.0026 over 221 diseases; higher in 69

Reading. With pooling the picture is the same as with single batches. The forward NLL is identical in all three. Calibration is better under the warmed pool (O/E about 1.04 against 1.13). Within-sex discrimination is about 0.002 lower on average against the same four batches' original fits. The comparison with the 38-batch pool also reflects pool size: 38 batches against 4.

A second group of held-out people, and the paper's metric. Every score above used the same 10,000 held-out people (batch 1). The next cell repeats the pooled comparison on batch 2, which is in neither pool, and then gives the paper-style metric (28 disease groups, sex-specific groups within sex) for the warmed and original backbones on batch 1.

label pool_orig4 pool_warm4
n_diseases 222.0000 222.0000
median AUC within sex 0.6251 0.6290
median AUC over everyone 0.6561 0.6475
held-out NLL 0.0085 0.0086
O/E 1.1201 1.0253
healthy mass at 40 0.8961 0.9370
held-out batch 1: warmed minus original pool, within sex: mean -0.0018 over 221 diseases; higher in 92
held-out batch 2: warmed minus original pool, within sex: mean +0.0007 over 222 diseases; higher in 103
warmed minus original, within-sex 10-year AUC, by disease:
held-out batch 1 held-out batch 2
coronary disease -0.004 -0.009
type 2 diabetes -0.013 -0.009
atrial fibrillation 0.009 0.011
breast cancer -0.016 -0.031
prostate cancer 0.020 0.016
cerebral infarction 0.001 -0.015
1-yr AUC (28 groups) 10-yr AUC (28 groups) held-out NLL O/E
backbone
single batch, current recipe, 300 0.9399 0.6787 0.0087 1.1146
single batch, warm start, 350 0.9368 0.6656 0.0087 1.0336
single batch, warm start, 400 0.9434 0.6676 0.0087 0.9571
pooled, original fits, 300 0.9283 0.6838 0.0087 1.1325
pooled, warm start, 375 0.9496 0.6787 0.0087 1.0355

Reading. Prediction is essentially unchanged by the warm start. On the second group of held-out people the calibration gain repeats (O/E about 1.03 against 1.12) and the within-sex difference over about 220 diseases is zero on average. On the paper's metric the 1-year AUC is the same for single batches and slightly higher with pooling, and the 10-year AUC is within 0.005 with pooling. A few diseases move a little, in the same direction in both groups of people: type 2 diabetes about 0.01 lower, prostate cancer about 0.02 higher, atrial fibrillation about 0.01 higher. For diseases that both sexes get at different rates, sex is a legitimate predictor, and a smaller sex coefficient uses it slightly less; that is the likely source of the small all-comers difference.

The worst production batch, refitted. Batch 32, same people, same seed.

epochs men: S13 men: healthy women: S18 women: healthy sex coefficient norm train loss
label
production_b32 300 0.321 0.413 0.017 0.686 6.907 50.409
warmup_ep300 300 0.030 0.637 0.012 0.659 2.855 51.811
warmup 375 0.021 0.697 0.006 0.703 1.858 47.854
gfixed 300 0.046 0.643 0.012 0.677 3.701 46.203
epochs S13_men healthy_men S18_women healthy_women gsex_norm final_loss
label
production_b0 300 0.108 0.582 0.009 0.701 4.354 48.782
b0_warmup_seed0_ep300 300 0.035 0.611 0.011 0.622 2.862 51.000
b0_warmup_seed0_ep350 350 0.025 0.673 0.008 0.686 2.005 48.559
b0_warmup_seed0_ep400 400 0.021 0.700 0.006 0.707 1.594 46.343
b0_warmup_seed1_ep300 300 0.040 0.624 0.019 0.619 2.745 50.613
b0_warmup_seed2_ep300 300 0.036 0.621 0.013 0.625 2.729 51.017
b0_warmup375_seed0 375 0.022 0.689 0.007 0.699 1.760 47.404
b0_warmup375_seed1 375 0.021 0.699 0.008 0.693 1.744 46.942
b0_warmup375_seed2 375 0.022 0.696 0.007 0.698 1.754 47.315

Reading. In batch 32 men's share on S13 falls from about a third to a few percent under either fix, and men's healthy share returns to the typical level. Under the warmup at 375 epochs men and women carry the same healthy share. Batch 0 behaves the same way from a milder start, and its sex coefficient keeps shrinking with epochs, which is the drift of section 4. So one change handles an unlucky seed and an unlucky batch.

The select batches, original against warmed. The six batches of the earlier bar figure, each refitted with the warmup to 375 epochs.

S13 men | original S13 men | warmup healthy men | original healthy men | warmup S18 women | original S18 women | warmup healthy women | original healthy women | warmup
batch
0 0.108 0.022 0.582 0.689 0.009 0.007 0.701 0.699
1 0.032 0.019 0.557 0.704 0.078 0.007 0.697 0.692
3 0.210 0.019 0.457 0.707 0.060 0.008 0.715 0.695
5 0.059 0.028 0.606 0.685 0.007 0.007 0.703 0.701
32 0.321 0.021 0.413 0.697 0.017 0.006 0.686 0.703
39 0.010 0.022 0.861 0.698 0.006 0.009 0.856 0.691
batches refitted so far: [0, 1, 3, 5, 32, 39]
No description has been provided for this image

Reading. Under the warmup the six batches are indistinguishable. Men's share on the health component, which ranged from about 0.41 to 0.86 across these batches in the original fits, lies between about 0.69 and 0.71. Men's share on S13 is 2 to 3% in every batch, and women's share on S18 about 1%. The two batches with heavy male parking (3 and 32) and the batch with the most S18 in women (1) all return to the typical pattern, and men and women now carry the same health share.

Batch 39 was a different kind of outlier: a fit whose person-level terms ran away, with a training loss far below the others. Under the warmup it is an ordinary fit. Whether the warmup is the reason needs a control, because the original batch-39 fit was trained on a different machine: the same batch refitted on this machine with the original recipe.

epochs men: healthy men: S13 women: healthy women: S18 sex coefficient norm train loss
label
production_b39 300 0.861 0.010 0.856 0.006 1.225 28.627
b39_original_local 300 0.663 0.057 0.682 0.010 3.199 48.424
b39_warmup375 375 0.698 0.022 0.691 0.009 1.918 47.350

Reading. The control is an ordinary fit as well: with the original recipe on this machine, batch 39 has a training loss of about 48 and a typical health share and S13 share. So the original outlier fit was specific to that run, and the warmup is not what repaired it. The practical consequence is only that batch 39's original fit should be retrained or left out of the pool.

8b. Do the $\gamma$ boxplots hold under the warmup?¶

Same named cells as section 4. Boxes are the 39 production batches (original recipe, 300 epochs; batch 39 left out). Points are batches 0, 1, 3, 5 and 32 refitted with the warmup to 375 epochs, plus batch 0 under seeds 1 and 2. Script gamma_cells_warmup_vs_original_348.py.

box mean (39 batches, orig 300) box sd same 5 batches, orig 300 same 5 batches, warm 375 batch 0 seed 1, warm batch 0 seed 2, warm largest |z| of warm batches vs box
cell
CAD->S5 0.210 0.037 0.245 0.206 0.231 0.256 1.468
T1D->S15 0.111 0.134 0.205 0.235 0.401 0.280 2.225
T2D->S15 0.962 0.114 0.990 0.731 0.871 0.738 2.751
BC->S19 0.187 0.056 0.164 0.131 0.211 0.147 1.824
BC->S6 0.205 0.134 0.205 0.107 0.066 0.060 1.876
AF->S0 0.245 0.049 0.267 0.230 0.176 0.189 1.440
LDL_SF->S5 0.102 0.030 0.139 0.141 0.132 0.142 2.376
SCZ->S9 0.003 0.047 -0.043 -0.018 -0.063 -0.041 1.228
r_mean r_min r_max
comparison
batches 0,1,3,5,32 pairwise (original, 300 ep) 0.219 0.125 0.354
batches 0,1,3,5,32 pairwise (warm start, 375 ep) 0.247 0.171 0.415
batch 0 seeds 0 vs 1 (original, 300 ep) 0.932 NaN NaN
batch 0 seeds 0 vs 2 (original, 300 ep) 0.706 NaN NaN
batch 0 seeds 1 vs 2 (original, 300 ep) 0.720 NaN NaN
batch 0 seeds 0 vs 1 (warm start, 375 ep) 0.899 NaN NaN
batch 0 seeds 0 vs 2 (warm start, 375 ep) 0.916 NaN NaN
batch 0 seeds 1 vs 2 (warm start, 375 ep) 0.922 NaN NaN
batch 0: warm 375 vs original 300, same people 0.752 NaN NaN
batch 1: warm 375 vs original 300, same people 0.630 NaN NaN
batch 3: warm 375 vs original 300, same people 0.671 NaN NaN
batch 5: warm 375 vs original 300, same people 0.739 NaN NaN
batch 32: warm 375 vs original 300, same people 0.798 NaN NaN
batch 39: warm 375 vs original 300, same people 0.474 NaN NaN
orig300 warm375 sex_on_healthy_orig sex_on_healthy_warm warm300
batch
0 3.42 2.82 -0.07 -0.03 5.34
1 3.05 2.97 -0.39 0.06 NaN
3 4.01 2.61 -0.72 0.10 NaN
5 3.28 2.97 -0.07 -0.01 NaN
32 3.83 2.25 -0.35 0.04 4.61
39 1.51 2.96 0.09 0.13 NaN
0 seed1 3.47 2.73 -0.08 0.05 NaN
0 seed2 4.49 2.64 -1.12 0.01 NaN
No description has been provided for this image

Reading.

  • Direction holds. Every warmed fit sits within about 2.8 sd of the original box on every named cell. Six of the eight cells keep the box's sign in every warmed fit. Breast PRS on S6, already the noisiest cell, is slightly negative in one warmed batch. Schizophrenia on S9 is near zero in both recipes.
  • Batch agreement is unchanged. Five batches agree with each other at r of about 0.25 under the warmup and 0.22 under the original recipe. Pooling is still what pins $\gamma$.
  • Seed agreement is fixed. Under the warmup all three seed pairs agree at about 0.90 to 0.92. Under the original recipe seed 2 agreed with the others at only about 0.71.
  • Between-batch spread is about the same. On the same five batches the typical sd of a cell is 0.045 under the warmup against 0.054. For the named cells it is 0.02 to 0.07, small against their size, and every one keeps its sign in all five batches.
  • Size is still moving at 375. On batch 0 under the warmup, the norm of the polygenic block is 15.4 at 200 epochs, 5.3 at 300, 3.5 at 350, 2.3 at 400 and 1.6 at 500. The original recipe moves less over the same range: 3.6 at 300, 2.8 at 400. So under the warmup $\gamma$ overshoots while the sex row is held and then shrinks quickly. At 375 the strong cells are a little smaller than the original box: type 2 diabetes on S15 is about 0.73 against 0.96. A $\gamma$ magnitude must be quoted with its recipe and epoch, even more under the warmup.

8c. Does the signature structure under the warmup match production?¶

A disease's signature is $\arg\max_k \psi_{kd}$ over the 20 disease rows. The production reference is the modal signature over 39 production batches. Script sig_structure_warmup_vs_production_348.py.

same as production mode (348) same as mode (318 firmly held) same as this batch, original psi r with this batch, original
fit
production batches vs mode (39; median, min) 0.980 0.997 0.934 NaN
batch 0, original 300 0.989 1.000 NaN NaN
batch 0, warm 375 0.914 0.940 0.911 0.677
batch 1, original 300 0.960 0.987 NaN NaN
batch 1, warm 375 0.974 0.978 0.940 0.678
batch 3, original 300 0.954 0.994 NaN NaN
batch 3, warm 375 0.977 0.984 0.937 0.636
batch 5, original 300 0.974 0.997 NaN NaN
batch 5, warm 375 0.868 0.899 0.868 0.609
batch 32, original 300 0.968 0.984 NaN NaN
batch 32, warm 375 0.940 0.959 0.922 0.595
batch 39, original 300 0.989 1.000 NaN NaN
batch 39, warm 375 0.954 0.965 0.943 0.656
batch 0 seed 1, original 300 0.986 1.000 0.991 0.967
batch 0 seed 1, warm 375 0.940 0.972 0.943 0.682
batch 0 seed 2, original 300 0.954 0.984 0.948 0.841
batch 0 seed 2, warm 375 0.925 0.956 0.922 0.655
prod_sig production batches agreeing (of 39) warm_sig warm fits agreeing (of 8)
disease
Hypertensive chronic kidney disease 19 30 16 4
Cardiac arrest 3 38 16 3
Pneumococcal pneumonia 14 39 16 7
Chronic glomerulonephritis, NOS 19 35 0 4
Renal failure NOS 19 24 16 6
Chronic renal failure [CKD] 19 34 16 6
Chronic Kidney Disease, Stage III 19 39 16 4
Benign neoplasm of breast 8 23 3 6

Reading.

  • The structure holds, with one coherent shift. Warm fits give the production signature to about 87 to 98% of diseases. A production batch gives its own mode to about 98%. Only 8 of 348 diseases have a different modal signature across the eight warm fits.
  • The shift is kidney disease. Chronic kidney disease, renal failure and hypertensive kidney disease leave S19 for S16. In production S19 is a mixed bucket of skin, breast and eye conditions, and S16 holds sepsis, electrolyte disorders and acute illness. Several of these were already weakly held in production: renal failure is in S19 in only 24 of 39 batches.
  • The values of $\psi$ move more than the assignments. For the same people, $\psi$ under the warmup correlates about 0.6 to 0.7 with the original fit, against about 0.97 for two original seeds in the same basin. So the warm start is a different fit with the same structure, not the same fit. Prediction from the pooled backbone is essentially the same (section 8).
  • Here 310 or more of 348 assignments are unchanged in every warm fit.

A second measure: each disease's top signature over ages 50 to 70. Computed (script sig_structure_phi5070_warmup_348.py), with two baselines: two production batches, and the original recipe trained longer on the same people.

top signature, ages 50-70 argmax psi
comparison
batch 0: warm 375 vs original 300 (same people) 0.899 0.911
batch 1: warm 375 vs original 300 (same people) 0.922 0.940
batch 3: warm 375 vs original 300 (same people) 0.928 0.937
batch 5: warm 375 vs original 300 (same people) 0.845 0.868
batch 32: warm 375 vs original 300 (same people) 0.925 0.922
batch 39: warm 375 vs original 300 (same people) 0.940 0.943
batch 0 seed 1: original vs original seed 0 0.989 0.991
batch 0 seed 1: warm vs original seed 0 0.934 0.943
batch 0 seed 2: original vs original seed 0 0.945 0.948
batch 0 seed 2: warm vs original seed 0 0.928 0.922
original batch vs original batch (10 pairs, mean) 0.940 0.949
warm batch vs warm batch (10 pairs, mean) 0.881 0.894
recipe original recipe warm start
epoch
200 NaN 0.966
250 NaN 0.940
300 1.000 0.922
350 0.968 0.908
400 0.957 0.902
450 0.937 0.908
500 NaN 0.902
600 0.917 NaN
1000 0.862 NaN
1500 0.842 NaN
2000 0.845 NaN

Reading.

  • At 348 the warm start changes about 8% of top signatures on the same people (85 to 94% kept). Two production batches differ by about 6%. Two seeds in the same basin differ by about 1%.
  • About half of that is the extra training. With no warmup, the original recipe trained from 300 to 400 epochs keeps 96%. The warm start at 300 keeps 92%, and at 375 to 500 it stays at about 90%. The structure drifts slowly with epochs in both recipes: 92% at 600 and 85% at 2000 without the warmup.
  • Warm batches agree with each other a little less than production batches do: 88% against 94%.
  • On another disease list, check the structure with the same two baselines and at the same epoch for both recipes.

9. Scoring sex-specific diseases¶

An AUC computed over both sexes is misleading for a sex-specific disease: sex alone separates cases from non-cases, so a model with a larger sex coefficient scores higher without discriminating any better among the people who can get the disease. Compare backbones within sex. The manuscript's metric scores breast cancer within women and prostate cancer within men.

n_cases_all AUC over everyone n_cases_sex0 AUC within women n_cases_sex1 AUC within men
name
Breast cancer [female] 47 0.723 47 0.506 0 NaN
Malignant neoplasm of female breast 195 0.746 194 0.553 1 NaN
Cancer of prostate 205 0.850 0 NaN 205 0.672

10. Applying this elsewhere¶

  • The reasoning carries over; the numbers do not. One dataset (UK Biobank), 348 diseases, batches of 10,000. The stopping epoch, the warmup length, how often a fit parks and the warning thresholds depend on the cohort, the disease list and the batch size. On a new dataset: derive the stop from a held-out curve, check where loading sits by sex across a few batches and starts, apply the warmup if any fit parks, re-derive the stop, pool $\gamma$.
  • Re-derive the stop on held-out people. Here both recipes are calibrated near 375 to 400 epochs; a fit stopped at 300 under either is not.
  • Sex coefficients are not comparable between recipes. They are less than half the size under the warmup.
  • Any covariate that marks a group can open a sink, not only sex.
  • Each batch fit is still checked against the others (batch 39); the warmup is about order of learning, and it does not change the dependence of $\gamma$'s size on the stop or the noise of a single batch.

11. What is established, and what is not¶

Established on the evidence above.

  • The stop lies in a held-out plateau of about 300 to 400 epochs: NLL flat throughout, 10-year AUC highest near 300, calibration right near 375 to 400. The training loss cannot choose it, and training to 2000 is far worse on every held-out measure.
  • $\gamma$'s size depends on the stopping epoch and is quoted with it. Its pooled sign and ranking are reliable for the strong cells.
  • Signatures are stable across batches. A person's trajectory is stable under a pooled backbone.
  • Sex-specific parking is the one place where the start matters. It appears for one seed in three on one batch and partway in two of forty production batches.
  • Holding the sex coefficient for 150 epochs removes it for three of three seeds on batch 0 and for the worst production batch, with discrimination unchanged within sex. Fixing $\gamma$ at the pooled value also removes it.
  • Under the warmup, three random starts agree at 375 epochs in training and on held-out people, with O/E of 0.99 in each.

Not established.

  • The rate at which a random start finds the bad state: three seeds on one batch.
  • The stop on more than one training batch and one group of held-out people.
  • Held-out scores for the refitted batch 32, and the remaining production batches under the warmup.
  • Whether a pool that includes badly parked batches is safe to fix $\gamma$ at. The test used a pool of clean fits.
  • Uncertainty is from replication across batches, not from a posterior.

What stays as it is. The scale of $\gamma$ still drifts with epochs under the warmup, faster than under the original recipe (section 8b), and batch-to-batch noise in $\gamma$ is unchanged. Those are handled by the stop and by pooling.

Scripts¶

All in src/. Training: train_nokappa_v3_inithealthy.py (level stage; opt-in flags SEX_WARMUP, GAMMA_FREEZE_FROM, INIT_SEED), launchers run_sex_warmup_348.sh, run_sex_warmup_stop_348.sh, run_gamma_fixed_348.sh, run_batch32_fixes_348.sh, run_select_batches_warmup_348.sh, run_leftside_conv2000.sh, run_gamma_from_below.sh. Held-out scoring: convergence2000_348_heldout.py, convergence2000_348_fig5auc.py, heldout_perdisease_bysex_348.py. Readouts: gamma_batch_seed_stability_348.py, phi_stability_348.py, traj_stability_348.py, sig_mass_by_batch_f3way40.py, sig_mass_one_ckpt.py, pool_backbone_348.py, conv2000_348_plateau_plots.py, conv2000_348_gamma_cells_boxplot.py, conv2000_348_gamma_from_below_readout.py, recovery_epochs_centered_vs_reparam.py. Figures: fig_sig_mass_bars_select_batches.py, fig_sig_mass_bars_original_vs_warmup.py, fig_sex_sinks_by_ancestry_basins.py. This page: build_nb_stability_sex_warmup_348.py --public.