Skip to content
KitploitKITPLOIT
ToolsExploitsBlog
Log in
Submit
ToolsExploitsBlog
Submit

Hacking, PenTest, and Cybersecurity Tools for Your Security Arsenal!

Kitploit is a directory of hacking, cybersecurity, and pentesting tools. Discover the latest project updates to find vulnerabilities, analyze systems, automate testing, and strengthen your security.

FeedsContactPrivacy© 2026 Kitploit

Tool Directory

Categories

View all categories
Loading categories
co-weight-drift — PyTorch reference implementation of a fast adversarial training method that prevents catastrophic overfitting via coupled objectives and an EMA-based weight-drift guard, with AutoAttack evaluation. | Kitploit
Tools/GitHubGitHub/fzjcdt/co-weight-drift
Machine LearningPapers & ResearchAI SecurityAdversarial Attack
GitHubfzjcdt/co-weight-drift

co-weight-drift

PyTorch reference implementation of a fast adversarial training method that prevents catastrophic overfitting via coupled objectives and an EMA-based weight-drift guard, with AutoAttack evaluation.

View Repository
152 days agoNot yet reviewed

Most Popular

View all →

Discover the most used tools by our community.

Explore all tools

Browse our collection of tools

View all tools →
Share

Catastrophic Overfitting is Weight Drift the Training Loss Cannot See

