---
title: 'FedNSAM: Federated Nesterov SAM'
url: https://www.emergentmind.com/topics/fednsam
type: topic
---

# FedNSAM: Federated Nesterov SAM

Searching arXiv for FedNSAM and closely related federated SAM papers to ground the article.
FedNSAM is a federated-learning optimizer introduced in “FedNSAM: Consistency of Local and Global Flatness for Federated Learning” [2602.23827]. It addresses a specific limitation of SAM-style federated optimization: under multi-step local updates and high data heterogeneity, flatness obtained on individual clients does not necessarily translate into a flat global solution after aggregation. The method formalizes this mismatch through a flatness distance and modifies local SAM training by introducing global Nesterov momentum into both perturbation estimation and extrapolation. In the paper’s formulation, the objective is not merely to make local losses flat, but to harmonize the consistency of local and global flatness while retaining the generalization-oriented motivation of sharpness-aware minimization [2602.23827].

## 1. Problem setting and motivating failure mode

FedNSAM is posed in the standard federated setting with global objective
\[
F(\theta)=\frac{1}{N}\sum_{i=1}^N F_i(\theta),
\]
where \(F_i\) is client \(i\)’s local loss. The paper focuses on the case in which local client training uses SAM-like updates to search for flatter minima, but the client data are non-IID and local training proceeds for multiple steps between communications [2602.23827].

The central claim is that, in federated learning, locally flat solutions can be mutually inconsistent. When data are close to IID, client update directions are similar, local flat regions overlap, and the averaged global model may lie in a shared flat region. When data are highly heterogeneous, client updates point in different directions, each client’s flat region can be located differently, and the averaged global model may fall outside those flat regions. In that regime, minimizing the sharpness of local loss surfaces does not ensure flatness of the aggregated model, so the generalization benefit usually associated with SAM can deteriorate [2602.23827].

This framing places FedNSAM in direct continuity with FedSAM, which applies sharpness-aware minimization as the local optimizer in federated learning [2206.02618]. FedNSAM does not reject SAM’s objective; rather, it argues that the local perturbation direction must be made globally consistent if flatness is to remain meaningful after aggregation under heterogeneity.

## 2. Flatness distance and the local–global consistency question

To formalize the gap between local and global flatness, the paper defines the **flatness distance**. If the global model at round \(t+1\) is
\[
\theta^{t+1}=\frac{1}{N}\sum_{i=1}^N \theta_{i,K}^t,
\]
where \(\theta_{i,K}^t\) is client \(i\)’s model after \(K\) local steps in round \(t\), then the flatness distance is
\[
\Delta_{\mathcal{D}}=\frac{1}{N}\sum_{i=1}^N \mathbb{E}\left\|\theta_{i,K}^t-\theta^{t+1}\right\|^2.
\]
This quantity measures how far the local terminal models are from the aggregated global model [2602.23827].

The interpretation is geometric and operational. Small \(\Delta_{\mathcal{D}}\) means that local models cluster, so their flat regions are closer and global flatness is more plausible. Large \(\Delta_{\mathcal{D}}\) indicates that local models are dispersed, so local flat regions differ and the average model is less likely to lie in a flat region. The paper uses this as the key explanation for why FedSAM can be effective under low heterogeneity yet degrade under strong heterogeneity [2602.23827].

The empirical narrative in the paper follows the same logic. As heterogeneity increases, \(\Delta_{\mathcal{D}}\) increases and test performance degrades. The paper explicitly reports that, on CIFAR-100 with ResNet-18, FedSAM’s accuracy drops sharply under stronger heterogeneity, whereas FedNSAM maintains a much smaller flatness distance and substantially better accuracy. This suggests that FedNSAM is best understood not simply as an accelerated SAM variant, but as a method for controlling the mismatch between client-wise flatness and server-side aggregation.

## 3. Algorithmic mechanism: SAM with global Nesterov momentum

