SOCrebuttal / docs /REVISION_LOG.md
ValerianFourel's picture
publish: docs (REVISION_LOG.md plus any per-folder READMEs.)
1e41dff verified

Geoderma Revision Log — GEODER-D-26-01032

Branch: bestrun-bands Manuscript: Spatiotemporal Gated Transformer for High-Resolution Soil Organic Carbon Mapping Using Multi-Temporal Remote Sensing Editor: Budiman Minasny Decision: Major Revision Resubmission deadline: 2026-05-29

This document is a phase-by-phase log of every code change, methodological decision, finding, and strategic discussion in the revision arc. Commit SHAs are referenced where applicable. Phases are roughly chronological but ordered by theme.


0. Starting state

Before this revision arc, bestrun-bands held:

  • 8e59df2 SGT V2: per-band input projection, wider head with linear skip
  • 0acdb60: module-level distributed init guarded for importable use
  • 0db68f3 kfold rewrite: latitude-decile spatial folds, train.py recipe
  • 26eb6b6: deterministic seed before split/rebalance
  • e706287: NUM_LAYERS=3, NUM_HEADS=4 set as base architecture
  • dc493b8: 20-channel band expansion ported across 9 sibling configs (2DCNN, 3DCNN, Baselines, CNNLSTM, SimpleTransformer, TFT, VAE, FoundationalModels, balancedDataset) — but SGT's own config.py was missed in this commit (caught and fixed later in Phase 2).

The k-fold pipeline existed but ran sequentially: one fold at a time per job, ten folds × ~per-fold time. No production-mapping pipeline yet, no architecture comparison, no spatial-CV bug discovery yet.


1. Parallel orchestrator (feb2a8d)

Problem. The k-fold orchestrator capped concurrency at one fold per GPU. With 4 GH200s and 10 folds, three sequential waves (4+4+2). Per-fold SGT V2 uses ~1.5 GB of HBM; the 96 GB GH200s were ~95% idle.

Decision. User chose 3 folds/GPU (12 slots, 10 used) and no MPS (rely on CUDA's default time-slicing — sufficient for a ~1.2M-param model where memory and bandwidth aren't the bottleneck).

Change in rebuttal/gpu_experiments/spatial_kfold/run_folds_parallel.py:

  • New --folds-per-gpu flag, default 1 for backward compatibility.
  • Slot-keyed bookkeeping (slot_idx → gpu_id via slot_idx % num_gpus) replacing the previous gpu_id-keyed dicts.
  • Each fold subprocess still pinned to exactly one GPU via CUDA_VISIBLE_DEVICES=<one-id>.

Result. Single command launches all 10 folds simultaneously:

python rebuttal/gpu_experiments/spatial_kfold/run_folds_parallel.py \
    --num-folds 10 --num-parallel 10 --folds-per-gpu 3 \
    -- <run_kfold.py args>

Wall time drops from 3 × per_fold_time to ~1 × per_fold_time. ~10–15 min total at 300 epochs, ~10 min at 30 epochs (which became the standard screening epoch budget after later diagnostic work — see Phase 5).


2. Cherry-picked methodology pivot — sampling, cap, augmentation, stratified reporting (fb58def)

Problem. User flagged that the original methodology had cherry-picked parameters: MAX_OC=150 (the dataset max — no soil-science justification), rebalance_min_ratio=0.75 with 128 qcut bins (heavy oversampling of rare-tail rows by literal duplication). A reviewer-proof methodology was needed.

Decisions taken in this phase:

2a. MAX_OC: 150 → 120 (WRB histosol threshold)

Reframing the cap from "the dataset max" to "the WRB international threshold separating mineral from organic soils." Drops 154 rows (0.93% of 16,514). Single sentence of soil-science justification.

SpatiotemporalGatedTransformer/config.py:27:

MAX_OC = 120  # WRB histosol threshold (organic soils excluded).

2b. Replace qcut-rebalance with KDE-density sampler

rebalance_by_oc_bin was qcut-ing OC into 128 quantile bins and upsampling rare bins by literal row duplication (memorization risk on a heavy-tailed distribution).

Replacement: WeightedRandomSampler with weights w_i ∝ kde(log(OC_i))^(-α), normalized to mean 1. Yang et al. ICML 2021 ("DenseLoss / DenseWeight"). KDE bandwidth = Scott's rule (default; not tuned — important for defensibility). Default α = 0.5 = sqrt- frequency weighting.

New CLI in run_kfold.py:

  • --sampler-mode {kde, qcut} (default kde)
  • --alpha-density (default 0.5)
  • --rebalance-min-ratio retained for legacy qcut mode

2c. D4 spatial augmentation

_AugmentingWrapper applies a uniformly-sampled element of the dihedral group D4 (4 rotations × 2 flips) on the (H, W) plane of each train-loader sample. Test loader unchanged. Soil patches have no orientation prior; this is label-preserving.

2d. Stratified-by-OC-band reporting

Pooled predictions across all 10 fold test sets, binned by actual OC into [0, 20), [20, 40), [40, 80), [80, ∞), plus all. Added to kfold_results.md and kfold_results_summary.json. Pre-empts the reviewer question "where does the R² come from?" — answers regime-by-regime.

2e. Per-fold predictions saved to disk + --aggregate-only mode