Reference PyTorch implementation of the method described in the paper above. Fast adversarial training (FAT) suffers from catastrophic overfitting (CO): the FGSM robust accuracy stays high while PGD robust accuracy collapses within a couple of epochs. This codebase implements the paper's two contributions:

  1. Mechanism. CO is weight drift along directions the training loss cannot see: the one-step (FGSM-style) attack makes the loss blind to a subspace of perturbations, the weights drift through it, and BN re-calibration turns the drift into gradient masking. The EMA of the weights stays in the robust basin throughout — the training run carries its own pre-collapse anchor.
  2. Method. A coupled base objective (two coupling scales that cover each other's failure modes) plus a guard: after each epoch, if validation PGD-10 accuracy drops by more than θ = 0.08 (8 accuracy points) from the running best, the raw weights are recentred on their own EMA, with a 3-epoch cooldown and a 5-fire budget. The guard costs zero extra forward or backward passes and never fires on healthy trajectories.

Results

Robust accuracy (%) under the complete standard AutoAttack (AA) and the constraint-relaxation attack (CR), ε = 8/255, ResNet18 (PreActResNet18 on Tiny-ImageNet), mean ± sample std. Baseline rows are the released results of the FastAT_Benchmark under the identical protocol.

MethodC10 AAC10 CRC100 AAC100 CRTiny AATiny CR
PGD-AT-WA (multi-step ref.)50.49±0.1550.51±0.1626.90±0.1726.87±0.1719.77±0.1619.75±0.13
NuAT50.10±0.1850.11±0.1914.41±3.2917.66±0.4210.20±0.4410.19±0.44
LIET49.99±0.1549.93±0.1526.64±0.1326.63±0.1419.88±0.0919.86±0.07
FGSM-PGI49.89±0.0849.89±0.1226.29±0.1626.31±0.1219.55±0.1119.52±0.12
FGSM-FUAP49.73±0.1249.71±0.1225.95±0.0825.94±0.0519.10±0.1819.09±0.19
FGSM-CUAP49.55±0.2249.54±0.2225.85±0.5025.83±0.4919.19±0.0919.20±0.11
Base + guard (ours)50.45±0.2050.44±0.1627.15±0.0427.20±0.0720.47±0.1120.54±0.15

Strongest AutoAttack and CR accuracy among fast methods on all three datasets, at FAT cost (~0.7–1.1 h/run on one A100, vs ~2 h for the multi-step reference). On CIFAR-10 the unguarded base is a coin flip: 2 of 4 seeds collapse to CO artifacts (AutoAttack 7.5) while the survivors match the guarded row (50.67±0.08) — the guard's effect is exactly the removal of this failure mode. Notably, the FAB-T and square components of AutoAttack find zero additional points on all of our released checkpoints (no gradient masking signature). Per-seed numbers and raw logs: logs/.

Setup

pip install -r requirements.txt

Tested with Python 3.12, torch 2.5.1, torchvision 0.20.1, torchattacks 3.5.1, CUDA 12.4, on A100-PCIE-40GB. The autoattack/ directory in this repo is the vendored copy the released numbers were produced with (Francesco Croce's AutoAttack); running from the repo root makes it take precedence over any pip-installed copy.

Training

train.py implements the paper's method; defaults are the CIFAR-10 recipe.

# CIFAR-10 (γ_max=4.0, m_max=2.5, λ_d=0.3, guard θ=0.08) — 4 seeds
bash scripts/train_cifar10.sh 0            # GPU 0, seeds 0 1 2 3

# CIFAR-100 (γ_max=1.25, m_max=4.5, λ_d=0)
bash scripts/train_cifar100.sh 0

# Tiny-ImageNet (PreActResNet18, γ_max=1.0, m_max=2.5, λ_d=0)
bash scripts/train_tiny.sh 0

# or a single run directly (equivalent to the CIFAR-10 script)
python train.py --dataset cifar10 --seed 0 --gpu 0 \
    --nuc-max 4.0 --mse-extra 2.5 --lam-d 0.3 --guard val --guard-thr 0.08 \
    --out-dir results/cifar10/guard_s0

Each run writes train.log (per-epoch val PGD-10 of raw and EMA weights, guard-fire lines), probe.csv (optional batch-level CO dynamics), and best.pth / last.pth / ema_last.pth. best.pth is the epoch with the highest validation PGD-10 (raw vs EMA weights, tie-broken by clean accuracy).

Method switches

  • --guard none disables the guard (the unguarded base; expect the CO coin flip on CIFAR-10).
  • --init-style bu switches the perturbation init from the paper's fresh half-sign at 0.5ε to 70% ±ε Rademacher / 30% U[−ε, ε].
  • --probe-every 0 disables the diagnostic probes. Note the probes consume RNG and therefore perturb the training trajectory (the "instrumentation lottery" reported in the paper) — match this flag to the released run you compare against (see logs/README.md).

Evaluation

# complete standard AutoAttack + CR attack, full test set, bs=200
bash scripts/eval.sh results/cifar10/guard_s0 0            # GPU 0, ResNet18
bash scripts/eval.sh results/tiny-imagenet/guard_s0 0 preact18

# or individually
python aa_eval.py --run-dir results/cifar10/guard_s0 --gpu 0 --full   # autoattack_full.log
python cr_eval.py --run-dir results/cifar10/guard_s0 --gpu 0          # cr_attack.log

aa_eval.py --full runs the complete standard suite (apgd-ce, apgd-t, FAB-T, square) — the protocol of every AA number in the paper. Without --full it runs the benchmark's 2-attack development variant (apgd-ce + apgd-t), which on our models differs by at most 0.02.

Repo layout

train.py                 # coupled FAT + EMA self-anchor guard (the method)
aa_eval.py               # AutoAttack evaluation (full suite / 2-attack variant)
cr_eval.py               # CR attack evaluation
models/                  # ResNet18 / PreActResNet18 (from FastAT_Benchmark)
utils/                   # datasets, seeding, logger (from FastAT_Benchmark)
attacks/                 # CR attack (from FastAT_Benchmark)
autoattack/              # vendored AutoAttack (Francesco Croce, fra31)
scripts/                 # per-dataset training launchers + eval
logs/                    # raw logs of every run behind the paper's tables

Protocol

Identical to FastAT_Benchmark: ResNet18 (CIFAR-10/100) and PreActResNet18 (Tiny-ImageNet); ε = 8/255; 100 epochs; SGD (lr 0.1, momentum 0.9, weight decay 5e-4) with OneCycleLR; batch size 128; 49 000 / 1 000 train / val split; label smoothing 0.4; model selection by validation PGD-10; evaluation on the full test set with PGD-{10,20,50}, AutoAttack and the CR attack. All runs use set_seed with cudnn deterministic mode.

Credits

  • The benchmark scaffolding (models/, utils/, attacks/ CR attack) and all baseline results are from FastAT_Benchmark — please cite it if you use the comparison numbers.
  • autoattack/ is AutoAttack by Francesco Croce (vendored unmodified).
  • The base objective builds on ideas from NuAT (nuclear-norm logit coupling), FGSM-PGI (per-example MSE coupling) and DualC (MSE ramp), and the init scheme follows NuAT; see the paper for full citations.

Citation

The paper is under review. If you use this code, please cite it by its title until a BibTeX entry is available:

License

MIT (see LICENSE). The vendored third-party files keep their upstream licenses and copyright headers.

Download Tool