FedNSAM combines SAM’s perturbation-based flatness search with Nesterov momentum, but the crucial modification is that the momentum is global rather than client-local. The server maintains
\[
m^t=\lambda m^{t-1}+\Delta^t, \qquad \Delta^t=\frac{1}{S}\sum_{i\in S_t}\Delta_i^t, \qquad \Delta_i^t=\theta_{i,K}^t-\theta_{i,0}^t,
\]
where \(S_t\) is the set of selected clients, \(S=|S_t|\), and \(\lambda\in[0,1)\) is the momentum parameter [2602.23827].

The paper’s approximation is that the desired global perturbation direction can be estimated through this momentum:
\[
\delta_k^t = \rho \frac{\nabla F(\theta_k^t)}{\|\nabla F(\theta_k^t)\|} \approx \rho \frac{m^t}{\|m^t\|}.
\]
This is the conceptual pivot of the algorithm. Standard FedSAM constructs perturbations from local gradients; FedNSAM replaces that with a shared direction derived from server-side momentum, so the perturbation geometry becomes aligned across clients [2602.23827].

The local update uses a three-stage sequence. First, a Nesterov extrapolation:
\[
\theta_{i,k+1/4}^t=\theta_{i,k}^t+\lambda m^t.
\]
Second, a SAM-style perturbation along the global momentum direction:
\[
\delta_{i,k}^t=\rho \frac{-m^t}{\|m^t\|},
\qquad
\theta_{i,k+1/2}^t=\theta_{i,k+1/4}^t+\delta_{i,k}^t.
\]
Third, a local gradient step evaluated at the perturbed point:
\[
\theta_{i,k+1}^t = \theta_{i,k}^t-\eta \nabla F_i(\theta_{i,k+1/2}^t;\zeta_i).
\]
After \(K\) local updates, clients transmit the model drift \(\Delta_i^t\), the server aggregates them, updates \(m^t\), and applies
\[
\theta^t=\theta^{t-1}+m^t.
\]
The paper emphasizes two consequences: perturbation correction, because client perturbations become globally consistent, and update acceleration, because Nesterov extrapolation improves optimization speed [2602.23827].

## 4. Theoretical analysis

The convergence analysis is carried out for non-convex objectives under three standard assumptions: each client loss is \(L\)-smooth,
\[
\|\nabla F_i(x)-\nabla F_i(y)\|\le L\|x-y\|,
\]
client heterogeneity is bounded,
\[
\|\nabla F_i(\theta)-\nabla F(\theta)\|^2\le \sigma_g^2,
\]
and stochastic gradient variance is bounded,
\[
\mathbb{E}_{\xi_i}\|\nabla F_i(\theta,\xi_i)-\nabla F_i(\theta)\|^2\le \sigma^2.
\]
Under a stepsize condition
\[
\eta \le \frac{(1-\lambda)^2}{128KL}, \qquad \rho=\mathcal{O}(1/\sqrt{T}),
\]
the paper proves a convergence rate and states that it is tighter than the corresponding FedSAM bound because the dominant term scales more favorably with \((1-\lambda)\), reflecting Nesterov acceleration [2602.23827].

A second theoretical thread concerns flatness distance itself. The paper provides upper bounds for both FedSAM and FedNSAM and states that FedNSAM achieves a better upper bound. The key technical reason is a perturbation-consistency lemma:
\[
\frac{1}{N}\sum_i \mathbb{E}\left[\|\delta_{i,k}^t-\delta_{i,0}^t\|^2\right]=0
\]
for FedNSAM, because the perturbation direction is shared across local steps within a round. In FedSAM, the corresponding term is nonzero and is bounded by a quantity proportional to \(K^2L^2\eta^2\rho^2\). This is the paper’s main analytical explanation for why local–global flatness mismatch is reduced in FedNSAM [2602.23827].

