Commit 580d693
committed
boxcrete: V2 strength GP — final-form module layout
Introduces the V2 strength GP — a multiplicatively-gated kernel
architecture that structurally enforces the physics constraint
f(x, t=0) = 0 with zero posterior variance — plus the supporting
public API and the saved model artifact.
Module layout (each module focused on one concept):
* boxcrete/concrete_model.py — SustainableConcreteModel (the
multi-output joint GWP/slump/strength model) and AppendDerivedFeatures.
* boxcrete/strength_model.py — public fit/load API for V2:
fit_strength_gp() and load_pretrained_strength_gp(). Hosts the
V2 fit factory and ChainedInputTransform composition.
* boxcrete/kernels.py — kernel primitives: TimeGatedKernel,
within_group_prior, ard_matern_with_within_group_prior,
additive_time_kernel, build_strength_kernel_for_aug_dim,
make_gated_strength_kernel_builder.
* boxcrete/features.py — features and transforms:
F5_ALLLOG_FEATURES, GATE_TAU, IDX, FEATURE_BUILDERS,
append_engineered_features_callable, augmented_bounds, max_scale_Y.
* boxcrete/likelihoods.py — GatedGaussianLikelihood (heteroscedastic
Gaussian with h(t)² gating, paired with the gated kernel) and
PartialFixedNoiseLikelihood.
* boxcrete/priors.py — WithinGroupShrinkagePrior + the binder /
aggregate group definitions used for ARD lengthscale shrinkage.
* boxcrete/slump_model.py — fit_slump_gp() for the slump model.
* boxcrete/strength_model_legacy.py — V1 helpers retained for
backward compatibility (get_strength_gp_input_transform).
Replaces the legacy boxcrete/models.py (758 lines) with the focused
modules above.
Persisted artifact:
* docs/model/strength_model.pt — PyTorch state_dict for the deployed
V2 strength GP. load_pretrained_strength_gp() reconstructs the
full SingleTaskGP from this without re-fitting.
Float64 throughout the fit (precision fix): explicit dtype=torch.float64
in boxcrete/utils.py (bounds, constraint coefficients), strength_model.py
(time-transform parameters), and priors.py (MVN loc/scale). Without
this, ~7-decimal float32 precision was sensitive enough to per-runner
CPU rounding that L-BFGS-B occasionally landed in different local
optima — including a wb_ratio-railed basin.
Tests:
* test/test_lengthscale_identifiability.py — guards lengthscales
remain identifiable (no rail-at-cap pathologies); also asserts
fresh-fit predictions agree with committed test_vectors.json
within a cross-architecture-portable tolerance.
* test/test_strength_curve_monotonicity.py — physical-constraint
regression for monotonic strength evolution (committed JSON
+ freshly-fit V2).
* test/test_pretrained_loader_fidelity.py — guards the state_dict
round-trip reproduces the trained model's predictions exactly.
* test/test_public_api.py — public API surface guard.1 parent 348b0ac commit 580d693
28 files changed
Lines changed: 4301 additions & 2788 deletions
File tree
- boxcrete
- docs/model
- notebooks
- scripts
- test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
| 54 | + | |
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
108 | | - | |
| 108 | + | |
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | | - | |
| 7 | + | |
| 8 | + | |
9 | 9 | | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
16 | 24 | | |
| 25 | + | |
| 26 | + | |
17 | 27 | | |
18 | 28 | | |
19 | 29 | | |
20 | 30 | | |
21 | 31 | | |
22 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
23 | 37 | | |
24 | 38 | | |
25 | 39 | | |
| |||
69 | 83 | | |
70 | 84 | | |
71 | 85 | | |
| 86 | + | |
| 87 | + | |
72 | 88 | | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
73 | 92 | | |
74 | 93 | | |
75 | 94 | | |
| |||
80 | 99 | | |
81 | 100 | | |
82 | 101 | | |
| 102 | + | |
83 | 103 | | |
84 | 104 | | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
85 | 110 | | |
86 | 111 | | |
87 | 112 | | |
| |||
93 | 118 | | |
94 | 119 | | |
95 | 120 | | |
| 121 | + | |
| 122 | + | |
96 | 123 | | |
| 124 | + | |
97 | 125 | | |
98 | 126 | | |
99 | 127 | | |
100 | 128 | | |
101 | 129 | | |
102 | 130 | | |
103 | 131 | | |
| 132 | + | |
104 | 133 | | |
0 commit comments