Ilikemechuri's picture
Clarify GPU comparison baselines and relative L2
b3b6a9c verified
|
Raw History Blame Contribute Delete
35.6 kB
---
license: apache-2.0
---
# Training Delta and Poisoning Experiments
This repository contains GPT-2 parameter deltas from FineWeb-Edu training runs. The included `delta_train.py` is a single-process training script; it does **not** implement DiLoCo's outer optimization loop. In the experiments below, the saved GPU-specific deltas are used as benign reference updates, not as verified DiLoCo updates.
## Poisoning Gradient Geometry
Gradients were measured in fp32 on the pretrained GPT-2 model using the same first FineWeb-Edu batch (4 sequences × 512 tokens). The clean gradient norm was 6.172803. The label-poisoning case changed about 10% of next-token labels to EOS. The trigger case changed one of the four examples to begin with ` cf` followed by ` Hello there.`.
| Gradient | Cosine vs. clean | L2 distance | Relative L2 distance |
| --- | ---: | ---: | ---: |
| Sign flip | -1.000000 | 12.345606 | 2.000 |
| EOS label poisoning | 0.266241 | 24.606737 | 3.986 |
| Trigger to target | 0.996913 | 0.485583 | 0.079 |
| Trigger-to-target gradient scaled ×10 | 0.996913 | 55.081192 | 8.923 |
The trigger gradient points in almost the same direction as the clean gradient in this one-batch probe. Scaling it preserves that cosine while greatly increasing its magnitude.
- [Cosine similarity heatmap](poisoning_gradients/cosine_similarity.png)
- [L2 distance heatmap](poisoning_gradients/l2_distance.png)
- [Per-gradient metrics](poisoning_gradients/gradient_metrics.csv)
## Benign-Update Mimic and Simple Detection
The clean reference was the RTX 3060 fp32 500-step delta, with L2 norm 28.978321. A backdoor-target gradient was computed at the resulting checkpoint and mixed into that update. Each candidate was rescaled to keep the same total L2 norm as the clean update. The poison ratio is the added poison component's norm divided by the clean update norm.
A nearest-neighbor detector used the other six fp32 GPU deltas as benign references. Leave-one-out reference thresholds were cosine ≥ 0.999237 and L2 distance ≤ 1.137659.
| Poison ratio | Nearest benign cosine | Nearest benign L2 | Detector | Target loss change | Clean loss change |
| ---: | ---: | ---: | --- | ---: | ---: |
| 0.01 | 0.999936 | 0.329987 | Pass | -5.670213 | +0.741890 |
| 0.03 | 0.999536 | 0.882983 | Pass | -5.804795 | +7.911239 |
| 0.10 | 0.995022 | 2.890360 | Flag | -5.099086 | +13.729857 |
The cosine/L2 detector missed the 1% and 3% candidates and flagged the 10% candidate. The target metric is loss on the fixed trigger phrase, not a full backdoor success-rate evaluation. The clean loss also rose as the poison component grew. This is a small, single-round outlier probe over GPU deltas, not a robust federated-learning defense evaluation.
- [Mimic and detection plot](mimic_detection/mimic_detection.png)
- [All poison-ratio measurements](mimic_detection/mimic_detection.csv)
- [Experiment metadata and thresholds](mimic_detection/metadata.json)
## Per-Tensor Poisoning Detection
Download the [interactive tensor comparison](tensor_poisoning_audit/tensor_comparison.html)
and open it in a browser. Select the 2-GPU DDP control or a 1%, 3%, or 10%
poisoned update, then click a tensor to see the clean delta, candidate delta,
and their difference. The heatmap shows up to 128 sampled elements per tensor.
The sortable table uses L2 distances over all elements of each tensor.
For each of GPT-2's 148 parameter tensors, the threshold was the largest L2
distance between any pair of the six clean FP32 GPU references. A tensor was
flagged when its distance to the closest clean reference exceeded that threshold.
| Candidate | Whole-update L2 flagged | Tensors flagged |
| --- | --- | ---: |
| Clean RTX 3060 single GPU | No | 0 / 148 |
| Clean RTX 3060 2-GPU DDP | No | 0 / 148 |
| 1% poison component | No | 92 / 148 |
| 3% poison component | No | 106 / 148 |
| 10% poison component | Yes | 141 / 148 |
At 1%, `transformer.h.2.ln_1.bias` was the strongest outlier at 64.7× its
threshold. These results cover three trigger variants and two held-out clean
controls for a single training setup. In volunteer training with different
data shards, calibrate against clean replays of the same assigned work,
including the starting checkpoint, token order, and precision.
[Per-tensor CSV](tensor_poisoning_audit/tensor_metrics.csv) ·
[Experiment summary](tensor_poisoning_audit/summary.json) ·
[Reproduction script](tensor_poisoning_audit.py)
### Robustness and attack-effect tradeoff
A candidate fails the tensor check if any tensor's distance to its closest clean reference exceeds that tensor's clean threshold. Re-scoring the saved per-tensor distances with different threshold multipliers gives the following counts. The target and clean loss changes are measured relative to the clean single-GPU update.
| Candidate | Flagged at 0.5× | Flagged at 1× | Flagged at 2× | Flagged at 10× | Target loss change | Clean loss change |
| --- | ---: | ---: | ---: | ---: | ---: | ---: |
| Clean single GPU | 0 | 0 | 0 | 0 | 0.000 | 0.000 |
| Clean 2-GPU DDP | 0 | 0 | 0 | 0 | +0.002 | −0.0002 |
| 1% poison component | 100 | 92 | 81 | 30 | −5.670 | +0.742 |
| 3% poison component | 132 | 106 | 95 | 66 | −5.805 | +7.911 |
| 10% poison component | 148 | 141 | 126 | 92 | −5.099 | +13.730 |
All three tested poisoned candidates substantially lowered loss on the fixed target phrase and were flagged even at 10× the calibrated threshold. Both clean controls passed at every tested multiplier. This shows that the observed separation is insensitive to these threshold changes for the saved candidates.
The stronger hypothesis is that an update that passes the tensor check has negligible attack effect. This experiment leaves that hypothesis open: every poisoned candidate was flagged, so the effect among passing poisoned updates was unmeasured. The three candidates are different strengths of the same setup, and loss on one fixed phrase measures a proxy for attack effect. To establish the stronger claim, measure target behavior on held-out prompts for passing candidates, define a negligible effect in advance, and repeat across independent shards, seeds, and training rounds.
### Exponential range-penalty optimization probe
To test whether a targeted optimizer could trade off attack effect against the tensor ranges, `penalized_attack_audit.py` optimized the fixed trigger-target loss with an exponential penalty on tensor scores above 1. For tensor *i*, the score is its distance to the nearest clean reference divided by that tensor's clean maximum pairwise distance. The penalty is the mean of `(exp(10 × max(score − 1, 0)) − 1) / 10`; the candidate's whole-update L2 norm was projected back to the RTX 3060 anchor norm after every AdamW step. The exponential is continued linearly past its numerical cap so the penalty gradient does not disappear for large violations.
The anchor target loss was 8.502. The table shows two optimization settings; the recorded results are in [the higher-learning-rate summary](penalized_attack_exp_k10_v2/summary.json) and [the lower-learning-rate summary](penalized_attack_exp_k10_lr1e3/summary.json).
| AdamW learning rate | Steps | Penalty weight | Target loss | Tensors outside range |
| ---: | ---: | ---: | ---: | ---: |
| 0.01 | 80 | 1 | 0.00003 | 148 / 148 |
| 0.01 | 80 | 10 | 8.380 | 148 / 148 |
| 0.001 | 60 | 10 | 1.629 | 141 / 148 |
| 0.001 | 60 | 100 | 2.280 | 138 / 148 |
No tested candidate passed the tensor check. Lowering the learning rate let the optimizer retain a substantial target-loss reduction, but most tensors still exceeded their calibrated ranges. At the higher learning rate, a larger penalty weight suppressed most of the target-loss reduction, while the candidate remained out of range. This suggests that finding an in-range candidate with this particular target objective and short optimization budget was difficult; it does not show that an adaptive attacker cannot find one. The outcome is sensitive to optimizer settings, and this probe did not measure clean loss or held-out target behavior. Treat the exponential term as an optimization deterrent, not a replacement for server-side range checks and rejection of updates that exceed the calibrated bounds.
Reproduce the lower-learning-rate setting with:
```bash
python penalized_attack_audit.py --steps 60 --lr 0.001 --penalty exponential \
--exp-rate 10 --lambdas 10 100 --output penalized_attack_exp_k10_lr1e3
```
### Bounds for updates that pass the tensor check
For each tensor, the triangle inequality bounds its distance from the RTX 3060 anchor by the sum of its calibrated threshold and the largest distance from the anchor to any of the six clean references. Taking the L2 norm of these 148 bounds gives a whole-update distance bound of **2.365**, or **8.16%** of the anchor delta norm. This is an upper bound and allows the nearest clean reference to differ across tensors.
At the anchor checkpoint, the original fixed target phrase had cross-entropy loss **8.502**. Summing the per-tensor products of the distance bound and the target gradient norm gives **117.231** as an upper bound on the decrease in the first-order loss approximation. That exceeds even the baseline loss. The bound on actual loss decrease from nonnegative cross-entropy alone is **8.502**. The first-order calculation does not bound the nonlinear remainder, and neither result establishes that passing updates have negligible target effect. No passing attack or held-out prompt was evaluated in this calculation.
### Clean holdouts, tensor ablation, and effect among passing candidates
The two original clean RTX 3060 controls passed. In a separate leave-one-GPU-out analysis, each of the six FP32 reference GPUs was tested against the other five. The per-tensor thresholds were recalibrated from those five references in each fold. Five held-out updates passed with zero flagged tensors. CMP 170HX was flagged on all 148 tensors, giving one flagged clean update in six folds. The folds share calibration data and belong to one training setup, so this count is not a population false-positive rate.
| Poison component | Flagged tensors | After removing highest-scoring tensor | Minimum after removing any one of 12 transformer blocks |
| --- | ---: | ---: | ---: |
| 1% | 92 | 91 | 83 |
| 3% | 106 | 105 | 95 |
| 10% | 141 | 140 | 129 |
All three saved candidates were still flagged after either ablation. The clean controls still passed. Zero of the three poisoned candidates passed the original tensor check, so the target effect among passing poisoned candidates is unmeasured. The available loss values cover one fixed phrase and do not measure target response generation on held-out prompts.
### Per-tensor random-projection fingerprints
Each of GPT-2's 148 flattened FP32 parameter tensors gets its own 2048-bit random-hyperplane signature. We append that tensor's FP32 L2 norm with a hyphen: the signature and norm are compared separately. Projection bits use Hamming distance; norms use relative numeric error, not bitwise comparison. The complete representation contains 307,840 bits across all tensors.
Thresholds use the six non-anchor GPU deltas. For each tensor, the projection threshold is the largest leave-one-out nearest-reference Hamming distance; the norm threshold is the largest pairwise relative norm difference. Projection thresholds had median 24 bits and maximum 83 bits. Norm thresholds had median 0.108% and maximum 2.075%. Five clean GPU references had mean nearest-neighbor projection distance between 0.64 and 1.04 bits per tensor; CMP 170HX was farther away at 26 bits per tensor. The held-out clean RTX 3060 anchor was flagged on one tensor, while the clean DDP control passed.
| Candidate | Norm-only flags | Both criteria flags | Fixed target loss |
| --- | ---: | ---: | ---: |
| Clean RTX 3060 anchor | 1 / 148 | 1 / 148 | 8.502 |
| Clean RTX 3060 DDP | 0 / 148 | 0 / 148 | 8.504 |
| 1% poison component | 84 / 148 | 94 / 148 | 2.832 |
| 3% poison component | 105 / 148 | 115 / 148 | 2.697 |
| 10% poison component | 140 / 148 | 148 / 148 | 3.403 |
| 1% poison, per-tensor norms matched to clean references | 0 / 148 | 92 / 148 | 2.619 |
| 1% poison, per-tensor norms and projection bits matched | 0 / 148 | 0 / 148 | 1.586 |
For the adaptive candidate, the attacker knows the projection vectors and six allowed clean references. It chooses the nearest clean reference separately for each tensor, matches that tensor's norm, then adjusts the update along the known projection directions. It matched all 303,104 projection bits to those reference fingerprints. The complete adjustment from the original 1% poison candidate had L2 norm 0.134, or 0.463% of the anchor delta norm. The resulting update passed every per-tensor check and lowered the fixed target loss further. This shows that the fingerprint is not robust against an attacker with this reference and projection knowledge; the test does not establish how easily an attacker succeeds without access to the clean references. It also uses one target phrase and one training setup, and the clean anchor false positive shows the small calibration set is imperfect.
- [Fingerprint summary](per_tensor_random_projection_fingerprint/summary.json)
- [Per-tensor comparison metrics](per_tensor_random_projection_fingerprint/tensor_metrics.csv)
- [Reproduction script](per_tensor_random_projection_fingerprint.py)
- [Original 1% poisoned delta](per_tensor_random_projection_fingerprint/poison_0.01.safetensors)
- [Original 3% poisoned delta](per_tensor_random_projection_fingerprint/poison_0.03.safetensors)
- [Original 10% poisoned delta](per_tensor_random_projection_fingerprint/poison_0.10.safetensors)
- [Norm-matched poisoned delta](per_tensor_random_projection_fingerprint/poison_0.01_per_tensor_norm_matched.safetensors)
- [Fingerprint-matched adaptive delta](per_tensor_random_projection_fingerprint/poison_0.01_known_per_tensor_fingerprint_evasion.safetensors)
Reproduce with:
```bash
python per_tensor_random_projection_fingerprint.py --bits-per-tensor 2048 \
--seed 20261127 --output per_tensor_random_projection_fingerprint
```
## Determinism with a Fixed Seed
On one RTX 3060, the clean gradient for the same 4 × 512 batch was recomputed three times per setting. The tested non-TF32 modes—deterministic algorithms off, cuDNN deterministic off/benchmark on, cuBLAS workspace unset, and all guards off—showed no observed difference from strict fp32: cosine remained 1.0 and relative L2 distance remained 0. The cuDNN and cuBLAS modes also disabled PyTorch's deterministic-algorithm guard, so those settings were not isolated from that guard. TF32 changed the gradient slightly while remaining repeatable: cosine 0.999966, relative L2 0.008204, and absolute L2 0.050642 versus strict fp32.
A separate clean 500-step fp32 run used seed 1337 with deterministic guards disabled, cuDNN benchmarking enabled, TF32 disabled, and `CUBLAS_WORKSPACE_CONFIG` unset. Its delta matched the strict deterministic RTX 3060 delta exactly (cosine 1.0, L2 distance 0). Both runs had matching first and final logged losses to the reported precision. These results describe this fixed model, batch, software stack, and GPU; they do not establish that arbitrary CUDA workloads are deterministic without these settings.
- [Determinism settings summary](determinism_gradients/settings_summary.csv)
- [Cosine vs. strict mode](determinism_gradients/cosine_vs_strict.png)
- [Relative L2 vs. strict mode](determinism_gradients/relative_l2_vs_strict.png)
- [Repeated-run variation](determinism_gradients/within_mode_repeat_variation.png)
- [Full 500-step delta comparison](determinism_training/training_comparison.csv)
- [Guards-off 500-step delta](determinism_training/delta_rtx3060_fp32_all_guards_off.safetensors)
## Clean Single-GPU vs Multi-GPU
`delta_train.py` is the clean single-process baseline. [`delta_train_multi_gpu.py`](delta_train_multi_gpu.py)
adds clean data-parallel training with [Hugging Face Accelerate](https://huggingface.co/docs/accelerate/en/index) and DDP. It uses the
same seed, token order, optimizer, learning-rate schedule, precision, and global
batch size as the single-GPU script. In the multi-GPU script, `--micro-batch` is
the total batch across all GPUs; with two GPUs and `--micro-batch 4`, each GPU
processes two sequences per micro-step. Gradient synchronization happens after
the accumulation micro-steps, before clipping and the optimizer update. This is
DDP training, not DiLoCo's periodic outer-loop update.
Run both clean fp32/bf16 variants with matching settings:
```bash
uv pip install accelerate
python delta_train.py --repo Ilikemechuri/diloco_floating_point --prefix delta_single_gpu \
--steps 500 --seq-len 512 --micro-batch 4 --grad-accum 4 --seed 1337
accelerate launch --multi_gpu --num_processes 2 delta_train_multi_gpu.py \
--repo Ilikemechuri/diloco_floating_point --prefix delta_multi_gpu \
--steps 500 --seq-len 512 --micro-batch 4 --grad-accum 4 --seed 1337
```
The fp32 files are named `delta_single_gpu_<gpu>_fp32.safetensors` and
`delta_multi_gpu_<gpu>_fp32.safetensors`. Download both files from the repo and
compare them with [`compare_clean_deltas.py`](compare_clean_deltas.py):
```bash
gpu_slug=nvidia-geforce-rtx-3060 # replace with the slug in your filenames
python compare_clean_deltas.py "delta_single_gpu_${gpu_slug}_fp32.safetensors" \
"delta_multi_gpu_${gpu_slug}_fp32.safetensors"
```
The comparison reports cosine similarity, L2 distance, and relative L2 distance
between the clean parameter deltas. Small numerical differences can occur from
GPU kernel and distributed-reduction order even when the global batch and
training data are matched.
Download [the interactive tensor heatmap](delta_heatmap.html) and open it in a browser. It includes sampled clean FP32 and BF16 deltas for one and two GPUs. Use the file picker to compare another safetensors delta, including an existing poisoned delta.
### RTX 3060 run
Both runs used seed 1337, 500 steps, sequence length 512, global micro-batch 4,
gradient accumulation 4, and the same cached FineWeb-Edu token stream.
| Run | FP32 loss (first → last) | Delta L2 |
| --- | ---: | ---: |
| 1 × RTX 3060 | 3.2252 → 3.1780 | 28.978321 |
| 2 × RTX 3060 DDP | 3.2252 → 3.1780 | 28.937950 |
The FP32 deltas have cosine similarity **0.9999679**, L2 distance **0.235570**,
and relative L2 distance **0.008129** (0.81% of the single-GPU delta norm).
- [Single-GPU FP32 delta](delta_single_gpu_nvidia-geforce-rtx-3060_fp32.safetensors)
- [Two-GPU FP32 delta](delta_multi_gpu_nvidia-geforce-rtx-3060_fp32.safetensors)
- [Single-GPU BF16 delta](delta_single_gpu_nvidia-geforce-rtx-3060_bf16.safetensors)
- [Two-GPU BF16 delta](delta_multi_gpu_nvidia-geforce-rtx-3060_bf16.safetensors)
- [FP32 comparison metrics](clean_single_vs_multi_comparison.json)
## Reproduce
Run from this directory in the prepared environment:
```bash
python poisoning_gradient_analysis.py --repo-dir .
python mimic_diloco_detection.py --repo-dir .
python determinism_gradient_comparison.py --repo-dir . --repeats 3
python clean_training_nondeterministic.py --repo-dir .
```
The model-poisoning and backdoor scenarios follow threat families studied in federated learning, including [local model poisoning](https://www.usenix.org/conference/usenixsecurity20/presentation/fang) and [model replacement for backdoor injection](https://proceedings.mlr.press/v108/bagdasaryan20a.html).
## Replay Auditing and GPU-Specific Tolerances
This section documents the detection thresholds and independently recomputed delta comparisons for snapshot `c5373f0dd887a8faf3d85bee9911a009175b8a33`. The round records, randomized fingerprints, and replay procedures describe a proposed DiLoCo audit design.
The training scripts use GPT-2 and FineWeb-Edu. The `data_sha256` field stores the first 16 hex characters of SHA-256. Replay requires pinned model, tokenizer, and dataset revisions, the exact ordered batches, and complete starting model, optimizer, and RNG state. The DDP experiment synchronizes accumulated gradients within local training. DiLoCo outer-round aggregation requires its own records. [Single-GPU script](delta_train.py) · [DDP script](delta_train_multi_gpu.py)
### Existing detection thresholds
| Check | Flag condition | Threshold |
| --- | --- | --- |
| Whole delta | Nearest clean-reference cosine falls below the cutoff or absolute L2 distance exceeds the cutoff | Cosine 0.999237, absolute L2 1.137659. The L2 cutoff is about 3.93% of the RTX 3060 reference delta norm. |
| Per-tensor L2 | Distance to the nearest reference exceeds the largest clean-reference pairwise distance for that tensor, with an absolute floor of 1e-8 | One threshold per tensor. Any flagged tensor flags the candidate. |
| Per-tensor fingerprint and norm | For each reference, take the larger of the normalized Hamming and norm errors. Flag if the minimum score across references exceeds 1. | Hamming allowance 6–83 of 2,048 bits, median 24. Relative norm allowance 0.0118–2.075%, median 0.108%. |
The joint score is `min_ref max(Hamming / max(Hamming_limit_t, 1), norm_rel_error / norm_limit_t)`. The relative norm error is the absolute difference between norms divided by their maximum, with a denominator floor of `1e-30`. Both conditions must pass against the same reference for that tensor. The CSVs give the exact thresholds in `projection_threshold_hamming`, `norm_relative_threshold`, and `reference_max_pair_l2`. Calibrate a randomized fingerprint policy across independent seeds and normal replays, including each new execution profile. [Fingerprint metrics](per_tensor_random_projection_fingerprint/tensor_metrics.csv) · [Tensor L2 metrics](tensor_poisoning_audit/tensor_metrics.csv)
### GPU differences recomputed from saved deltas
**Baseline for every row: one RTX 3060 at the same training precision.** FP32 rows use the single-GPU RTX 3060 FP32 delta, and BF16 rows use the single-GPU RTX 3060 BF16 delta. Each delta is the change in weights after training. Both modes store deltas in FP32. All 148 matching tensors and 124,439,808 elements were compared with FP64 accumulation.
Global relative L2 is `100 × ||delta_comparison − delta_baseline||₂ / ||delta_baseline||₂`, with all parameters treated as one vector. For example, the L4 FP32 distance is **0.659%** of the RTX 3060 FP32 baseline delta norm. The L4 BF16 distance is **9.053%** of the separate RTX 3060 BF16 baseline delta norm.
The median and maximum columns compute the same ratio for each tensor using its own baseline norm. For the two-RTX-3060 BF16 DDP run, the global relative L2 is **3.630%**, while the maximum is **123.310%** for `transformer.h.3.attn.c_attn.bias`. That tensor's absolute L2 difference is 0.055337 and its baseline norm is 0.044876. The ratio exceeds 100% because the distance between the two updates exceeds the size of the baseline update for that tensor.
| Comparison GPU | Training precision | Cosine | Absolute L2 | Global relative L2 | Median tensor relative L2 | Maximum tensor relative L2 |
| --- | --- | ---: | ---: | ---: | ---: | ---: |
| GeForce RTX 3060 + GeForce RTX 3060 | FP32 | 0.99996788 | 0.235570 | 0.813% | 0.641% | 1.722% |
| CMP 170HX | FP32 | 0.99938010 | 1.024766 | 3.536% | 3.574% | 11.126% |
| GeForce RTX 3090 | FP32 | 0.99994391 | 0.311470 | 1.075% | 0.863% | 2.209% |
| GeForce RTX 4090 | FP32 | 0.99992874 | 0.351173 | 1.212% | 0.980% | 2.493% |
| L4 | FP32 | 0.99997891 | 0.190859 | 0.659% | 0.517% | 1.475% |
| RTX PRO 6000 Blackwell Workstation Edition | FP32 | 0.99991447 | 0.384816 | 1.328% | 1.074% | 2.734% |
| Tesla T4 | FP32 | 0.99998553 | 0.158027 | 0.545% | 0.422% | 1.301% |
| GeForce RTX 3060 + GeForce RTX 3060 | BF16 | 0.99934124 | 1.010663 | 3.630% | 5.039% | 123.310% |
| CMP 170HX | BF16 | 0.99310921 | 3.313035 | 11.899% | 8.787% | 121.168% |
| GeForce RTX 3090 | BF16 | 0.99932075 | 1.026024 | 3.685% | 5.153% | 116.133% |
| GeForce RTX 4090 | BF16 | 0.99890321 | 1.303894 | 4.683% | 6.415% | 117.018% |
| L4 | BF16 | 0.99593113 | 2.520465 | 9.053% | 7.868% | 134.928% |
| RTX PRO 6000 Blackwell Workstation Edition | BF16 | 0.99906424 | 1.216129 | 4.368% | 6.005% | 121.920% |
The single RTX 3060 FP32 and BF16 deltas differed by **20.722%** in global relative L2 using FP32 as the baseline. The table compares saved runs. Each GPU and configuration has one observed run, so the measurements cannot isolate GPU model effects from driver and kernel differences or estimate deployment thresholds. Cross-GPU training and two-GPU DDP were not rerun for this analysis.
### Round records and trust assumptions
Workers and aggregators may submit incorrect data or become unavailable. Independent auditors need access to the public inputs and retained artifacts, plus a way to replay disputed segments. Independent witnesses cross-check signed log heads. Retain replicated artifact bodies through the full audit period.
| Record | Required fields |
| --- | --- |
| `run_manifest` | Code commit, immutable image digest, software versions, model/tokenizer/dataset revisions, SHA-256 of shards and token chunks, sample order, packing, EOS, masks and loss rules, step-by-step batch plan or pinned generator and seed, audit policy, and randomness source |
| `worker_commit` | Run, round, worker and attempt IDs, global starting checkpoint root, local starting state root, ending state and submitted delta roots, intermediate checkpoint roots, assigned data root, execution profile, optimizer step count, token count, and worker signature |
| Restart state | Model parameters and buffers, AdamW moments and step counters, scheduler, FP32 master weights and loss scaler where applicable, rank-specific Python/NumPy/CPU/GPU RNG state, and input cursor. Save at optimizer-step boundaries or include partially accumulated gradients. |
| `round_record` | Previous round root, all submissions and acceptance or rejection reasons, worker weights, delta sign and normalization, clipping and quantization rules, reduction order and dtype, rounding rules, outer optimizer state before and after the round, and next global model root |
| `audit_record` | Commitment inclusion proof, beacon chain and pulse, beacon proof and derived seed, fingerprint algorithm version and values, sampled segments, submitted and replayed artifact digests and environments, calibration policy ID, raw measurements, verdict, and auditor signature |
For example, define the worker delta as `d_i = W_local - W_global` and feed `-Σ a_i d_i` to the outer optimizer as its pseudo-gradient. Link every worker to the previous accepted global checkpoint. Record whether local optimizer state is reset or carried forward. With carryover, link the local starting state to the worker's previously accepted state. Recompute aggregation from the accepted transmitted bytes using a fixed worker order and reference arithmetic. If quantization is enabled, verify the conversion from the local ending state to the transmitted representation.
Use whole-file hashes for download integrity. Define a canonical tensor encoding that includes the name, shape, dtype, endianness, byte order, chunk index, and length. Use length-delimited fields and domain separation when building a signed SHA-256 Merkle root. Independent witnesses should exchange signed tree heads and verify inclusion and consistency proofs. Conflicting signed submissions for the same assignment establish equivocation. A numerical mismatch warrants replay and investigation. [RFC 9162](https://www.rfc-editor.org/rfc/rfc9162.html)
### Commit the delta before drawing the fingerprint
1. Before the deadline, the worker publishes signed roots for its delta and all replay checkpoints. Independent storage operators verify and retain the underlying artifacts. Fix the accepted submission set and allow one accepted attempt per assignment. Specify the deadline and future beacon pulse in the run policy.
2. After witnesses confirm the log head, verify the designated public randomness pulse and its signature. For example, derive `seed = SHA256(canonical("diloco/audit/v1", beacon_id, pulse, beacon_value, run_id, round, worker_id, delta_root))`. Derive separate streams for tensor fingerprints and segment sampling. Use uniform sampling without replacement for segment indices. Enforce a predeclared outage policy and keep the original submission fixed after the pulse. [drand cryptography](https://docs.drand.love/docs/cryptography/)
3. Auditors verify the stored tensors against their roots and compute fingerprints from those tensors. Specify the PRNG and byte encoding, such as SHAKE256-derived Rademacher signs with fixed-order FP64 accumulation. Specify the sign of zero and handling of nonfinite values. Store sign bits, L2 norms, normalized continuous projections, the seed, and the algorithm version. Publish small test vectors so third parties can reproduce the calculation.
4. Project the replayed delta with the same seed and retain both results. Later auditors can reproduce the original comparison or use a new beacon against the same committed artifacts. When the full tensors are available, compute exact per-tensor residuals alongside the fingerprints.
For a fixed residual `e = d_submitted - d_replay`, independent Rademacher projections `z_j = r_j · e` satisfy `E[z_j²] = ||e||₂²`. Continuous projections retain magnitude information that sign bits omit. For isotropic Gaussian hyperplanes, the expected bit disagreement rate is the angle divided by π. Calibrate the Rademacher implementation empirically. Drawing the seed after commitment prevents a worker from choosing the committed bytes in response to that draw. Detection still depends on residual size, normal GPU variation, artifact availability, and audit coverage.
### Compare replays across GPUs
Replay the same worker assignment from the same starting state using the same data order and precision policy. Comparing workers trained on different shards confounds hardware differences with differences in training data.
| Stage | Verification |
| --- | --- |
| Artifact integrity | Check signatures, data and state roots, hashes, schema, tensor shapes, nonfinite values, and the round chain before numerical comparison. |
| Matched replay | Test bitwise repeatability for the same GPU class, image, rank placement, and reduction settings. Where repeatability has been demonstrated, compare canonical ending-state and delta hashes. |
| Cross-GPU replay | Calibrate each worker/auditor profile pair by training precision, DDP topology, and replay length. Hold the verdict for an uncalibrated pair and replay on a matched profile or independent verified hardware. |
| Numerical metrics | Measure global relative L2 and cosine, per-tensor absolute and scale-adjusted L2, maximum and high-quantile element errors, Hamming distance and projected residuals, AdamW moments and steps, and segment loss. Use an absolute floor for near-zero tensors. |
| Out-of-bounds results | Repeat the replay and have an independent auditor confirm it. Record the evidence for numerical anomalies, reproducible rule violations, or missing artifacts. |
One candidate per-tensor bound is `||d_submit,t − d_replay,t||₂ ≤ a_t √n_t + b_t ||d_replay,t||₂`. Fit `a_t` and `b_t` on independent normal replays. Calibrate a round-level maximum or hierarchical rule on held-out runs to account for testing 148 tensors. Include element-level statistics for sparse errors. Vary data order, seed, round, and hardware across calibration and evaluation. With zero flags in `n` independent normal rounds, the approximate 95% upper bound on the false-positive rate is `3/n`. An upper bound near 1% therefore requires about 300 independent rounds with zero flags.
Record the GPU model and compute capability, driver, CUDA/cuBLAS/cuDNN/NCCL versions, PyTorch/Transformers/Accelerate versions, TF32, autocast and accumulation dtypes, attention and optimizer implementations, clipping and determinism settings, rank placement, DDP buckets, and collective settings. Collect normal replay pairs when adding a GPU profile. Small FP64 reference checks can help investigate reduction and optimizer updates. Full FP64 training requires separate calibration. [PyTorch reproducibility documentation](https://docs.pytorch.org/docs/stable/notes/randomness.html)
### Replay coverage, cost, and response
- **Full replay.** Execute all `H` local steps from the accepted global model and recorded local state. Verify the ending model and optimizer state, derive the worker delta and its transmitted representation, then recompute aggregation and the outer optimizer.
- **Sampled replay.** Split each worker round into `M` contiguous blocks and commit complete restart states for all boundaries. Anchor the first boundary to the accepted starting state and the last to the submitted result. Use the beacon to select `k` distinct blocks and replay each from its committed start to its committed end. Mix in random full-round replays to verify complete worker histories. Report the replay coverage with each verdict. [Proof-of-Learning](https://arxiv.org/abs/2103.05633)
- **Detection probability.** If `b` blocks contain a violation that would exceed the replay threshold and `k` blocks are drawn uniformly without replacement, the detection probability is `1 − C(M−b,k)/C(M,k)`. For 500 steps split into ten 50-step blocks, checking three blocks costs 150 steps per worker and detects one violating block with 30% probability or three violating blocks with about 70.8% probability.
- **Storage and computation.** The FP32 delta is about 498 MB. The model and two FP32 AdamW moment tensors require about 1.49 GB per restart state, or 14.9 GB for ten additional boundaries per worker-round when the starting state is shared. Sign bits alone take about 38.5 kB. Applying 2,048 dense projections to every element takes about 255 billion terms per delta. Measure detection performance if projection count or coverage is reduced. Exact L2 can be computed in a single linear scan. Replicate and periodically download retained artifacts to verify availability.
- **Incident response.** Append the auditor's findings to the same log and replay adjacent segments to locate the first divergence. For a confirmed invalid update or aggregation, restore the previous accepted model and outer optimizer state, recompute the round from valid submissions, and replay downstream rounds from the corrected checkpoints.
### Rollout
1. Extend the GPT-2 experiment with pinned input revisions, token chunks, complete checkpoints, and a separate offline replay verifier. Use the published clean and modified deltas as regression fixtures for artifact and fingerprint checks.
2. Start with RTX 3060 single-GPU and two-GPU DDP runs plus L4, testing FP32 and BF16 at 1, 10, 50, and 500 steps. Collect matched repeats and cross-GPU pairs. Treat the CMP 170HX outlier as a separate calibration case.
3. Exercise commit deadlines, beacon selection, and retry rules in a pilot. Test skipped steps, wrong data or optimizer state, sparse numerical errors, missing artifacts, and incorrect aggregation weights. Freeze thresholds before held-out evaluation and record false-positive rates, detection rates by fault type, audit cost, and recovery time.
4. Define the assurance as whether the signed update agrees with the prescribed training computation. Public inputs allow another machine to perform that computation. Physical GPU provenance and model safety require separate evidence.