The proof strategy introduces a transformed sequence \(z^t=\theta^t+\frac{\lambda}{1-\lambda}m^t\), uses smoothness to track descent in \(F(z^t)\), and bounds the effects of momentum, stochasticity, and heterogeneity. A plausible implication is that FedNSAM’s advantage is not only better search of flat regions, but more stable propagation of a shared geometry across clients.

## 5. Empirical evaluation

The experiments are designed to test both optimization speed and generalization under heterogeneous federated learning. On CNNs, the paper evaluates LeNet-5, VGG-11, and ResNet-18 on CIFAR-10 and CIFAR-100. Non-IID splits are generated with Dirichlet heterogeneity levels \(0.6\), \(0.3\), and \(0.1\), where Dirichlet-\(0.6\) denotes lower heterogeneity and Dirichlet-\(0.1\) denotes high heterogeneity. The paper reports that, on CIFAR-10 and CIFAR-100 with Dirichlet-0.6 and 100 clients, FedNSAM achieves the best accuracy across all three CNN architectures [2602.23827].

One reported example is CIFAR-100 with ResNet-18, where the paper gives
- FedNSAM: **66.04%**
- FedSAM: **47.83%**

The communication-efficiency comparison is similarly explicit. On CIFAR-100 with ResNet-18, FedNSAM reaches 55% accuracy in **316 rounds**, whereas FedSAM needs **1000+** rounds. The paper interprets this as evidence of both improved optimization and improved generalization [2602.23827].

The transformer experiments use Tiny ImageNet with Swin-Small, Swin-Base, and ViT-Base, initialized from ImageNet-22k pre-trained weights. The reported setting is 100 communication rounds, Dirichlet-0.1, 5% participation, batch size 16, and learning rate 0.01 decayed by 0.99. FedNSAM again achieves the best reported accuracies:
- Swin-Small: **70.12%**
- Swin-Base: **70.86%**
- ViT-Base: **71.23%**

It also reaches the target threshold in **67**, **42**, and **26** rounds, respectively. The paper further studies participation rates of **2%**, **5%**, and **10%**, reporting that FedNSAM remains consistently strong when fewer clients participate and when heterogeneity worsens. This supports the claim that the momentum-based global direction estimate is robust under partial participation [2602.23827].

## 6. Position within the federated-learning literature and naming issues

FedNSAM belongs to the line of federated methods that import sharpness-aware minimization into local client optimization. The immediate precursor is FedSAM, introduced as a federated method that replaces local ERM with the SAM min–max objective and, in its base form, is essentially FedAvg with SAM as the local optimizer [2206.02618]. FedNSAM differs by using global Nesterov momentum as the direction of local estimation of client global perturbations and extrapolation, thereby addressing a limitation that the FedNSAM paper identifies in high-heterogeneity regimes.

The name can be confused with other federated methods whose abbreviations begin with “FedN” or “FedS.” It should be distinguished from **FedNS**, the Newton-sketch method in “FedNS: A Fast Sketching Newton-Type Algorithm for Federated Learning,” which communicates sketched square-root Hessians and targets second-order communication efficiency rather than sharpness-aware flatness consistency [2401.02734]. It should also be distinguished from **pFedSAM**, a personalized federated framework for Segment Anything Model adaptation in medical image segmentation, where “SAM” refers to the foundation model rather than sharpness-aware minimization [2509.15638].

A recurrent misconception in the broader literature is that local flatness is sufficient for global generalization in federated training. FedNSAM is centered on rejecting that assumption. Its defining contribution is the claim that, in federated learning, flatness is meaningful only if the client-side perturbation and update directions are coordinated strongly enough that the aggregated model remains within the relevant flat region. This suggests that the “N” in FedNSAM refers to the incorporation of Nesterov momentum, though the paper’s substantive contribution is not nomenclature but the consistency of local and global flatness [2602.23827].

Source: https://www.emergentmind.com/topics/fednsam