# A Multi-Machine and Multi-Modal Drift Detection (M2D2) Framework for Semiconductor Manufacturing
## 3 Methodology
### Phase 6: Drift-Aware Federated Learning  
In large-scale industrial environments spanning multiple machines or even multiple companies, FL has become a key approach to consolidating distributed knowledge under strict privacy and communication constraints. However, most existing frameworks--such as FedAvg or FedProx--merely average local parameters from each site without considering drift discrepancies across machines (sites). When one or more machines experience significant distributional shifts, the global model can be severely degraded. Moreover, if the federated process solely focuses on parameter updates (e.g., aggregating weights) without incorporating the maintenance and drift detection insights from earlier phases (Phase 2, Phase 3), it cannot deliver true \"intelligent operations and maintenance\". To address these issues, we enhance the original Phase 6 into a drift-aware federated learning and maintenance paradigm. By integrating dynamic aggregation weights, collective drift responses, multi-head/multi-task architectures, and a closed-loop approach with interpretability and maintenance decisions, federated learning becomes the driving force in our M2D2 framework. 1. Drift Score Calculation and Upload: Building on Phase 2 (short-term detection) and Phase 3 (long-term detection), each machine \(k\) in round \(r\) computes one or more drift scores, denoted by \(\delta_{k}^{r}\). A straightforward approach is to combine short-term reconstruction errors (\(E_{recon}^{r}\)) with long-term distributional distances \(\big{(}D_{dist}^{r}\big{)}\) using weighted sums: \[\delta_{k}^{r}=\alpha\cdot E_{recon,k}^{r}+\beta\cdot D_{dist,k}^{r},\] (12) where \(E_{recon,k}^{r}\) typically reflects the short-term anomaly or reconstruction error as described in Phase 2. \(D_{dist,k}^{r}\) can be a KL-divergence, Wasserstein distance, or any metric quantifying the long-term shift from a baseline distribution (Phase 3). \(\alpha\) and \(\beta\) are hyperparameters used for regulating the relative importance of short-term versus long-term drift. In practice, if one needs finer distinctions, \(\delta_{k}^{r}\) can be a vector (\(\delta_{k,short}^{r}\), \(\delta_{k,long}^{r}\)), thereby allowing separate policies for immediate vs. gradual shifts. 2. Drift-Aware Aggregation Weights: Traditional FL methods, such as FedAvg, compute the global model by weighting local parameters \(\theta_{k}^{r}\) using the data size \(\big{|}D_{k}^{r}\big{|}\): \[\theta_{global}^{r+1}=\sum_{k=1}^{K}\frac{\big{|}D_{k}^{r}\big{|}}{\sum_{j=1}^ {K}\big{|}D_{j}^{r}\big{|}}\theta_{k}^{r}.\] (13) However, if different machines exhibit heterogeneous drift, a naive averaging scheme can allow heavily drifting clients to \"pull\" the global parameters off track. To mitigate this, we introduce drift-aware weight \(f\big{(}\delta_{k}^{r}\big{)}\): \[w_{k}^{r}=\frac{\big{|}D_{k}^{r}\big{|}}{\sum_{j=1}^{K}\big{|}D_{j}^{r}\big{|} }.f(\delta_{k}^{r}),\theta_{global}^{r+1}=\sum_{k=1}^{K}w_{k}^{r}\theta_{k}^{r}.\] (14) The function \(f(\delta)\) decreases with \(\delta\) to downweight clients that are heavily drifting. Common choices for \(f\) include \[f(x)=\exp(-\lambda x)\;or\;f(x)=\frac{1}{1+\lambda x},\] (15) where \(\lambda>0\) controls how strongly the system penalizes drift. By adjusting \(\delta_{k}^{r}\) and \(\lambda\), the global model remains robust against outliers or heavily drifting sites. 3. Adaptive Rounds and Micro-Rounds 1. Micro-Round Trigger When machine \(k\) reports \(\delta_{k}^{r}\) that exceeds threshold \(\gamma\), the server can trigger micro-rounds to afford extra local updates before final aggregation. Let \(\mathscr{C}(\theta;D_{k}^{r})\) represent the local loss function (e.g., reconstruction or contrastive loss in earlier phases).