Does SAM Help a Small MLP Under Label Noise? A Controlled CPU Study Against SGD and Weight Decay Quartz-46Y Stemma seed corpus https://github.com/mihir-chauhan/research-harness-papers/tree/main/papers/sam-vs-sgd-label-noise-mlp Abstract—We compare SGD, SGD with weight decay behaviour under label noise is not simply a flatness effect (SGD+WD), their validation-selected early-stopped variants, [5], [6]. Networks that can fit random labels [7] make their variants with twice the steps (the gradient-evaluation label noise a natural stress test: an optimiser must avoid count of SAM) and sharpness-aware minimisation (SAM) on a three-layer MLP trained on scikit-learn digits with symmetric memorising the flipped labels. label noise (0, 20, 40%) and on a noisy two-spirals task, using Closest prior work and what this study adds. Foret five seeds and a fixed outer digits test set that no tuning et al. [1] report SAM’s robustness to label noise; Baek run uses. Learning rate, ρ and weight decay are selected on et al. [5] analyse it, find that the gains peak with early a noisy validation split with separate tuning seeds, with equal- stopping, and decompose it into a logit and a Jacobian sized ρ and weight-decay grids and a shared learning-rate grid. This is a small-scale reproduction of known effects, not a new effect; Jiang et al. [3] and Andriushchenko et al. [4] mechanism. SAM clearly beats plain SGD under noise (clean show that sharpness-type measures correlate poorly with test accuracy 0.951 vs 0.865 at 20% noise and 0.924 vs 0.727 at generalisation. We do not identify a mechanism or a 40%), and most of this gain is also obtained by tuned weight finding beyond these works. This paper is a small-scale decay or by early stopping, which SAM still beats by 0.023 and reproduction of those effects (a 3-layer width-128 MLP 0.035 over SGD+WD at 20% and 40% noise (positive in all five seeds). Of the 24 Holm-corrected paired comparisons, the on 600 digits images, and a two-spirals task), and its margin over SGD+WD at 20% noise survives (Holm p = 0.029); only addition is a controlled comparison at this scale in the margin over SGD+WD at 40% noise (Holm p = 0.055) and which SAM is set against tuned weight decay, validation- the margins over early-stopped SGD, early-stopped SGD+WD selected early stopping and baselines with SAM’s number and SGD+WD with twice the steps at both noise levels do not of gradient evaluations, with hyper-parameters selected reach 0.05 after correction (smallest Holm p among the latter 0.064). On two-spirals SAM does not help. On noisy digits without any use of the test data. accuracy rises with the radius ρ up to ρ = 0.5 and collapses We ask three questions at a scale that fits a laptop CPU, toward chance at ρ = 0.7 and ρ = 1.0; a random-direction with equal-sized validation-selected grids for SAM’s ρ and perturbation of the same radius behaves like SGD, and SAM the weight decay λ (8 values each) and a learning-rate combined with the separately selected weight decay collapses grid (3 values) for every system: H1: does SAM improve to chance. A fixed-norm loss-increase sharpness is only weakly or inconsistently correlated with the generalisation gap (pooled clean test accuracy over SGD and over SGD with tuned Spearman −0.22 to −0.05 over the two sharpness measures and weight decay, early stopping or twice the steps, under label two gaps, negative on spirals). noise? H2: how sensitive is SAM to the neighbourhood Index Terms—sharpness-aware minimisation, label noise, size ρ, and is there an interior optimum? H3: does a weight decay, sharpness, generalisation gap, small MLP measured sharpness (loss increase under a fixed-norm weight perturbation) track the generalisation gap? I. Introduction Our contributions are modest and empirical: (i) a Sharpness-aware minimisation (SAM) [1] trains on the seven-system comparison (SGD, SGD+WD, SAM, early- worst-case loss within a small ball around the weights, stopped SGD and SGD+WD, and SGD and SGD+WD and has been reported to improve generalisation and, in with twice the steps) on digits with 0/20/40% symmetric particular, to be robust to noisy labels. This is usually label noise and on a two-spirals task, with 5 evaluation motivated by the idea that flat minima generalise better seeds and hyper-parameter selection on separate tuning [2], yet the evidence that sharpness explains generalisation seeds and a held-out outer test set; (ii) a ρ sweep, a weight- is mixed [3], [4], and recent analyses suggest that SAM’s decay sweep and two ablations (random-direction per- turbation, SAM+WD); (iii) a sharpness–gap correlation Quartz-46Y is the codename of an autonomous study, not a person. analysis over 380 runs. Our headline finding is that SAM Produced by the Stemma autonomous AI research pipeline; the topic beats plain SGD by a wide margin under noise and keeps was chosen to cover the field. Every reported number comes from logged runs in the linked repository and every reference was checked a smaller positive margin over every stronger baseline, against arXiv, Crossref, DataCite or OpenAlex. but that only one of the margins over those baselines survives multiple-comparison correction, and that fixed- and gt replaces the gradient in the momentum update radius sharpness does not track the gap across optimisers. above (no weight decay, λ = 0). The norm is global over all parameters. A step costs two forward/backward passes. II. Related Work Early-stopped and 2x-step baselines. SGD+ES and SAM and variants. SAM [1] minimises max∥ϵ∥≤ρ L(w+ϵ) SGD+WD+ES are SGD and SGD+WD in which the with a one-step approximation of the inner maximum. reported model is the checkpoint with the highest accuracy ASAM [8] makes the neighbourhood adaptive to pa- on the noisy validation labels (first such epoch). SGD 2x rameter scale, addressing the dependence of fixed-radius and SGD+WD 2x are SGD and SGD+WD trained for sharpness on re-parameterisation, and ESAM [9] reduces twice the epochs, which equals SAM’s number of gradient SAM’s cost of two gradient evaluations per step. We evaluations. reimplement only the original SAM; the scale dependence Ablations. SAM random direction: ϵ̂t = ρ u/∥u∥2 with that ASAM addresses matters for our sharpness measure u ∼ N (0, I), same radius. SAM+WD: SAM with λ > 0. (Sec. VII). Sharpness and gap measures. At the end of training Understanding SAM. Andriushchenko and Flammarion we measure, on the full noisy training set with a fixed [6] analyse the implicit bias of SAM (diagonal linear perturbation norm r = 0.5 for all systems, networks, plus convergence results) and argue that PAC-   ∇L(w) Bayes and flat-minima explanations are incomplete. Wen Sadv = L w + r ∥∇L(w)∥ − L(w), (2) et al. [10] pin down which notion of sharpness SAM X 20   actually regularises. For label noise specifically, Baek et 1 Srand = 20 L w + r ∥uukk ∥ − L(w). (3) al. [5] report that SAM’s largest gains occur under label k=1 noise, that the peak occurs with early stopping rather than The generalisation gap is gap_acc = acctrain, noisy labels − at convergence, and decompose the robustness into a logit acctest, clean (also gap_loss = Ltest − Ltrain ). Note that effect (up-weighting clean examples) and a Jacobian effect. against noisy labels a model that does not memorise has We report early-stopped SGD and SGD+WD baselines a train accuracy below the clean test accuracy, so the (checkpoint chosen on noisy validation accuracy) but not gap becomes negative. memorised is the fraction of flipped early-stopped SAM. training samples predicted with their (wrong) noisy label. Sharpness and generalisation. Keskar et al. [2] asso- ciated large-batch training with sharp minima and a IV. Experimental Setup larger generalisation gap; Jiang et al. [3] compared over 40 complexity measures across thousands of networks; Tasks. digits: scikit-learn digits (1797 images, 64 fea- Andriushchenko et al. [4] report that (adaptive) sharpness tures scaled to [0, 1]). A fixed outer test set of 897 does not correlate well with generalisation across modern images (chosen once, the same for every run, tuning runs settings, but rather with training parameters such as the included) is held out; the remaining 900 images are split learning rate. Zhang et al. [7] showed that standard net- by the seed into 600 train and 300 validation images. Sym- works fit random labels, which motivates our measurement metric label noise η ∈ {0, 0.2, 0.4} is applied to train and of how many flipped labels each optimiser memorises. validation labels; test labels are clean. spirals: a two-class, 1.5-turn spiral with Gaussian input noise, 400/200/400 III. Method train/val/test points from the same generator (fresh per seed), η = 0.2. Task names are digits_nη and spirals_n0.2. Model and data. A ReLU MLP fw with two hid- Systems and training. Momentum 0.9, cosine decay den layers of width 128 (digits: 64–128–128–10; spi- of the learning rate to 0, batch 100, no augmentation, rals: P 2–128–128–2) is trained with cross-entropy L(w) = 1 for every system. SGD, SGD+WD and SAM train for n i ℓ(fw (xi ), ỹi ) on labels ỹi that were flipped with 150 epochs (900 steps for digits) and report the final- probability η to a uniformly chosen other class. epoch model. Four baselines were added in this revision: SGD (reimplemented, reference). With momentum µ = SGD+ES and SGD+WD+ES train for the same 150 0.9 and learning rate ηt (cosine decay), vt+1 = µvt + epochs and report the checkpoint (epoch) with the highest gt , wt+1 = wt − ηt vt+1 , where gt = ∇w LBt (wt ) is the noisy validation accuracy (first such epoch); SGD 2x and minibatch gradient. SGD+WD 2x train for 300 epochs and report the final SGD+WD. The same update with gt = ∇w LBt (wt ) + model. Gradient evaluations per digits run: 900 for SGD, λwt (L2 penalty λ2 ∥w∥2 ). SGD+WD, SGD+ES and SGD+WD+ES; 1800 for SAM SAM (reimplemented). Following [1], the inner maxi- (two per step) and for SGD 2x and SGD+WD 2x, so mum is approximated at each step by one normalised- SAM and the 2x baselines have the same count. SAM’s gradient ascent step, ablations also use two per step. The code is the same for ∇w LBt (wt ) all systems (method/run.py); the sharpness is measured ϵ̂t = ρ , gt = ∇w LBt (w + ϵ̂t ) w=w , with identical settings for all, on the reported model (the ∥∇w LBt (wt )∥2 t (1) selected checkpoint for the +ES systems). Hyper-parameter selection. Every system has a learning TABLE I rate chosen from {0.05, 0.1, 0.2} (3 values). SAM addi- Selected hyper-parameters per system and task (learning rate, then ρ for SAM or λ for the weight-decay systems), from 3 tuning seeds. tionally has ρ ∈ {0.02, 0.05, 0.1, 0.2, 0.3, 0.5, 0.7, 1.0} (8 values), the weight-decay systems λ ∈ {10−4 , 10−3 , 3 · system digits_n0.0 digits_n0.2 digits_n0.4 spirals_n0.2 10−3 , 6·10−3 , 10−2 , 2·10−2 , 3·10−2 , 5·10−2 } (8 values); the SGD 0.2 0.05 0.05 0.2 grids cross, so SAM and SGD+WD each get 24 candidates SGD+WD 0.2, 0.003 0.2, 0.02 0.05, 0.01 0.2, 0.0001 SAM 0.05, 0.3 0.05, 0.5 0.05, 0.5 0.2, 0.02 per task, SGD 3, and the 2x variants are tuned separately SGD+ES 0.2 0.05 0.05 0.2 with the same grids at 300 epochs. The +ES systems SGD+WD+ES 0.2, 0.003 0.2, 0.02 0.1, 0.006 0.2, 0.0001 SGD 2x 0.2 0.2 0.05 0.1 are tuned on the best-validation-epoch accuracy of the SGD+WD 2x 0.2, 0.003 0.2, 0.02 0.1, 0.02 0.1, 0.0001 same tuning runs as SGD and SGD+WD. Each candidate was run on 3 tuning seeds (100–102; 936 runs in total) and the candidate with the highest mean noisy validation H1 (SAM beats SGD and SGD+WD under noise): accuracy was chosen (ties: earlier grid position; Table I). supported against SGD; against the stronger baselines Selection reads only validation accuracy: the outer digits positive in every seed on noisy digits, but after Holm test images are never in a tuning train or validation split correction established only against SGD+WD at 20% (the test accuracy of tuning runs is logged but not read noise. Without noise (digits_n0.0) SGD, SGD+WD and by the selection), and the spirals data are generated fresh SAM reach 0.965, 0.965 and 0.969; the SAM margin over per seed. The ablation SAM+WD reuses SAM’s selected SGD (0.0033) has paired p = 0.230 and Welch p = 0.554, learning rate and ρ and SGD+WD’s selected λ, and was i.e. it is not distinguishable from zero. At 20% and 40% not tuned jointly. The ρ and λ sweeps run the other grid noise plain SGD memorises most of the flipped labels values at the selected learning rate of SAM and SGD+WD (memorised 0.558 and 0.602 in Table II) and drops to 0.865 respectively. and 0.727; SAM reaches 0.951 and 0.924 and memorises far Evaluation. Seeds 0–4 (5 seeds; the seed fixes the fewer (0.046 at 20%), with differences of 0.086 and 0.197 train/validation split, noise, initialisation and batch order, (paired p = 1.0 × 10−4 and 3.4 × 10−5 ; Holm p = 0.002 so seeds are paired across systems; on digits all seeds share and 0.001). the same outer test images, so the test-set sampling error Stronger baselines. Tuned SGD+WD reaches 0.928 and is common to all runs). The main group has 140 runs 0.889, early-stopped SGD 0.924 and 0.882 (best-validation (ρ and λ sweeps: 140 and 140 runs, the selected value epoch on average 27.0 and 32.6 of 150), early-stopped coming from the main group; ablation group: 40 runs). SGD+WD 0.922 and 0.894, and SGD+WD with twice the Statistical tests are Welch and paired t-tests on the 5 steps 0.929 and 0.883. Early stopping and weight decay per-seed test accuracies (rh compare); with n = 5 they thus each recover most of SGD’s loss under noise, and have little power. The registered tests are uncorrected; training plain SGD for twice the steps does not help: Table III also lists Holm-adjusted paired p-values over SGD 2x reaches 0.832 and 0.644, below SGD, with all its 24 comparisons (4 tasks, 6 baselines). The Spearman flipped labels memorised. SAM’s margins over SGD+WD correlations, the Holm-adjusted p-values and the per- are 0.023 at 20% noise (paired p = 0.001, Welch p = 0.025) seed differences are computed from the logged runs by and 0.035 at 40% (paired p = 0.003, Welch p = 0.0003); experiments/derive2.py and logged as 38 analysis rows the per-seed differences are 0.025, 0.016, 0.022, 0.033, (group derived_v2) of the run registry. An earlier version 0.020 at 20% and 0.043, 0.038, 0.017, 0.029, 0.046 at 40%, of this study selected hyper-parameters on tuning seeds all positive. Against early-stopped SGD, early-stopped that re-split all 1797 images, so its digits tuning images SGD+WD and SGD+WD 2x the margins at 20% and overlapped the evaluation test images; all numbers in 40% noise are 0.027 and 0.041, 0.029 and 0.030, and this paper come from the protocol above, and the earlier 0.022 and 0.041, with uncorrected paired p-values between runs (groups tune, main, sweep_rho, sweep_wd, abl_sam, 0.0042 and 0.012 for early-stopped SGD (Table III). With derived) remain in the registry but are not used. Holm correction over the 24 paired tests of Table III, the Compute. CPU only (no GPU), PyTorch, 2 threads per margin over SGD+WD at 20% noise remains below 0.05 run, on an Apple M1 Pro laptop; the host name recorded (0.029), but the margin over SGD+WD at 40% noise does in each registry row (field host) is a campus-network name not (0.055), nor do the margins over early-stopped SGD and does not identify the hardware. Cost is accounted in (0.067 and 0.150), early-stopped SGD+WD (0.064 and gradient evaluations (above); wall-clock times are logged 0.098) and SGD+WD 2x (0.064 and 0.125) at 20% and but are not reported, because they are not reproducible. 40% noise. SAM’s advantage over the stronger baselines Code, logs and the run registry are in the repository. at noisy digits is therefore positive in every seed but, with n = 5 and 24 comparisons, statistically established against V. Results one of them only. Weight decay alone removes most of the Table II gives the main results (mean ± std over 5 seeds) damage of label noise at this scale: SGD+WD memorises for the seven systems and Table III the paired comparisons 0.025 of flipped labels at 20% noise. of SAM against each of the six baselines on test accuracy. Where SAM fails. On two-spirals (20% noise) every TABLE II Main results, mean ± std over 5 seeds; final-epoch model, except SGD+ES and SGD+WD+ES (best-validation checkpoint). gap_acc is noisy-train accuracy minus clean test accuracy; memorised is the fraction of flipped training labels fitted; sharp_adv is the loss increase after one normalised-gradient step of norm 0.5; sharp_rand is the mean loss increase over 20 random directions of the same norm, printed in scientific notation; all of them are measured on the reported model. Method Task test_acc gap_acc memorised sharp_adv sharp_rand weight_norm SGD digits_n0.0 0.965 ± 0.009 0.035 ± 0.009 0.000 ± 0.000 0.0005 ± 0.0000 4.51 × 10−6 ± 1.8 × 10−6 18.82 ± 0.69 SGD+WD digits_n0.0 0.965 ± 0.008 0.035 ± 0.008 0.000 ± 0.000 0.0198 ± 0.0002 2.53 × 10−4 ± 4.1 × 10−5 10.16 ± 0.08 SAM digits_n0.0 0.969 ± 0.008 0.031 ± 0.008 0.000 ± 0.000 0.0091 ± 0.0032 2.40 × 10−5 ± 7.1 × 10−6 16.90 ± 0.09 SGD+ES digits_n0.0 0.963 ± 0.007 0.036 ± 0.007 0.000 ± 0.000 0.2961 ± 0.2036 1.33 × 10−5 ± 1.4 × 10−5 18.26 ± 0.48 SGD+WD+ES digits_n0.0 0.962 ± 0.005 0.038 ± 0.005 0.000 ± 0.000 0.8809 ± 0.2415 1.67 × 10−4 ± 1.3 × 10−4 11.03 ± 1.11 SGD 2x digits_n0.0 0.966 ± 0.008 0.034 ± 0.008 0.000 ± 0.000 0.0003 ± 0.0000 2.80 × 10−6 ± 7.6 × 10−7 19.05 ± 0.74 SGD+WD 2x digits_n0.0 0.967 ± 0.006 0.033 ± 0.006 0.000 ± 0.000 0.0199 ± 0.0001 2.81 × 10−4 ± 4.4 × 10−5 10.04 ± 0.07 SGD digits_n0.2 0.865 ± 0.017 0.048 ± 0.024 0.558 ± 0.090 0.0792 ± 0.0204 2.95 × 10−3 ± 1.9 × 10−4 17.54 ± 0.44 SGD+WD digits_n0.2 0.928 ± 0.014 −0.143 ± 0.026 0.025 ± 0.015 0.0986 ± 0.0014 9.12 × 10−4 ± 1.3 × 10−4 7.10 ± 0.09 SAM digits_n0.2 0.951 ± 0.013 −0.142 ± 0.027 0.046 ± 0.029 0.0614 ± 0.0041 3.24 × 10−4 ± 4.9 × 10−5 15.11 ± 0.28 SGD+ES digits_n0.2 0.924 ± 0.016 −0.138 ± 0.021 0.024 ± 0.018 0.8787 ± 0.2559 7.68 × 10−4 ± 1.2 × 10−4 12.51 ± 0.42 SGD+WD+ES digits_n0.2 0.922 ± 0.016 −0.144 ± 0.026 0.021 ± 0.012 0.6396 ± 0.1632 6.37 × 10−4 ± 3.5 × 10−4 7.07 ± 0.07 SGD 2x digits_n0.2 0.832 ± 0.018 0.168 ± 0.018 1.000 ± 0.000 0.0018 ± 0.0007 4.37 × 10−5 ± 1.1 × 10−5 31.33 ± 0.55 SGD+WD 2x digits_n0.2 0.929 ± 0.016 −0.143 ± 0.027 0.025 ± 0.015 0.0986 ± 0.0010 1.09 × 10−3 ± 1.6 × 10−4 7.15 ± 0.11 SGD digits_n0.4 0.727 ± 0.020 0.108 ± 0.030 0.602 ± 0.037 0.1259 ± 0.0618 4.68 × 10−3 ± 1.9 × 10−4 18.22 ± 0.10 SGD+WD digits_n0.4 0.889 ± 0.010 −0.288 ± 0.013 0.053 ± 0.007 0.0627 ± 0.0023 1.69 × 10−3 ± 6.4 × 10−5 7.82 ± 0.16 SAM digits_n0.4 0.924 ± 0.009 −0.320 ± 0.010 0.032 ± 0.008 0.0853 ± 0.0061 3.02 × 10−4 ± 4.7 × 10−5 13.08 ± 0.32 SGD+ES digits_n0.4 0.882 ± 0.026 −0.277 ± 0.039 0.066 ± 0.038 0.8847 ± 0.3385 8.96 × 10−4 ± 3.1 × 10−4 12.30 ± 0.79 SGD+WD+ES digits_n0.4 0.894 ± 0.010 −0.294 ± 0.022 0.047 ± 0.023 0.5928 ± 0.1708 6.98 × 10−4 ± 2.4 × 10−4 8.92 ± 0.24 SGD 2x digits_n0.4 0.644 ± 0.024 0.356 ± 0.024 1.000 ± 0.000 0.0423 ± 0.0117 1.43 × 10−3 ± 1.0 × 10−4 25.75 ± 0.25 SGD+WD 2x digits_n0.4 0.883 ± 0.012 −0.301 ± 0.003 0.032 ± 0.005 0.0838 ± 0.0014 1.27 × 10−3 ± 1.1 × 10−4 6.27 ± 0.10 SGD spirals_n0.2 0.917 ± 0.023 −0.142 ± 0.016 0.099 ± 0.031 0.0736 ± 0.0567 9.38 × 10−4 ± 1.5 × 10−4 13.08 ± 0.49 SGD+WD spirals_n0.2 0.915 ± 0.023 −0.139 ± 0.022 0.107 ± 0.038 0.0633 ± 0.0401 8.89 × 10−4 ± 1.3 × 10−4 12.58 ± 0.50 SAM spirals_n0.2 0.915 ± 0.026 −0.139 ± 0.023 0.105 ± 0.038 0.0543 ± 0.0264 7.13 × 10−4 ± 1.3 × 10−4 12.94 ± 0.39 SGD+ES spirals_n0.2 0.911 ± 0.032 −0.147 ± 0.025 0.092 ± 0.020 0.3118 ± 0.1148 3.40 × 10−4 ± 2.3 × 10−4 12.49 ± 0.61 SGD+WD+ES spirals_n0.2 0.915 ± 0.021 −0.144 ± 0.019 0.087 ± 0.033 0.4019 ± 0.1014 2.80 × 10−4 ± 3.7 × 10−4 12.23 ± 0.50 SGD 2x spirals_n0.2 0.919 ± 0.018 −0.137 ± 0.017 0.114 ± 0.049 0.0482 ± 0.0138 1.34 × 10−3 ± 2.6 × 10−4 13.09 ± 0.57 SGD+WD 2x spirals_n0.2 0.917 ± 0.018 −0.138 ± 0.020 0.104 ± 0.051 0.0679 ± 0.0395 1.32 × 10−3 ± 2.3 × 10−4 12.55 ± 0.57 TABLE III than at the selected ρ = 0.02 there (Table IV: 0.823 at Test accuracy of SAM minus baseline, with Welch and paired t-test ρ = 0.2, 0.685 at ρ = 0.3 and 0.518, i.e. chance, at ρ = 0.5). p-values (5 seeds, uncorrected), and the Holm-adjusted paired p over the 24 rows. On this task SAM gives no measurable gain, so H1 does not hold there. task vs diff Welch p paired p Holm p digits_n0.0 digits_n0.0 SGD SGD+WD 0.0033 0.0033 0.554 0.516 0.230 0.023 1.000 0.277 H2 (interior optimum in ρ, larger and wider useful range digits_n0.0 digits_n0.0 SGD+ES SGD+WD+ES 0.0054 0.0069 0.304 0.145 0.049 0.025 0.488 0.277 under noise): partly supported. Table IV and Fig. 1 show digits_n0.0 SGD 2x 0.0025 0.649 0.130 1.000 the sweep. On noise-free digits accuracy rises from 0.959 digits_n0.0 SGD+WD 2x 0.0020 0.670 0.221 1.000 digits_n0.2 SGD 0.086 2.43 × 10−5 1.01 × 10−4 2.12 × 10−3 (ρ = 0.02) to 0.969 at the selected ρ = 0.3 (0.968 at digits_n0.2 SGD+WD 0.023 0.025 1.43 × 10−3 0.029 digits_n0.2 SGD+ES 0.027 0.019 4.20 × 10−3 0.067 0.5), then falls to 0.932 at 0.7 and chance-level (0.115) at digits_n0.2 SGD+WD+ES 0.029 0.013 3.59 × 10−3 0.064 1.0, an interior optimum, but the gain over SGD (0.965 digits_n0.2 SGD 2x 0.119 4.58 × 10−6 8.02 × 10−7 1.93 × 10−5 digits_n0.2 SGD+WD 2x 0.022 0.043 3.55 × 10−3 0.064 ± 0.009) is within one SGD seed standard deviation. On digits_n0.4 SGD 0.197 3.01 × 10−6 3.37 × 10−5 7.41 × 10−4 digits_n0.4 SGD+WD 0.035 3.39 × 10−4 2.88 × 10−3 0.055 noisy digits accuracy rises monotonically up to ρ = 0.5 digits_n0.4 digits_n0.4 SGD+ES SGD+WD+ES 0.041 0.030 0.021 1.31 × 10−3 0.012 6.56 × 10−3 0.150 0.098 (from 0.874 at ρ = 0.02 to 0.951 at 20% noise, from 0.742 digits_n0.4 SGD 2x 0.279 2.17 × 10−6 1.40 × 10−5 3.21 × 10−4 to 0.924 at 40%; ρ = 0.3 gives 0.944 and 0.897) and then digits_n0.4 SGD+WD 2x 0.041 4.85 × 10−4 8.95 × 10−3 0.125 spirals_n0.2 SGD −0.0020 0.901 0.587 1.000 falls at ρ = 0.7 (0.598 and 0.248) and to chance at ρ = 1.0 spirals_n0.2 SGD+WD 0.0000 1.000 1.000 1.000 spirals_n0.2 SGD+ES 0.0040 0.833 0.500 1.000 (0.105 and 0.097). The best grid value thus shifts from spirals_n0.2 SGD+WD+ES −0.0005 0.974 0.871 1.000 spirals_n0.2 SGD 2x −0.0040 0.785 0.450 1.000 0.3 without noise to 0.5 with noise, as hypothesised, but spirals_n0.2 SGD+WD 2x −0.0020 0.891 0.654 1.000 the useful range is not wider under noise: the noisy-digits optimum is bracketed by 0.3 and 0.7 on this grid, and the selected value sits one grid step below a collapse, so we system fits only a small fraction of the flipped training cannot say how close to the cliff it is. On spirals accuracy labels (memorised 0.105 for SAM, 0.099 for SGD and 0.107 is flat for ρ ≤ 0.05 (0.915 at ρ = 0.02, 0.917 at 0.05) and for SGD+WD, against 0.558 for SGD on digits at the then falls to chance at ρ ≥ 0.5, so no interior optimum is same noise rate) and the systems are indistinguishable: observed. Nothing is claimed beyond these 8 grid points. SAM 0.915 vs SGD 0.917 and SGD+WD 0.915 (paired The weight-decay sweep (Table V) has the same shape p = 0.587 and 1.000). From ρ = 0.2 on, SAM is worse on noisy digits: accuracy at the selected learning rate is digits n0.0 digits n0.2 digits n0.4 spirals n0.2 1.0 1.0 0.9 0.8 0.8 0.8 0.8 test acc 0.6 0.6 0.6 0.7 0.4 0.4 0.4 SGD 0.6 SGD+WD (sel.) 0.2 0.2 0.2 SAM 0.5 10−1 10 0 10−1 10 0 10−1 10 0 10−1 100 ρ ρ ρ ρ Fig. 1. Test accuracy (mean ± std, 5 seeds) versus ρ for SAM at its selected learning rate; dashed: SGD, dotted: SGD+WD at its selected λ. At ρ = 1.0 digits runs end at near-chance accuracy (task means 0.097–0.115). TABLE IV TABLE VI Test accuracy (mean over 5 seeds) of SAM by ρ (columns) at Spearman correlation of sharpness (rand: random direction, adv: SAM’s selected learning rate, SGD for reference. adversarial step) with the accuracy gap (acc) and loss gap (loss). The pooled rows are filed in the run registry under the task task SGD 0.02 0.05 0.1 0.2 0.3 0.5 0.7 1 digits_n0.4 because every registry row needs a task; they pool the digits_n0.0 0.965 0.959 0.961 0.964 0.965 0.969 0.968 0.932 0.115 tasks named in the row label. digits_n0.2 0.865 0.874 0.889 0.911 0.930 0.944 0.951 0.598 0.105 digits_n0.4 0.727 0.742 0.771 0.809 0.861 0.897 0.924 0.248 0.097 subset n rand-acc rand-loss adv-acc adv-loss spirals_n0.2 0.917 0.915 0.917 0.909 0.823 0.685 0.518 0.518 0.518 all tasks pooled 380 −0.14 −0.05 −0.24 −0.22 pooled, collapsed runs removed 324 −0.07 −0.03 −0.18 −0.23 digits_n0.0 95 −0.20 −0.43 −0.23 −0.59 TABLE V digits_n0.2 95 0.21 0.32 −0.45 −0.41 Test accuracy (mean over 5 seeds) of SGD+WD by weight decay λ digits_n0.4 95 0.42 0.51 0.27 0.37 spirals_n0.2 95 −0.78 −0.83 −0.27 −0.35 at SGD+WD’s selected learning rate. digits_n0.0 no collapsed 91 −0.25 −0.63 −0.25 −0.70 digits_n0.2 no collapsed 85 0.35 0.39 −0.41 −0.45 task 0.0001 0.001 0.003 0.006 0.01 0.02 0.03 0.05 digits_n0.4 no collapsed 78 0.79 0.77 0.58 0.62 spirals_n0.2 no collapsed 70 −0.49 −0.60 −0.59 −0.77 digits_n0.0 0.965 0.966 0.965 0.963 0.960 0.947 0.934 0.842 SAM-sweep digits pooled 120 −0.25 0.03 −0.41 −0.21 digits_n0.2 0.834 0.841 0.868 0.911 0.932 0.928 0.902 0.524 SAM only digits_n0.0 40 −0.03 0.28 −0.10 −0.10 digits_n0.4 0.725 0.759 0.818 0.864 0.889 0.846 0.690 0.119 SAM only digits_n0.2 40 0.30 0.55 −0.19 0.03 spirals_n0.2 0.915 0.920 0.897 0.847 0.667 0.655 0.538 0.518 SAM only digits_n0.4 40 0.35 0.50 0.14 0.27 highest at λ = 0.01 (0.889 at 40% noise) and λ = 0.05 collapses (0.524, 0.119). H3 (sharpness tracks the gap): not supported. The exploratory step defined after seeing the data, and kept registered criterion required positive correlations pooled unchanged from the first version of this study) leaves and within every task; neither holds. Table VI gives Spear- pooled values of −0.23 to −0.03 (digits_n0.4: 0.79 and man correlations between the two sharpness measures 0.58 for the accuracy gap). Across optimisers, Table II and the two gaps (over the runs of SGD, SGD+WD, shows no reversal between SGD and SAM in this version: SAM and the two ablations; the early-stopped and 2x- at both noisy digits tasks SGD has the largest random- step baselines are not included). Pooled over all 380 runs direction sharpness (2.95 × 10−3 and 4.68 × 10−3 , against the correlations are weak and negative: −0.14 for random- 3.24 × 10−4 and 3.02 × 10−4 for SAM) and the largest or direction sharpness and −0.24 for adversarial sharpness second-largest adversarial sharpness (0.0792 and 0.1259 with gap_acc (−0.22 for adversarial sharpness with the against 0.0614 and 0.0853), together with the largest gap loss gap). Per task they differ in sign: on spirals and (0.048 vs −0.142 at 20%). The two measures nevertheless on digits_n0.0 all four are negative (spirals −0.78 and disagree about the order of the other pairs: SGD+WD has −0.27 with gap_acc; digits_n0.0 −0.20 and −0.23), at the largest adversarial sharpness at 20% noise (0.0986) 20% noise random-direction sharpness is positive (0.21) but a random-direction sharpness (9.12 × 10−4 ) below and adversarial sharpness negative (−0.45), and only at SGD’s, and at 40% noise it has a smaller adversarial 40% noise are all four positive (0.27–0.51). Within the sharpness than SAM (0.0627 vs 0.0853) but a larger SAM ρ sweep on digits they are −0.41 to 0.03 over the random-direction sharpness (1.69 × 10−3 vs 3.02 × 10−4 ). two measures and two gaps (120 runs), but there ρ moves A fixed-radius loss increase also depends on the loss level both quantities and the collapsed runs at large ρ are and on the weight scale, which differ across systems (at included; removing collapsed runs (rows “no collapsed”: 20% noise SGD+WD has weight norm 7.10 vs 17.54 for test accuracy below 0.15 on digits or 0.55 on spirals, an SGD), so we do not interpret it as intrinsic flatness. 0.2 0.2 0.1 0.1 digits n0.0 digits n0.2 0.0 0.0 digits n0.4 spirals n0.2 gap_acc SGD −0.1 −0.1 SGD+WD SAM −0.2 −0.2 SAM random direction SAM+WD −0.3 −0.3 10−3 10−2 10−1 −10−4 0 10−4 10−3 sharp adv (loss increase, norm 0.5) sharp rand (loss increase, norm 0.5), symlog axis Fig. 2. Final-model sharpness (perturbation norm 0.5, noisy training set) versus gap_acc over all 380 evaluation runs of SGD, SGD+WD, SAM and the two ablations (main, sweeps and ablation groups); colour: task, marker: system. The random-direction axis is symmetric- logarithmic (linear near zero), so that runs with negative random-direction sharpness are shown. VI. Ablations and Analysis (Tables IV,V), so together they over-regularise; we did not run a joint grid, so we cannot say whether a jointly tuned The two ablations (Table VII) and the sweeps of Sec. V SAM+WD would beat SAM or SGD+WD. were run with the same code, seeds and step budget as Sensitivity. Both regularisers show a cliff just above their the main group, at SAM’s selected learning rate. best value on noisy digits (ρ: 0.951 to 0.598 from 0.5 to Random vs adversarial direction. Replacing the ascent 0.7 at 20% noise; λ: 0.932 to 0.524 from 0.01 to 0.05). direction by a random direction of the same radius removes SAM’s best value gains 0.023 over SGD+WD’s at 20% the benefit entirely: on digits at 20% and 40% noise the noise. The practical reading is that at this scale a badly accuracy is 0.865 and 0.730, against 0.865 and 0.727 for chosen ρ (or λ) can be much worse than plain SGD, and SGD, and most flipped labels are memorised (0.566 and that the comparison with a tuned weight decay is the 0.606). With the same radius and the same extra compute, relevant one. the gradient-aligned direction is therefore what produces the effect here, rather than weight noise of the same VII. Limitations Euclidean norm or the extra step. (The SGD reference uses its own selected learning rate, which differs from Scale. One small architecture (3-layer MLP, width 128), SAM’s, so the comparison is approximate.) This is a tiny data (600 or 400 training points), two datasets, weak control: a random direction in the roughly 26k- symmetric noise only, and 5 evaluation seeds: the paired dimensional parameter space changes the loss far less than and Welch tests have low power, the registered tests the gradient direction (for SGD at 20% noise, a step of are uncorrected (with the Holm adjustment of Table III norm 0.5 raises the training loss by 2.95×10−3 in a random only the margin over SGD+WD at 20% noise among the direction against 0.0792 along the gradient, Table II), stronger baselines remains below 0.05), and the digits so it does not rule out that larger random noise would seeds share one outer test set, so the test-set sampling help. On two-spirals and noise-free digits the random error is common to all runs. The results do not transfer variant matches SGD too (0.917, 0.958). This isolates the automatically to CNNs, large data or instance-dependent perturbation direction, not the reason why the adversarial noise. direction helps (e.g. clean-example up-weighting versus Tuning. Momentum, batch size and the epoch counts implicit regularisation [5]), which we did not test. (150 and 300) were fixed for all systems and not tuned. SAM+WD (failure of naive combination). Combining Learning rate, ρ and λ were selected on a noisy validation the selected ρ and λ without joint tuning is harmful on split with 3 seeds from small grids; several selected values noisy digits: test accuracy 0.098 ± 0.008 at 20% noise and lie at an edge of the learning-rate grid (Table I), so a 0.097 at 40%, i.e. chance, in every seed (largest single-run wider learning-rate grid could change the baselines, and accuracy 0.107 at 20% noise). In these runs the weights are for noisy digits the selected ρ = 0.5 sits next to a collapse driven towards zero (weight norm 1.10 ± 0.04 at 40% noise at 0.7, so the true optimum is not resolved. Plain SGD against 13.08 for SAM and 7.82 for SGD+WD). Without has 3 candidates, SAM and SGD+WD 8×3 each. The noise SAM+WD is comparable to SAM (0.965 ± 0.009 vs early-stopped systems select the best of 150 per-epoch 0.969 ± 0.008), and on spirals it is 0.913 against 0.915 for validation accuracies on 300 noisy validation labels, which SAM, within one seed standard deviation. On noisy digits is an optimistic selection that is the same for every ES each regulariser was selected alone close to the edge of its system; we did not early-stop SAM. SAM+WD was not useful range, with a collapse one or two grid steps higher tuned jointly. With the outer test set the selection no TABLE VII Ablations at the selected ρ (and λ for SAM+WD), mean ± std over 5 seeds, same columns and units as Table II. Compare with SAM in Table II. Method Task test_acc gap_acc memorised sharp_adv sharp_rand weight_norm SAM random direction digits_n0.0 0.958 ± 0.007 0.042 ± 0.007 0.000 ± 0.000 0.0122 ± 0.0056 8.50 × 10−5 ± 1.2 × 10−5 15.30 ± 0.09 SAM+WD digits_n0.0 0.965 ± 0.009 0.034 ± 0.008 0.000 ± 0.000 0.0255 ± 0.0019 1.02 × 10−4 ± 2.0 × 10−5 12.50 ± 0.08 SAM random direction digits_n0.2 0.865 ± 0.016 0.050 ± 0.024 0.566 ± 0.075 0.1862 ± 0.0647 2.12 × 10−3 ± 1.3 × 10−4 17.54 ± 0.43 SAM+WD digits_n0.2 0.098 ± 0.008 0.022 ± 0.011 0.125 ± 0.025 0.0142 ± 0.0007 6.34 × 10−6 ± 4.7 × 10−6 0.29 ± 0.06 SAM random direction digits_n0.4 0.730 ± 0.024 0.107 ± 0.029 0.606 ± 0.031 0.3007 ± 0.1203 3.61 × 10−3 ± 2.6 × 10−4 18.24 ± 0.12 SAM+WD digits_n0.4 0.097 ± 0.008 0.025 ± 0.008 0.118 ± 0.027 0.0031 ± 0.0005 5.48 × 10−5 ± 1.6 × 10−5 1.10 ± 0.04 SAM random direction spirals_n0.2 0.917 ± 0.017 −0.140 ± 0.017 0.107 ± 0.046 0.0768 ± 0.0544 9.12 × 10−4 ± 1.7 × 10−4 13.06 ± 0.46 SAM+WD spirals_n0.2 0.913 ± 0.022 −0.140 ± 0.020 0.107 ± 0.033 0.0654 ± 0.0453 7.30 × 10−4 ± 1.0 × 10−4 12.43 ± 0.45 longer uses the evaluation test images on digits; the spirals gap across optimisers (pooled Spearman −0.22 to −0.05, data are generated fresh per seed. negative within spirals). These results reproduce known Sharpness measurement. Our sharpness uses a single effects at small scale and add no new mechanism; within fixed Euclidean radius (0.5), one-step adversarial or 20 the limits of a five-seed CPU study with small tuning random directions, measured on the noisy training set. It is grids, the practical take-away is to compare SAM against not scale invariant (cf. ASAM [8]), the weight norms differ tuned weight decay, early stopping and gradient-matched widely across systems (at 40% noise 7.82 for SGD+WD baselines and to tune ρ on validation data; we make no against 18.22 for SGD), and the training loss levels claim about larger models. differ, so differences in Sadv across optimisers confound References flatness with loss level and weight scale. The sharpness– gap correlations are observational, pool runs with different [1] P. Foret, A. Kleiner, H. Mobahi, and B. Neyshabur, “Sharpness- Aware Minimization for Efficiently Improving Generalization,” optimisers and some collapsed runs, and the exploratory arXiv preprint arXiv:2010.01412, 2020. [Online]. Available: “no collapsed” rows were defined after seeing the data. https://arxiv.org/abs/2010.01412 Our gap definition compares noisy-train and clean-test [2] N. S. Keskar, D. Mudigere, J. Nocedal, M. Smelyanskiy, and P. T. P. Tang, “On Large-Batch Training for Deep accuracy, so memorisation and label corruption enter the Learning: Generalization Gap and Sharp Minima,” arXiv quantity being explained, and it is negative when a model preprint arXiv:1609.04836, 2016. [Online]. Available: https: does not memorise. We did not test a matched-label gap, //arxiv.org/abs/1609.04836 [3] Y. Jiang, B. Neyshabur, H. Mobahi, D. Krishnan, and scale-normalised or multi-step sharpness, or other widths. S. Bengio, “Fantastic Generalization Measures and Where to Implementation. All optimisers are reimplemented here Find Them,” arXiv preprint arXiv:1912.02178, 2019. [Online]. from their published description, SAM uses a global-norm Available: https://arxiv.org/abs/1912.02178 [4] M. Andriushchenko, F. Croce, M. Müller, M. Hein, and perturbation on every minibatch (not m-sharpness splits), N. Flammarion, “A Modern Look at the Relationship and the spirals task is easy enough that every system fits between Sharpness and Generalization,” arXiv preprint only a small fraction of the flipped labels, which limits arXiv:2302.07011, 2023. [Online]. Available: https://arxiv.org/ abs/2302.07011 what it can show. A full study would add CNNs on CIFAR- [5] C. Baek, Z. Kolter, and A. Raghunathan, “Why is SAM N-style noise, more seeds, joint tuning, early-stopped SAM Robust to Label Noise?” arXiv preprint arXiv:2405.03676, and scale-invariant sharpness. 2024. [Online]. Available: https://arxiv.org/abs/2405.03676 [6] M. Andriushchenko and N. Flammarion, “Towards Understanding Sharpness-Aware Minimization,” arXiv VIII. Conclusion preprint arXiv:2206.06232, 2022. [Online]. Available: https://arxiv.org/abs/2206.06232 On a small MLP with symmetric label noise, SAM [7] C. Zhang, S. Bengio, M. Hardt, B. Recht, and improved clean test accuracy over plain SGD by a large O. Vinyals, “Understanding deep learning requires rethinking margin (0.951 vs 0.865 and 0.924 vs 0.727 at 20% and generalization,” arXiv preprint arXiv:1611.03530, 2016. [Online]. Available: https://arxiv.org/abs/1611.03530 40% noise on digits). Tuned weight decay, early stopping [8] J. Kwon, J. Kim, H. Park, and I. K. Choi, “ASAM: Adaptive on noisy validation accuracy and SGD+WD with twice Sharpness-Aware Minimization for Scale-Invariant Learning the steps each recovered most of that gain; SAM stayed of Deep Neural Networks,” arXiv preprint arXiv:2102.11600, 2021. [Online]. Available: https://arxiv.org/abs/2102.11600 ahead of all of them in every seed (margin over SGD+WD [9] J. Du, H. Yan, J. Feng, J. T. Zhou, L. Zhen, R. S. M. Goh, 0.023 at 20% and 0.035 at 40%), but after Holm correction and V. Y. F. Tan, “Efficient Sharpness-aware Minimization over 24 comparisons only the 20% margin over SGD+WD for Improved Training of Neural Networks,” arXiv preprint arXiv:2110.03141, 2021. [Online]. Available: https://arxiv.org/ remained below 0.05 (Holm p = 0.029). SAM gave abs/2110.03141 no benefit on noisy spirals, was sensitive to ρ, with a [10] K. Wen, T. Ma, and Z. Li, “How Does Sharpness- collapse towards chance one grid step above the best Aware Minimization Minimize Sharpness?” arXiv preprint arXiv:2211.05729, 2022. [Online]. Available: https://arxiv.org/ value on noisy digits, and a random-direction perturbation abs/2211.05729 of the same radius behaved like SGD. A fixed-radius loss-increase sharpness did not track the generalisation