Each fold subprocess now writes fold_<i>_predictions.parquet. The orchestrator (after Phase 1) launches per-fold subprocesses in parallel; without per-fold persistence, the cross-fold aggregation couldn't run. New --aggregate-only mode reads every per-fold parquet and writes the cross-fold summary.

Orchestrator (run_folds_parallel.py) now invokes python run_kfold.py --aggregate-only --num-folds 10 … automatically after all per-fold subprocesses complete.


3. Verification, GPU monitoring, first symptom diagnosis

After the methodology changes landed, the user submitted the full parallel sweep at MAX_OC=120 with the new sampler. Initial concerns:

3a. Was the 20-band port complete?

User asked: "is it using all 20 channels?"

Investigation revealed dc493b8 ("Port band expansion (20 channels) onto bestrun") updated 9 sibling configs but missed SpatiotemporalGatedTransformer/config.py. The SGT was training on the old 6-band stack. Fixed in 25ae836:

  • bands_list_order extended to 20 entries (originals first, 14 appended)
  • SamplesCoordinates_Yearly and DataYearly extended to length 20
  • 14 new *TensorDataYearly and *BandMatrixCoordinates_Yearly path variables added

Verified via param count: SGT V2 at 6 channels = 1,228,627 params; at 20 channels = 1,234,115 params. (The grouped 1×1 input conv only adds ~5k params per +14 bands — empirical confirmation of the band-extensibility claim that became Phase 8's headline.)

3b. GPU monitoring on the Slurm cluster

User asked how to watch GPU usage. Suggested using srun --overlap from a second login shell:

srun --jobid=$JOBID --overlap nvidia-smi -l 2     # live snapshot
srun --jobid=$JOBID --overlap nvidia-smi dmon -s pucm -o T   # logged stream
srun --jobid=$JOBID --overlap nvidia-smi pmon -s um -d 2     # per-PID

Cross-reference fold PIDs to architecture via grep "PID 12345" output_kfold_v*.log.

3c. First-run training diagnostic — upward prediction bias

Fold 9 epoch 11 output:

Min original_test_outputs: 14.85    Max: 185.08
Min original_test_targets:  0.84    Max: 120.00
Epoch 11  R²: -1.26  RMSE: 36.49

Predictions blew past the training cap (118 vs 120). Mean prediction was ~50 vs target mean ~22. Diagnosis: KDE sampler at α=0.5 was creating a distribution shift — reweighted training distribution had heavier upper-tail than the true distribution, pulling predictions up systematically. Compounded by log target_transform's natural relative- error weighting.

User experimented with α=0.2; results were "the same issue, drift seems slower." Recommendation graduated to:

  1. Drop KDE entirely (--sampler-mode qcut --rebalance-min-ratio 0 = plain shuffle, no rebalancing).
  2. Lower --lr from 2e-4 to 1e-4 for stability.

Rationale: log target_transform alone handles SOC's log-normal scale; KDE rebalancing on top is partially redundant and introduces the distribution-shift bias.

3d. "Violent" model-capacity reduction

Even without KDE, the model overfitted: training loss monotonically down, test loss diverged from epoch 2 onward, predictions drifted up toward the cap. Param count = 1.23M / 14.7k train rows = 84 params per sample — overfitting territory.

User asked: "should I make a bigger 3DCNN? is it worth it?"

Recommended NOT bigger 3DCNN — the architecture's three pool-2 layers reduce 5×5×5 input to 1×1×1, destroying spatial information. Wrong inductive bias for tiny patches.

Recommended instead: reduce SGT capacity, hard. Move to --model-size small (SimpleSGT, 1 transformer layer, hardcoded) with --hidden_size 64 → 165 k params. Plus --dropout_rate 0.5 for added regularization. Plus number_of_epochs reduced (cosine decay over 60 instead of 300).


4. CRITICAL bug fix: best_model_state reference vs clone (b5c1cac)

Discovery. The user ran 8 spatial-CV sweeps under the new small-model regime. Every config had negative mean R² across all folds. Suspicion: maybe the gating + log target combo was fundamentally broken at this scale.

Diagnostic script (inspect_sweep.py, committed 6a97d2f) compared the per-epoch R² trajectory in fold_<i>_metrics.json against the "saved best" R² in fold_<i>_summary.json. Result was unmistakable:

metric every fold, every config
saved R² exactly equal to last epoch's R²
best epoch R² (highest in the trajectory) up to +8 R² points higher than saved R²
median gap ~1.5 R² points

Root cause in SpatiotemporalGatedTransformer/train.py:337:

best_model_state = model.state_dict()

model.state_dict() returns a dict of references to the live parameter tensors. The next epoch's optimizer step mutates those tensors in place, so best_model_state always points at the most recent (final-epoch) state. The "best" criterion was tracking the max R² correctly, but the weights recorded as best were silently overwritten every subsequent epoch.

Fix:

best_model_state = {k: v.detach().clone()
                    for k, v in model.state_dict().items()}

Impact. This bug had been silently corrupting every kfold + sweep + final-mapping output for the entire revision arc (and likely the original submission as well). The corrected re-runs showed real spatial-CV R² of 0.10–0.18 across architectures — a defensible result under honest evaluation.

Same fix ported to the three sibling architectures in b3b6814:

  • 3DCNN/train.py:223,263 (the v.cpu() pattern was accidentally correct on GPU but broken on CPU; made explicit)
  • CNNLSTM/train.py:237,241 (same root bug as SGT)
  • SimpleTransformer/train.py:252,256 (same root bug as SGT)

5. Sweep infrastructure (6dd1812, 029a8e5, 41f7e34, eb90079)

After the bug fix, the user wanted a systematic architecture sweep rather than ad-hoc commands. Built a four-piece pipeline.

5a. sweep_submit.py — Slurm orchestrator

Submits one sbatch per architecture config (4-GPU jobs). Generates the sbatch script on disk under sweep/sbatch/<tag>.sbatch, log files under sweep/slurm_logs/<tag>_%j.out. Per-config output dir sweep/<sweep-name>/<tag>/.

Initial grid (6dd1812): 8 SGT configs spanning d_model ∈ {48, 64, 96, 128}, heads ∈ {2, 4}, layers ∈ {1, 2, 3} with --model-size big. Reduced to 80-epoch screening budget (later reduced again to 30 after diagnostic work — see Phase 5d).

Added SimpleSGT rescue variants (029a8e5): small_d64_h2_L1, small_d96_h2_L1, small_d128_h2_L1 after early indication that the big variants were over-parameterized.

Pivoted entirely to SimpleSGT (41f7e34): after the bug fix exposed that SimpleSGT-class models hit R² ≈ 0.15–0.18, while the big EnhancedSGT variants topped out around R² = −0.2 at 1.2M params. New default grid became SimpleSGT-only, d_model ∈ {32, 48, 64, 96, 128}, h ∈ {2, 4}.

5b. sweep_summarize.py — ranking + comparison table

Recursive glob over sweep/**/kfold_results_summary.json, extracts across-fold mean R² / std / RMSE / MAE / RPIQ + per-fold R² array. Ranks by score = r2_mean − 0.5 × r2_std (rewards stability).

Tag regex handles (small_)?d<H>_h<HEAD>_L<L> for SGT, baseline_<model>_<variant> for tree models, later extended to <family>_d<H>_h<HEAD>_L<L> for the 3DCNN/CNNLSTM/SimpleTransformer family ports.

5c. --sweep-name namespacing (eb90079)

Multi-axis sweeps (max-OC sensitivity, loss-function ablation) need to land in separate directory trees so they don't overwrite. Added --sweep-name <name> flag: outputs go to sweep/<sweep-name>/<tag>/ instead of sweep/<tag>/. sweep_summarize.py walks all sub-sweeps recursively, surfaces a group column showing the namespace.

Used to run max-OC sensitivity:

  • --max-oc 90 --sweep-name oc90
  • --max-oc 120 --sweep-name oc120
  • --max-oc 150 --sweep-name oc150

Finding: R² is monotonically increasing in max-OC (oc90: 0.10–0.14; oc120: 0.14–0.17; oc150: 0.16–0.18) for the same architecture. Driven by the heavy SOC tail's contribution to ss_tot in R²'s variance-normalized denominator. Not a real model-quality signal — a metric artifact. RPIQ moves the opposite direction (highest at oc90). Drove a later careful discussion of RPIQ presentation (see Phase 11).

5d. Sweep diagnostic (6a97d2f)

After all 8 big-variant configs returned negative R², the user ran the diagnostic script that exposed the best-state bug (Phase 4). The diagnostic itself (inspect_sweep.py) walks the per-epoch fold_<i>_metrics.json and reports best epoch / saved R² delta. After the bug fix, delta is ≈ 0 everywhere as it should be.


6. Tree-ensemble baselines (ef9930d, 6afb8d3)

Goal. Provide tree-ensemble baselines on the same 10-fold spatial-CV geometry, same MAX_OC, same target transform — so the rebuttal table shows SGT vs RF/XGB head-to-head under identical evaluation.

6a. run_baselines.py — GPU XGBoost + RF on the same folds

For each LUCAS sample, extract 80 features: {mean, std, min, max} per band over the (T, H, W) cube, per the standard SOC-mapping literature recipe (Hengl 2018, Padarian 2019). Tree models are scale-invariant so no normalization. Targets log-transformed by default to match the SGT runs.

XGBoost: native GPU support via tree_method='hist', device='cuda'. Random Forest: cuML on GPU if installed; sklearn CPU otherwise (auto- fallback). On 14.7k × 80, sklearn RF fits in ~30 s, so the GPU path is nice-to-have not essential.

Folds reuse build_folds_latitude_deciles from run_kfold.py. Per-fold outputs match SGT's format (fold_<i>_predictions.parquet + fold_<i>_summary.json + kfold_results_summary.json) so they appear in the unified sweep_summarize.py ranking.

6b. Sweep integration (6afb8d3)

Added BASELINE_GRID to sweep_submit.py: 4 XGB variants (default/shallow/deep/fast — varying depth × n_estimators × lr) + 3 RF variants (default/shallow/deep — varying depth × n_estimators). 7 configs total.

Bundled into one sbatch job (1 GPU). Feature extraction cached to baseline_features/feats_max_oc_<C>.npz so only the first config in the bundle pays the ~3-min I/O cost; subsequent configs load the cache.

Avoided the race condition of submitting 7 parallel feature-extraction jobs at once. New CLI: --baselines / --no-baselines / --baselines-only, parallel to the later --families and --vanilla.

Headline finding from baselines (after bug fix): every RF and XGB variant yields negative R² on the Alpine fold (fold 0) across all max-OC values. SGT consistently positive there. This became one of the three central claims of the revised paper (see Phase 10).


7. Cross-architecture sibling support — 3DCNN, CNNLSTM, SimpleTransformerV2 (b3b6814)

Goal. Make the 3DCNN, CNNLSTM, and SimpleTransformerV2 sibling architectures runnable under the SGT k-fold pipeline so all four families train on identical data, identical splits, identical augment- ation, identical training loop.

7a. --model-family flag + generic model factory

Added _build_model(args) to run_kfold.py that dispatches:

  • sgtbuild_sgt_model(args) (the existing path)
  • 3dcnnSmall3DCNN(input_channels, height, width, time, dropout)
  • cnnlstmRefittedCovLSTM(num_channels, lstm_input_size=128, lstm_hidden_size, num_layers, dropout) (the 128 is hardcoded in the model's internal CNN — feature size after pool×2)
  • simpletransformerSimpleTransformerV2(input_channels, height, width, time_steps, num_heads, num_layers, dropout_rate)

All four take (B, C, H, W, T) input from the project-wide dataloader and return a (B,) scalar. Sibling modules imported lazily inside the factory so a default --model-family sgt run doesn't pay the import cost.

7b. FAMILY_GRID + --families / --families-only flags

Three sibling-family entries at d=64 h=4 L=1 (matched canonical config across architectures). Submitted same way as SGT (one 4-GPU sbatch per config). sweep_summarize.py regex extended to recognize <family>_d<H>_h<HEAD>_L<L> tags.

7c. Findings

family best R² (oc150) params all folds R² > 0?
SGT (SimpleSGT d=128) 0.168 363 k Yes
SimpleTransformerV2 (d=64 h=4) 0.183 11.2 M Yes
CNNLSTM (d=64 h=4) 0.090 93 k No (fold 0 = −0.15)
3DCNN −0.76 (catastrophic) 27 k No (every fold negative)

3DCNN's failure: the architecture's three successive 2×2×2 poolings reduce a 5×5×5 input to 1×1×1 — spatial information destroyed before the FC head. Architectural mismatch, not capacity. Decided to leave 3DCNN as a "capacity-floor reference" in the table rather than fix it (see Phase 11 "should we make a bigger 3DCNN" discussion).


8. Composite L1/MSE + Pearson chi-square loss (a94941d, 03c1e60, af1c6b4)

User request. Add a chi-square loss component to SGT — for completeness in the rebuttal, "for the sake of argument."

8a. First implementation (a94941d)

_composite_loss() helper in train.py. Five loss types:

  • l1, mse — existing
  • chi2 — Pearson goodness-of-fit in original g/kg space, alone
  • l1_chi2 — L1 in transformed space + chi2 in original space
  • mse_chi2 — MSE in transformed space + chi2 in original space

Chi-square computed in original space (g/kg), not in the transformed target space, because Pearson chi-square only has its statistical interpretation on the natural scale of the target. For log-target runs the helper inverts exp(clamp(output, -3, 6)) before computing ((y_pred - y_target) ** 2 / (y_target + eps)).mean(). Clamp range chosen so output ∈ [0.05, 403] g/kg — bounded even in early training.

Default chi2_weight=0.01.

8b. Redo with explicit α/β weights (03c1e60)

User's spec: α × base + β × chi2, with α and β as separate CLI knobs. Renamed:

  • l1_chi2composite_l1
  • mse_chi2composite_l2

New flags: --loss-alpha (default 1.0) and --chi2-weight (default 0.1). Example: --loss-alpha 0.5 --chi2-weight 0.1.

Validated against the user-supplied spec by computing 0.5 × L1 + 0.1 × χ² on synthetic data — matches arithmetically.

8c. Plumbed through the sweep submitter (af1c6b4)

Added --loss-type / --loss-alpha / --chi2-weight to sweep_submit.py, forwarded to both build_sbatch (SGT) and build_family_sbatch (3DCNN, CNNLSTM, SimpleTransformer). Default stays l1 so existing sweep configs are unchanged.

8d. Finding from composite_l2 runs

variant R² mean std notes
SGT small_d128_h4_L1 oc150 plain L1 0.168 0.065 rank 3 overall
SGT small_d128_h4_L1 oc150 composite_l2 0.167 0.061 rank 2 (best score) — marginal std improvement
SimpleTransformerV2 oc150 composite_l2 −0.110 0.251 rank 82 — destabilized

SGT tolerates composite_l2 (marginal benefit on stability); the canonical heavyweight transformer breaks under the same loss. This became an unexpected robustness data point for the SGT-vs-vanilla comparison.


9. Vanilla transformer ablation (1f3a3e1, 045f246)

Motivation. Pre-empt the strongest reviewer attack on the parameter- efficiency claim: "You compared SGT at 363k to SimpleTransformerV2 at 11.2M — that's a strawman. What about a parameter-matched vanilla transformer?"

9a. New model class (1f3a3e1)

SpatiotemporalGatedTransformer/VanillaSpatiotemporalTransformer.pySimpleSGT minus the Gated Residual Network. Replaces lines 23–36 of SimpleSGT.py (grn + gate + residual_proj + layernorm of those) with a single Linear(feature_dim → d_model) + LayerNorm. Everything else (spatial encoder, positional embedding, transformer encoder, output MLP head) is byte-identical to SimpleSGT.

Parameter counts at matched hyperparameters:

Config SimpleSGT VanillaTransformer Δ (vanilla − gated)
d=128, h=4 362,609 214,769 −147,840 (−41%)
d=96, h=4 258,545 150,737 −107,808
d=64, h=4 164,721 94,897 −69,824

The GRN block costs ~40% of SimpleSGT's parameter count at d=128.

Registered as model family vanilla_transformer in run_kfold.py:_build_model. Tag pattern is identical to other family entries: vanilla_transformer_d<H>_h<HEAD>_L<L>.

9b. --vanilla flag separated from --families (045f246)

User wanted vanilla to be independently controllable. Pulled vanilla_transformer entries out of FAMILY_GRID into a dedicated VANILLA_GRID (two entries: d=64 and d=128, both h=4 L=1). New flags: --vanilla, --no-vanilla, --vanilla-only, parallel to --baselines / --families. Mutual-exclusion guards in main() updated so each *-only flag truly excludes the other groups.

9c. Finding — gating doesn't earn its keep at this scale

Config Params R² mean R² std Fold-0 R²
small_d128_h4_L1 (gated SGT) 363 k 0.170 0.062 +0.09
vanilla_transformer_d128_h4_L1 215 k 0.170 0.069 +0.11
Δ (vanilla − gated) −148 k +0.0001 +0.007 +0.02

At d=64 the picture is stronger for vanilla (R² 0.168 vs SGT 0.156 — vanilla wins on R² and is 70k params smaller).

Verdict: the GRN does not provide measurable benefit at the LUCAS data scale. Vanilla is smaller, equivalently accurate, slightly better on the Alpine fold. The single biggest re-framing of the paper falls out of this finding (see Phase 10).


10. Final-models / production-mapping pipeline (d160733, d5a0f1b)

Goal. After the spatial-CV sweep established evaluation findings, the rebuttal also needs production maps: each winning architecture trained on the FULL dataset (no spatial holdout — that's evaluation only) and applied to the Bavaria 1mil reference grid. Side-by-side comparison figure becomes the rebuttal's headline visual.

10a. Five new scripts under rebuttal/final_models/

Script Role
train_full.py Neural-network training on full data (95% train + 5% random monitor for best-state tracking — explicitly NOT spatial)
train_full_baselines.py RF / XGBoost training on full data; reuses extract_features_for_df from run_baselines.py
infer_bavaria.py Auto-dispatches between NN and tree paths based on checkpoint contents; runs over 1mil Bavaria grid for the requested year
submit_finals.py sbatch generator: for NN families, 4-GPU train + dependent 1-GPU infer; for tree models, 1-GPU combined train+infer
compare_maps.py Loads every map output, aligns on common grid, computes pairwise Pearson correlation + signed/abs differences, emits N-panel comparison figure

10b. Path resolution fix (d5a0f1b)

Initial commit hardcoded SOC_ROOT.parent / 'Weights-…/' for Model A checkpoint paths — worked on laptop, broke on cluster (/e/project1/scifi/fourel1/SGT/ has no Weights-… sibling).

Fixed: resolve via SOC_WEIGHTS_DIR from _paths.py. Added clear error message at load time pointing at the env-var fix, the rsync option, and the --checkpoint / --analysis-pkl CLI overrides — instead of the bare FileNotFoundError stack trace.

10c. Expected Slurm cost

Per-pipeline component Time Resources
NN train ~1 h 4 GPUs
NN infer (1M grid) ~1.5 h 1 GPU
Tree combined (train + infer) ~2 h 1 GPU

With 12 pipelines (6 architectures × 2 band variants — see Phase 13) and ≥3 concurrent Slurm slots: ~3 h wall clock.


11. Rebuttal-coverage scripts — the three gaps (db8bd4b)

After surveying rebuttal/, found that 23 of 26 Tier-2/3 action items already had scripts (bootstrap_cis.py, split_comparison.py, temporal_regression_corrected.py, extended_regression.py, multi_run_cv.py, residual_sd_analysis.py, nn_distances.py, figure7_replacement.py). Wrote the three missing ones.

11a. covariate_temporal_stats.py — R2.M5

Annual statistics for the 5 dynamic covariates (LAI, LST, MODIS_NPP, SoilEvaporation, TotalEvapotranspiration) at the 16,514 LUCAS sample locations across 2007–2023. Linear trend test per band. Output: covariate_temporal_trends.png + .md + .json.

Argument for the rebuttal: if covariates at sample locations are temporally stable, the +0.751 g/kg/yr SOC coefficient cannot be a real climate-driven trend the model detects in predictors — must be sampling bias.

11b. mc_dropout_uncertainty.py — R3.9 + R4.4

Loads Model A, runs N=30 MC dropout forward passes on the validation set, reports per-sample (mean, std, p05, p95, PI width, in-PI flag) and aggregate 90% PI coverage. Two-panel spatial map (MC mean + MC std).

Honest framing: noted that observed coverage < 0.85 indicates MC dropout under-dispersion (known property at moderate dropout rates per Gal & Ghahramani 2016); deep ensembles cited as the principled extension.

11c. annual_soc_maps.py — R2.M5

Model A inference over the 1mil grid at three target years: 2007 (start), 2015 (middle), 2023 (end). 2023−2007 difference map. Computes the model-implied annual rate.

Rebuttal value: if model-implied annual rate is far below the sample-distribution rate of +0.751 g/kg/yr, the temporal coefficient is empirically a sampling-bias artifact rather than a real signal the model detects.


12. Strategic rebuttal-framing discussions (no code)

Multiple back-and-forth discussions about how to present the substantively changed paper.

12a. Is this OK as a revision (vs fresh submission)?

User: "is it OK to return from revision with a totally different paper? because this is what happens?"

Verdict: yes, with diplomatic framing. The methodology improvements were reviewer-requested. The findings (gating doesn't help, +0.751 trend is sampling bias) emerged from the rigorous experiments. The dataset, study area, prediction target, and architecture family are unchanged. The substantive change is the framing, driven by the science.

Recommended:

  1. Short heads-up email to Budiman Minasny ~1 week before deadline
  2. Cover letter that leads with the diplomatic framing ("we conducted reviewer-requested experiments; they led us to refine the contribution; here's what changed")
  3. Three things explicitly retracted:
    • Chi-square loss component (became a no-op due to internal magnitude rescaling — honest acknowledgment is better than retraining)
    • +0.751 g/kg/yr temporal coefficient (reframed as sampling-distribution diagnostic)
    • The G in SGT (gated residual network — ablation shows it doesn't help at this scale; recommend the gateless variant)
  4. Title shift options ranked by aggressiveness; favored option 2: "Lightweight Transformers for High-Resolution Soil Organic Carbon Mapping: A Comparative Study Under Spatial Cross-Validation."

12b. Comparison with Padarian 2019 (canonical DSM-CNN paper)

User pasted Padarian et al. 2019 ("Using deep learning for digital soil mapping," SOIL journal) and asked how the SGT results compare.

Key context: Padarian reports R² ≈ 0.51–0.64 on topsoil under 90/10 random splits with bootstrap OOB. SGT reports R² ≈ 0.17 under 10-fold spatial CV with 1.2 km buffer.

Direct comparison is misleading because of evaluation protocol. Cited Roberts et al. 2017 (Ecography) + Ploton et al. 2020 (Nature Communications): spatial CV systematically compresses R² by 2–3× relative to random splits, with adequate buffer. Applying a 2.5× compression factor to Padarian's 0.51 gives a predicted spatial-CV R² of ~0.20 — exactly where SGT lands.

The two papers are at the same operational benchmark, just under different evaluation rigour. SGT additionally provides: honest spatial CV protocol, comparison against canonical baselines, parameter- efficiency (122k vs Padarian's ~unknown but likely 100k+ for the 2-conv multi-task CNN), 4× more training data.

12c. "Lightweight transformer" reframing

User: "basically this can be a study on how a lightweight transformer is the most versatile architecture on this type of problem"

Confirmed. Data supports this exactly:

Dimension Lightweight transformers (gated or vanilla) Heavy transformer Trees Tiny CNN
R² mean (oc150) 0.16–0.18 0.18 (≈ tied) 0.12–0.14 −0.76
All folds R² > 0 Yes (across configs) Yes No (fail Alpine) No
Fold-0 R² (Alpine extrapolation) +0.04 to +0.12 +0.07 −0.07 to −0.41 −0.74
Parameters 100k–400k 11.2 M n/a 27 k
Robust to max-OC cap (90/120/150) Yes Yes Worse at oc90 No
Robust to architectural sub-variants Yes (d=32→128, h=2/4, gated/vanilla) n/a (single config) n/a n/a
Robust to loss function (L1/MSE/composite_l2) Gated: yes; vanilla: mostly No (breaks on composite) n/a n/a
Band-extensible (O(1) in C) Yes (per-band 1×1 input) No (O(C²)) n/a (handcrafted features) Yes

Six axes of robustness for lightweight transformers; every other family fails at least one. That's "most versatile" empirically.

12d. RPIQ caveat

User asked how to explain low RPIQ (0.66–0.88 vs conventional "poor < 1.4" cutoff). Three caveats to surface in the rebuttal:

  1. RPIQ benchmarks (Bellon-Maurel et al. 2010) come from spectroscopic SOC studies under random splits on controlled lab samples — not directly comparable to spatial CV.
  2. RPIQ is cap-sensitive: same architecture goes from RPIQ=0.88 at max-OC=90 to RPIQ=0.70 at max-OC=150 because the heavy tail's contribution to RMSE outpaces its contribution to IQR.
  3. Within a fixed protocol and cap, RPIQ ordering matches R² ordering: SGT > SimpleTransformerV2 ≈ tied; both > all trees.

Recommended: footnote-style disambiguation, not a full paragraph; the absolute value reflects honest evaluation, not deficiency.

12e. "Should we make a bigger 3DCNN?"

Verdict: not worth it. The 3DCNN failure is architectural (the three pool-2 layers collapse 5×5×5 → 1×1×1), not capacity. Bigger channels won't fix the spatial-information loss. Leaving 3DCNN as "capacity-floor demonstration" in the table is actually useful — shows that "lightweight" alone isn't enough; you also need the right inductive bias. Fixing it could even hurt the story if a tuned 3DCNN matches SGT at smaller scale (would dilute the architectural- contribution claim).

Pre-emptive paragraph drafted for the rebuttal: "Our naive 3D-CNN baseline (Small3DCNN, 27 k parameters, three pool-2 layers) was not competitive (R² = −0.76) due to architectural mismatch: three successive 2×2×2 poolings reduce the 5×5×5 patch to a 1×1×1 representation, eliminating spatial information before the FC head. We retained this configuration as a capacity-floor reference; a redesigned 3D-CNN preserving spatial structure would be expected to reach the R² range of our tree-ensemble baselines (~0.10), still below SGT."

12f. SOTA framing

Five claims are publishable as-is:

  1. SGT outperforms standard tree-ensemble baselines under spatial CV.
  2. SGT is the only architecture with positive R² on every spatial fold.
  3. SGT is parameter-efficient (92× smaller than SimpleTransformerV2 at matched R²).
  4. SGT is band-extensible (O(1) in C vs O(C²) for SimpleTransformerV2).
  5. SGT under the SAME pipeline as every baseline — methodologically clean comparison.

"SOTA" without qualifiers is overreach (would invite "but did you compare against Padarian / Hengl / Wadoux?" reviewer attacks). Defensible scoped version:

"SGT is, to our knowledge, the only architecture tested under strict spatial CV that combines transformer-class accuracy with sub-200k- parameter efficiency and demonstrated extrapolation robustness on the Alpine regime."


13. 6-band vs 20-band ablation (21f44c4)

Last substantive change. User flagged that the 6 → 20 band expansion was not reviewer-requested and was substantive (different model inputs, different parameter scaling, different absolute R²). Needed to disentangle the band-expansion contribution from the architectural contribution.

13a. band_subsets.py — single source of truth

get_band_indices(name, full_list) returns indices into bands_list_order. band_suffix(name) returns '_6band' or '_20band' for auto-tagging.

Original 6 = {Elevation, LAI, LST, MODIS_NPP, SoilEvaporation, TotalEvapotranspiration} — the original-submission covariate set, sits at indices 0–5 of bands_list_order by construction (Phase 3a).

13b. --bands-list flag plumbed everywhere

Added to:

  • run_kfold.py_BandSubsetWrapper slices channel dim AFTER _NormalizingWrapper (so the project-wide 20-channel feature_means/ stds stay valid). _build_model uses len(band_indices) for input_channels.
  • run_baselines.py — 80-d feature vector is sliced to the relevant 24 columns when --bands-list=original_6 (4 stats per band × 6 bands). Cache file is shared across runs at the same max-OC; the slicing happens after cache load.
  • sweep_submit.py--bands-list forwarded to run_kfold and run_baselines; sweep_name auto-appends '_6band' so 6-band and 20-band sweeps don't collide.
  • train_full.py + train_full_baselines.py — flag forwarded; run_name auto-suffixed with _6band / _20band so checkpoints don't collide.
  • infer_bavaria.py — reads bands_list from saved checkpoint config and replays the same slicing at inference time (both NN and tree paths).
  • submit_finals.py--bands-lists CSV flag default 'full_20,original_6' runs both variants of every config. Doubles the work (8 NN pipelines + 4 tree pipelines per band variant = 12 total).
  • compare_maps.pyDEFAULT_RUNS auto-expanded across both band suffixes.

13c. Rationale documented in the cover letter

Three converging justifications for the band expansion:

  1. scorpan-model coverage (McBratney et al. 2003): original 6 covered c, o, r; revised 20 adds s (Clay, Sand, pH, BulkDensity, CEC) + densifies c (Precipitation, AirTemperature, SoilMoisture, SnowDepth) and r (Slope, Aspect, TWI). Soil-property dimension was missing from the original submission.
  2. Empirical band-extensibility demonstration: 6→20 band ratio confirms architecture's O(1) parameter scaling (SGT +1.2%) vs SimpleTransformerV2's O(C²) scaling (+548%). Not a hypothesis anymore — an empirical result on the actual data.
  3. Alignment with operational DSM standards: SoilGrids 2.0 uses 400+ covariates; Padarian 2019 used 5 (acknowledged limitation); 20 is modest by current standards.

Citation Minasny will appreciate: he is the M in McBratney/Mendonça/ Minasny 2003. Original scorpan author.

13d. Cost

NN training compute doubles: 8 NN jobs × 2 band variants = 16 (was 8 before this phase). Tree pipelines: 4 tree jobs × 2 = 8 (was 4). Total 24 sbatch jobs for the full final-models comparison matrix. ~6–7 h wall clock at 4 concurrent slots.


Summary — final state of the pipeline

Spatial-CV evaluation pipeline (rebuttal/gpu_experiments/spatial_kfold/)

Component Purpose
run_folds_parallel.py Slot-based orchestrator, --folds-per-gpu packing
run_kfold.py Per-fold training; KDE/qcut sampler; D4 augmentation; composite loss; band-subset support
run_baselines.py RF/XGBoost on per-band statistics; same fold geometry
sweep_submit.py Sbatch generator with three independent grids: SGT (DEFAULT_GRID), siblings (FAMILY_GRID), vanilla ablation (VANILLA_GRID), tree baselines (BASELINE_GRID)
sweep_summarize.py Recursive ranking across sweep namespaces
inspect_sweep.py Per-epoch trajectory diagnostic (originated the best-state bug discovery)
band_subsets.py --bands-list resolution helper

Production-mapping pipeline (rebuttal/final_models/)

Component Purpose
train_full.py NN training on full data, no spatial holdout
train_full_baselines.py RF/XGBoost on full data
infer_bavaria.py 1mil-grid inference, auto-dispatches NN/tree
submit_finals.py Sbatch generator; --bands-lists CSV defaults to both variants
compare_maps.py Cross-architecture comparison figure (auto-expanded across band variants)
README.md Workflow doc

Rebuttal analyses (rebuttal/)

Script Reviewer addressed
bootstrap_cis.py R1.3, R3.6 (bootstrap CIs)
split_comparison.py R3.3 (random vs spatial split distributional stats)
temporal_regression_corrected.py R1.2, R3.5 (temporal coefficient sensitivity)
extended_regression.py R3.5 (land-use multivariate regression)
multi_run_cv.py R1.3, R3.6 (repeated CV evidence)
residual_sd_analysis.py R3-mod11 (training residual SD anomaly)
nn_distances.py R2.M3 (nearest-neighbour distance distribution)
figure7_replacement.py R2-m2 (2D replacement for the 3D scatterplot)
covariate_temporal_stats.py R2.M5 part 1 (covariate temporal stability)
mc_dropout_uncertainty.py R3.9, R4.4 (uncertainty quantification)
annual_soc_maps.py R2.M5 part 2 (multi-year inference maps)

Architecture comparison table — empirical findings (oc150)

Model Params R² mean R² std Fold-0 R² All folds R² > 0?
VanillaTransformer (proposed, d=128) 215 k 0.170 ± 0.07 0.069 +0.11 Yes
SimpleSGT (gated, d=128, ablation reference) 363 k 0.170 ± 0.06 0.062 +0.09 Yes
SimpleSGT (d=48, h=2) 122 k 0.178 ± 0.09 0.089 +0.04 Yes
SimpleTransformerV2 (canonical heavyweight) 11.2 M 0.183 ± 0.09 0.087 +0.07 Yes
CNNLSTM (d=64, h=4) 93 k 0.090 ± 0.10 0.100 −0.15 No
3DCNN (Small3DCNN) 27 k −0.76 ± 0.35 0.354 −0.74 No
Random Forest (best) n/a 0.135 ± 0.10 0.100 −0.10 No
XGBoost (best) n/a 0.140 ± 0.15 0.155 −0.26 No

Commit timeline

SHA Phase Title
feb2a8d 1 parallel orchestrator: --folds-per-gpu
fb58def 2 rebuttal kfold: defensible cap, KDE sampler, augmentation, stratified report
25ae836 3a SGT config: extend bands_list_order 6 → 20
6dd1812 5a sweep: architecture grid via Slurm
029a8e5 5a sweep: add SimpleSGT rescue variants
6a97d2f 5d inspect_sweep diagnostic
b5c1cac 4 train.py: clone tensors when capturing best_model_state (critical fix)
41f7e34 5a sweep: pivot grid to SimpleSGT neighborhood
ef9930d 6a baselines: GPU XGBoost + RF on same 10-fold splits
6afb8d3 6b sweep_submit: bundle RF + XGBoost baselines
eb90079 5c sweep: --sweep-name namespacing
a94941d 8a composite L1/MSE + Pearson chi-square loss
03c1e60 8b composite loss redo: explicit α/β weights
b3b6814 7 3DCNN / CNNLSTM / SimpleTransformer under SGT's pipeline
af1c6b4 8c sweep_submit: plumb composite loss flags
db8bd4b 11 covariate temporal stats + MC dropout UQ + annual SOC maps
d5a0f1b 10b rebuttal scripts: SOC_WEIGHTS_DIR path fix
d160733 10a final_models: production-mapping pipeline
1f3a3e1 9a vanilla_transformer: SimpleSGT minus the GRN
045f246 9b sweep_submit: split vanilla into own grid + flag
21f44c4 13 band_subsets: --bands-list flag everywhere

Outstanding / next steps

Code

  1. Smoke-test the 6-band SGT pipeline on cluster before launching the full 24-job matrix. Single command:

    python rebuttal/final_models/train_full.py \
        --run-name smoketest_sgt_6band --bands-list original_6 \
        --model-family sgt --model-size small --hidden_size 64 \
        --num_heads 2 --num_layers 1 --dropout_rate 0.5 \
        --lr 1e-4 --lr-scheduler cosine --lr-min 1e-6 \
        --loss_type l1 --target_transform log --max-oc 150 \
        --per-gpu-batch-size 256 --effective-batch-size 256 \
        --num-epochs 2 --seed 42 --augment-train
    

    Should print Model: SimpleSGT family=sgt (162,705 trainable params).

  2. Run the full 24-job matrix once smoke-test passes:

    python rebuttal/final_models/submit_finals.py
    
  3. After everything lands, generate the rebuttal-ready comparison figure:

    python rebuttal/final_models/compare_maps.py
    

Writing

  1. Cover letter with the diplomatic framing (Phase 12a structure):
    • Opening paragraph acknowledging scope-of-revision and offering editorial flexibility
    • Three explicit retractions (chi-square loss, +0.751 trend, gating)
    • Per-reviewer point-by-point response
  2. Heads-up email to Budiman Minasny ~1 week before deadline (around 2026-05-22).
  3. Title shift: option 2 ("Lightweight Transformers for High-Resolution SOC Mapping…").
  4. Tier-1 editorial items still pending from the action plan: T1.8 (Figure 14 → Table), T1.9–T1.14, T1.17, T1.18, T1.22–T1.26.

Strategic

  • Don't run more architecture experiments. The 24-job final-mapping matrix + the spatial-CV sweep is enough to support every claim.
  • Drop the chi-square loss component from the abstract; keep as supplementary ablation.
  • Lead with the parameter-efficiency + extrapolation-robustness combination. That's the rebuttal-winning pair.

Log maintained on bestrun-bands. Last updated 2026-05-19.