67 lines
12 KiB
Markdown
67 lines
12 KiB
Markdown
# S2 R2-G24 / N / E synthetic code acceptance
|
||
|
||
## Scope and decisions
|
||
|
||
This implements Claude's [22:18:01 ruling](https://arcticnimbus.slack.com/archives/C0C78UFKGRM/p1794665881295239), the v0.5 Gre24 mapping and v0.6 process-conditioned target, with the [22:37:54 correction](https://arcticnimbus.slack.com/archives/C0C78UFKGRM/p1794667074550589). Claude's [22:47:07 full-code main review](https://arcticnimbus.slack.com/archives/C0C78UFKGRM/p1794667627081159) approved `bb09e8e` with one required fix: log/standardise encoder base inputs. That fix is implemented below; R2 and the direct prediction target are unchanged. This remains a synthetic-only code delivery, not a fitted model, real-corpus preprocessing receipt, or approval of predictive accuracy.
|
||
|
||
No real geometry, LOG or simulation field is loaded by these modules/tests. The existing registration queue and its pinned sources are untouched. Test execution has empty CUDA visibility, one numerical thread and CPU tensors. No estimator `.fit`, backward pass, optimiser or parameter update is executed. Model initialisation is random, fixed by test seeds.
|
||
|
||
**The latest target ruling replaces v0.3's transform entirely:** predict `t* = T/t_set` directly, loss on `t*`, seconds = prediction × `t_set`. There is no log transform, tau, fitted scale, oracle end-of-fill time or fallback. The initial pre-ruling tests were superseded; the receipt in this delivery tests the corrected implementation. `t_set` must be a finite positive process setting supplied equally to all arms. `B0 = V*_f` in normalised units; multiply by `t_set` for seconds. Predictions are not silently clipped.
|
||
|
||
## R2-G24 computational contract
|
||
|
||
`tools/s2_models/features.py` takes in-memory arrays; it has no data-loading entrypoint.
|
||
|
||
- Coordinates are physical 3D positions; tetrahedra index all tet nodes in ascending original-ID order. Invalid indices, unused nodes, degenerate cells and nonfinite inputs fail closed. Exact `D_w=d(x)` is supplied by the existing distance preparation, not recomputed or inferred here.
|
||
- Tet edges are unique unordered pairs. Gate source is the nearest node to the supplied gate, with exact-distance ties going to the first/smaller original ID.
|
||
- Both R2 `D_i` and `D_f` exclude edges whose endpoints both have `D_w=0`. Remaining costs are length and length/mean(endpoint `D_w`), respectively. Unreachable nodes fail the part; no epsilon speed or imputation. This is a graph approximation of the eikonal, not tetFIM.
|
||
- Lumped volume is `Σ incident tet volume/4`. `V*_f(i)` is the strict weighted CDF `Σ_{D_f(j)<D_f(i)} m_j / Σm_j`, with equal values sharing the same CDF. Consequently the maximum-distance node may have `V*_f<1`; the code does not change `<` into `≤` or add half-tie mass. Normalising `D_f` first gives the same ordering.
|
||
- `D_i*` and `D_w*` divide by their positive maxima. Each scalar's constant P1 cell gradient is solved from the four nodal values; raw gradients are cell-volume averaged to nodes and then unit-normalised. Exactly zero gradients stay zero. **This averaging order and volume weighting are explicit implementation conventions submitted for review.**
|
||
- Spatial moment: `R=3*h_max`, with `h_max` the longest tet edge. Cell centres are arithmetic vertex means; `D_i(center)` is their P1 mean. Both `||center-node||<R` and `|D_i(center)-D_i(node)|<R` are strict. Coincident centres are excluded before computing neighbourhood volume. `S=Σ(v_j/V_i) u_ij u_ij^T` uses unit directions; trace is one and the tensor is positive semidefinite. Empty neighbourhoods fail closed. A spatial tree avoids storing every node/cell neighbourhood at once.
|
||
- Columns, in order: `Vf`, its 3 normalised gradient components; `Di*`, its 3 gradient components; raw `Dw`, `Dw*`, its 3 gradient components; `Sxx,Sxy,Sxz,Syy,Syz,Szz`; `t_set` (20 columns). Six independent symmetric entries preserve the full tensor. The common process setting is appended to the Gre24 geometry tuple as required by v0.6.
|
||
- HistGradientBoostingRegressor is pinned to sklearn 1.7.2; twelve configs: learning rate `{.05,.1}` × leaves `{31,63}` × iterations `{200,500,1000}`, min_samples_leaf 20, random_state 0, early_stopping false. Only configurations and unfitted estimators are tested; no HPO is run.
|
||
|
||
## N/E architecture and input contract
|
||
|
||
Upstream is [thuml/Transolver at 75e0f67643806a81cd1d3f6adc88dd8c02416fe7](https://github.com/thuml/Transolver/tree/75e0f67643806a81cd1d3f6adc88dd8c02416fe7), MIT. Exact irregular-mesh model, Physics_Attention source, licence and SHA256 manifest are preserved in `tools/s2_models/upstream/`. `upstream-adaptation.diff` records source changes. This is an adaptation, not a claimed reproduction.
|
||
|
||
The encoder uses all tet nodes, four irregular Transolver blocks, eight heads, 32 slices, widths 128 or 256, GELU, dropout 0 and upstream Model default mlp_ratio 1. It retains the upstream preprocessing MLP, learned placeholder, initialisation and residual attention/MLP blocks. The final scalar head is removed so each node yields an embedding. No time embedding or unified-position grid is used. Pure torch transpose/reshape replaces einops; torch trunc_normal_ replaces timm; structured-grid classes are omitted. An identical-state attention forward comparison against the original source is tested.
|
||
|
||
Base columns (10), before standardisation: `(x-center)/Rg` (3), `d/t_part`, Euclidean gate distance/Rg, unrestricted tet-edge geodesic/Rg, `log(Rg)`, `log(volume)`, `log(t_part)`, `log(t_set)` (natural logs). The geodesic helper without R2 wall-edge exclusion is a separate input path. Physical scale and process setting are explicit. `t_part` and geodesic/Rg follow the earlier executable feature conventions. No O2 quantity enters the whole-part encoder.
|
||
|
||
`normalization.py` fits mean/population std (`ddof=0`) for all ten columns from **the current fold/pool learning parts only**, taking all their tet nodes with equal node weight. It never uses query draw weights or labels. The caller supplies the frozen learning-part manifest; the array mapping must match exactly, so extra validation/test parts or missing learning parts are rejected. Statistics accumulate by part in float64 without concatenating the corpus. Each part's mean is computed after shifting by its first row: this preserves exact constant columns instead of manufacturing tiny variance through summation roundoff. A zero-std learning column uses scale 1 and maps its learning values to zero; held-out deviations remain observable, not imputed.
|
||
|
||
The frozen `BaseStandardizer` stores immutable tuples, fold/pool IDs, learning-part IDs and node count, and exports a reproducible fingerprint plus full statistics. An array transform rejects mismatched fold/pool IDs. N/E must be constructed with the **same** standardizer (`QueryModel(arm, width, standardizer=shared_stats)`); there is no unnormalised default. The encoder applies its mean/scale buffers before preprocessing in FP32, including under future AMP. These buffers are not learned parameters and are retained by `state_dict`; the exported statistics/provenance must accompany the run manifest. No validation/test transform refits statistics. Synthetic tests inspect the actual preprocess input to confirm identical N/E transforms. Parameter counts are unchanged.
|
||
|
||
Unit conversion test: multiplying all lengths (including gate/centre/distances/Rg/t_part) by L, volume by L³ and time setting by H leaves the first six columns unchanged and shifts the last four by `(log L,3 log L,log L,log H)` for every node. Applying correspondingly converted learning statistics gives the same standardised input. The first test attempt exposed the constant-column roundoff issue; its observed failure summary is preserved in `artifacts/s2-model-normalization-2026-11-14/initial-failure.json`, followed by the corrected 24/24 PASS log and source hashes. No real learning-pool statistics have been computed in this task.
|
||
|
||
The query decoder uses the original node index directly. N receives `[embedding,g12,g23]`; E additionally receives `[q1_mean,q1_max,q2_mean,q2_max]`. Two hidden GELU layers have the encoder width and a linear scalar output predicts `t*`. Missing E inputs, E inputs passed to N, nonfinite base/query values, empty/out-of-range queries fail closed. Qualification (positive distance, valid spectrum, N_eff≥64, complete finite edge block) must be enforced by the common-query producer; this module neither invents eligibility nor reads stored draws. All arms must receive identical eligible query IDs and counts.
|
||
|
||
Parameter counts for both tiers/arms are in the test receipt; E adds exactly `4*width` decoder parameters. Capacity selection remains the already-defined shared N/E validation choice; this delivery makes no choice. Optimisation settings are recorded as inert configuration (AdamW 1e-3, weight decay 1e-5, cosine, batch one part, ≤200 epochs, patience 20, seeds 0/1/2). There is no training loop or optimiser construction.
|
||
|
||
## Objective and score
|
||
|
||
For node i in part p in component g, `w_i = c_i / Σ_{j in p}c_j / n_parts(g) / n_components`. The full learning-pool weights sum to one. Neural loss is `Σ w_i(predicted_t*_i−t*_i)^2`, computed in float32; HistGBRT must use the same weights. Do not renormalise a one-part minibatch, which would erase group balance. An epoch objective sums part contributions. A future uniformly sampled part step multiplies its contribution by the number of learning parts to estimate that full objective without bias.
|
||
|
||
Per-part relative L2 masks ineligible rows **before** arithmetic, counts draws without another mass factor, and marks zero truth norm NA. It is invariant to the common positive per-part seconds scale. Aggregation, splits, inner validation, HPO, the training loop and corpus adapters remain later integration work, not represented as implemented execution by this delivery.
|
||
|
||
## Acceptance and limitations
|
||
|
||
Latest synthetic acceptance after the required normalisation fix: **24/24 PASS**, cases took 0.413 s. See `artifacts/s2-model-normalization-2026-11-14/receipt.json` and `unittest.txt`. This adds unit conversion, learning-only/frozen statistics, population mean/std/constant handling, and actual shared N/E preprocessing checks. Only synthetic statistics were calculated; no estimator fit, training update, true-data read or GPU operation occurred.
|
||
|
||
Historical pre-review acceptance at `bb09e8e`: **20/20 PASS** (2026-11-14 22:44:43 UTC+8). Its receipt/source hashes remain a record of that fixed commit rather than the subsequently modified source.
|
||
The test subprocess consumed 5.040 CPU-seconds, peak RSS 554.32 MiB including imports; unittest cases themselves took 0.214 s. The 8.753 s wall receipt includes parent imports and parameter-count construction as explicitly noted there. No benchmark claim is made from these tiny cases.
|
||
|
||
| Width | N parameters | E parameters | Shared encoder count |
|
||
| --- | ---: | ---: | ---: |
|
||
| 128 | 406,817 | 407,329 | 373,408 |
|
||
| 256 | 1,606,049 | 1,607,073 | 1,473,696 |
|
||
|
||
The registration monitoring snapshot at delivery recorded 425 terminal PASS receipts, 0 failures, 16 active jobs, `stop_reason=null` and no completion flag. This is a partial status, not completion of the 2,012-pair run.
|
||
|
||
Run `env OMP_NUM_THREADS=1 OPENBLAS_NUM_THREADS=1 MKL_NUM_THREADS=1 NUMEXPR_NUM_THREADS=1 CUDA_VISIBLE_DEVICES='' /home/frank14f/anaconda3/envs/pycuda_3_10/bin/python tools/test_s2_models.py`.
|
||
|
||
The synthetic suite checks analytic graph paths (including removed wall shortcuts and gate ties), unreachable/degenerate cases, lumped volume, strict CDF ties, affine P1 recovery, zero gradients, moment volume weighting/rotation/trace/scaling/coincident-centre exclusion, process-scale roundtrip, no missing-scale fallback, draw compression/hierarchy weighting, score masks, 12 unfitted configs, preserved upstream hashes and numerical attention parity, all four architecture forwards, query order/global context and unchanged parameters. Versions and measured CPU/wall/RSS are in `artifacts/s2-model-synthetic-2026-11-14/receipt.json`.
|
||
|
||
This does not establish real-corpus reachability after removing wall-wall edges, feature runtime/memory at corpus scale, neural accuracy, trainability, pilot fitness or GPU fit. Those are distinct later receipts. No completed blind review is repeated. The registration process continues independently; its status snapshot is monitoring evidence only.
|