core/coop/param_avg library
Parameter averaging for DiLoCo-style cooperative training.
Given N checkpoints produced by Checkpoint.saveBytes over the same module architecture, averageCheckpoints returns a fresh DPTC checkpoint whose parameter tensors are the (optionally weighted) arithmetic mean of the sources.
All checkpoints must share an identical header (same version, same parameter shapes in the same order). This is verified by comparing header bytes byte-for-byte; a mismatch throws ArgumentError.
Optional per-checkpoint weights let you weight by the number of
local training steps each peer performed (as in FedAvg), so
long-training peers pull the average further toward their solution.
Weights are renormalised to sum to 1; passing null means uniform.