## 2 Methods: FMTL Framework
### FedAvg Algorithm  
The FMTL framework extends the standard FedAvg algorithm to support multi-task learning with client-specific model heads. Specifically, we assume the global model is denoted as  
\[\theta=\left\{\theta_{sh},\theta_{stage},\theta_{sdb}\right\} \tag{1}\]  
where \(\theta_{sh}\) represents the shared encoder, and \(\theta_{stage}\) and \(\theta_{sdb}\) are the task-specific heads for sleep staging and SDB severity classification, respectively. Figure 1: The overall architecture of the FMTL framework. At the beginning of each communication round \(t\), the server selects a random subset of clients and broadcasts the current shared parameters \(\theta_{sh}^{t}\) to them. Each selected client \(k\) performs \(E\) epochs of local multi-task training using its private PSG data and returns the updated shared parameters \(\theta_{sh,k}^{(t+1)}\). The server then aggregates these updates using a sample-weighted average:  
\[\theta_{th}^{(t+1)}=\frac{\sum_{k\in S_{t}}n_{k}\theta_{sh,k}^{(t+1)}}{\sum_{j \in S_{t}}n_{j}} \tag{2}\]  
where \(S_{t}\) is the set of clients that successfully upload updates in round \(t\), and \(n_{k}\) is the number of local training samples at client \(k\). Importantly, each client retains its own task-specific heads \(\theta_{stage,k}\) and \(\theta_{sth,k}\), which are not aggregated and evolve independently to support personalized adaptation. To emulate realistic deployment conditions in clinical federated learning, we modeled client-side heterogeneity during training. Each participating client was assigned a randomized training time budget \(\tau_{k}\in[60,\,180]\) seconds, reflecting local computational capacity variability. If a client fails to complete its prescribed local training within this time limit, it prematurely terminates and is excluded from the current aggregation round. In addition, we simulate network variability by sampling each client's available upload bandwidth \(b_{k}\) from a range of 50 to 500 KB/s. This constraint affects the time required to transmit model updates to the central server. Furthermore, to capture potential device dropout or environmental interruptions, each client faces an independent stochastic dropout probability of \(p_{drop}=0.1\). These mechanisms collectively introduce realistic training dynamics that mirror operational constraints in multi-institutional healthcare settings, ensuring that our federated protocol remains robust under non-ideal conditions. If a client fails to finish training within its time limit or exceeds a 60 s communication window, it is excluded from that round's aggregation. Furthermore, if fewer than \([C\cdot K/2]\) clients return updates, the server skips aggregation and retains the previous global model, i.e., \(\theta_{sh}^{(t+1)}=\theta_{sh}^{(t)}\). To enhance privacy, each client may optionally apply gradient clipping and inject Gaussian noise into its updates to satisfy \((\epsilon,\,\delta)\) differential privacy. We adopt a modified FedAvg training loop, outlined in Algorithm 1, where only the shared feature extractor is globally aggregated, while task-specific heads are retained locally on each client to support personalization. At the beginning of each round, a random subset of clients receives the global encoder and trains for a fixed number of local epochs. Clients that fail due to computational or network constraints are excluded from aggregation. The server aggregates updates from successful clients using sample-size-weighted averaging.