<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Abhinandan De on Medium]]></title>
        <description><![CDATA[Stories by Abhinandan De on Medium]]></description>
        <link>https://medium.com/@abhinandan0316?source=rss-6ff9673a22ba------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*eRBCLLijpK62KfgA</url>
            <title>Stories by Abhinandan De on Medium</title>
            <link>https://medium.com/@abhinandan0316?source=rss-6ff9673a22ba------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 23:34:29 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@abhinandan0316/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Distributed Machine Learning: spread updates, not data!]]></title>
            <link>https://medium.com/@abhinandan0316/distributed-machine-learning-spread-updates-not-data-f563cfc5975?source=rss-6ff9673a22ba------2</link>
            <guid isPermaLink="false">https://medium.com/p/f563cfc5975</guid>
            <category><![CDATA[federated-learning]]></category>
            <category><![CDATA[decentralization]]></category>
            <category><![CDATA[distributed-systems]]></category>
            <category><![CDATA[fault-tolerance]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Abhinandan De]]></dc:creator>
            <pubDate>Tue, 07 Feb 2023 16:16:47 GMT</pubDate>
            <atom:updated>2023-02-07T20:51:16.920Z</atom:updated>
            <content:encoded><![CDATA[<p>This blog has been co-authored by Animesh Jha, Aryan Singh, Parth Jindal, Pranav Rajput, and Vinit Raj.</p><p>Machine learning and artificial intelligence are rapidly evolving fields, with new advances being made every day. One area that has seen significant growth in recent years is distributed machine learning systems. Such systems are used to train large models using large amounts of data, allowing them to process and analyze large amounts of information. This blog reviews the various aspects of modern Distributed Machine Learning.</p><blockquote>We begin with a distributed algorithm which allows us to perform fast distributed SGD for training machine learning models. We then look into the paradigm of Federated Learning from the lens of Distributed Systems. Specifically, we dive into two distributed algorithms making communication-efficient decentralized machine learning possible, and then we explore the Fair Resource Allocation problem in Federated Learning. Next, we survey the Byzantine Fault Tolerance of Distributed Learning. Finally, we learn about Fully Decentralized Algorithms for Machine Learning and a surprising result where decentralization outperforms centralized algorithms under specific settings.</blockquote><h3>HOGWILD!</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NE8lClijgGT39LpI" /><figcaption>Does the title bring this image to your mind?</figcaption></figure><p>Back in 2011, when frameworks like PyTorch and TensorFlow weren’t as popular, people focused on improving the speed of vanilla ML algorithms. A natural direction of thought was to pursue parallel processing. Let&#39;s consider our famous SGD algorithm. How would we correctly process the data? Partition it, share the model across processes and update it using precautionary locking methods. Simple! But it comes at a cost. One would expect the runtimes to decrease by increasing the number of available cores, but this isn’t the case. The locking operation induces significant overheads and doesn’t scale very well. So locking is the culprit. Okay, What do we do now?</p><blockquote>Remove the locks?</blockquote><p><strong>Preposterous</strong>! The updates will be overwritten, th-they’ll be stale, and i-it might not even converge!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/665/0*SQ86Q0112yBN916Z" /><figcaption>The student and his professor had a similar conversation when the former discovered a helpful speedup after a hard toil.</figcaption></figure><p>That’s where the authors of HOGWILD! came in and verified that this indeed works! However, there is a secret ingredient: <strong><em>sparsity</em></strong>! Let’s say our goal is to minimize a function f such that:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*utVNSAPy10CVwqC2gQIHnw.png" /><figcaption>The assumption is that f_e acts on a small number of components of x.</figcaption></figure><p>With this base and some tens of pages of math, the authors prove that HOGWILD! does indeed converge and provide near optimal answers for three different scenarios viz. Sparse SVM, Matrix Completion and Graph Cuts. This brought about a revolution as removing locks resulted in a linear speedup <em>wrt </em>the number of cores.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MvU13hRimasprIbC" /><figcaption>Sample the particular instance, compute the Gradient matrix and do the regular ‘ole update!</figcaption></figure><p><strong>Communication-Efficient Learning of Deep Networks from Decentralized Data</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/419/0*PUY1qVEgfADSOeiz" /><figcaption><em>Leveraging user data for training models has serious issues.</em></figcaption></figure><p>Now, we look into Federated Learning (FL), a powerful technique that allows for training statistical models on many decentralized devices, such as smartphones or IoT devices. By leveraging these devices’ data and computational resources, FL enables the training of highly accurate and reflective models of real-world data. One of the main challenges in FL is ensuring that data is distributed and stored in a way that preserves privacy and security. The authors of this paper described a straightforward and practical algorithm that can be applied to this setting.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/0*8cje41W_ZvLDi1j1" /><figcaption>Federation of nodes</figcaption></figure><p>The described algorithm applies to any finite-sum objective of the form :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/372/0*BrvxhgE-h2r3cP6e" /></figure><p>Here, f_i(w) is the loss computed on a particular data point. There are kclients and everyone has n_k data points, with n being the total. then the objective can be rewritten as :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/389/0*pGcXFOM54eLdbjnL" /></figure><p>First, the authors create a baseline algorithm <em>FederatedSGD</em> where they select a C-fraction of the clients in each round and compute the loss gradient over all the data held by these clients. In a typical implementation with C = 1 and a fixed learning rate η has each client k compute g_k = ⛛F_k(w_t), the average gradient on its local data at the current model w_t, and the central server aggregates these gradients and applies the update:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/186/0*7VqUKvBsIf0TZQKw" /></figure><p>An equivalent update can be given by</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/378/0*qQWfEO9R-lm8uGEc" /></figure><p>However, this algorithm is extremely inefficient, requiring many iterations for convergence. This leads to high communication costs, making it unscalable, given that FL is usually used with edge devices with limited communication bandwidth.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/570/0*yOIrHHXzCv2Du_Ik" /><figcaption>The Federated Averaging algorithm</figcaption></figure><p>In the proposed FederatedAveraging algorithm, the authors iterate the update multiple times on a client before sending the update. This reduces the rounds of communication needed to train a deep network on decentralized data by orders of magnitude!</p><h3>SCAFFOLD</h3><p>Federated Averaging (FEDAVG) has emerged as the algorithm of choice for federated learning due to its simplicity and low communication cost. However, despite recent research efforts, its performance still needs to be fully understood. The authors first obtain tight convergence rates for FEDAVG and prove that it suffers from <em>client-drift</em> when the data is heterogeneous (non-iid), resulting in unstable and slow convergence. As a solution, they propose a new algorithm (SCAFFOLD) which uses control variates (variance reduction) to correct for the ‘client-drift’ in its local updates. They prove that SCAFFOLD requires significantly fewer communication rounds and is not affected by data heterogeneity or client sampling. Further, they show that (for quadratics) SCAFFOLD can take advantage of the similarity in the client’s data yielding even faster convergence. The latter is the first result to quantify the usefulness of local steps in distributed optimization.</p><p>Here, we first describe SCAFFOLD and then discuss how it solves the problem of client drift.</p><p><strong>Method:</strong></p><p><strong>Initialization:</strong> Each device starts with a local model, and the server maintains a global model.</p><p><strong>Random perturbation:</strong> Before each iteration of federated learning, each device adds a random perturbation to its local model. A scalar parameter called the <em>noise scale</em> controls the size of this perturbation.</p><p><strong>Local update:</strong> Each device trains its local model using its data.</p><p><strong>Averaging:</strong> Each device sends its updated model to the server, averaging all the models to create a new global model.</p><p><strong>Convergence check:</strong> The server checks if the global model has converged to a satisfactory solution.</p><p><strong>Repeat:</strong> If the global model has not converged, the algorithm returns to step 2 and repeats the process.</p><p><strong>Final result: </strong>When the global model has converged, the final result is returned to the devices for use.</p><p>The key idea behind SCAFFOLD is to use random perturbations to control the convergence rate of federated learning. The random perturbations encourage convergence to a common solution, even when devices have different data distributions or processing capabilities. Additionally, the averaging process ensures that the final result is robust and the communication efficiency is improved compared to traditional federated learning algorithms.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/1*R9YmdIAZEGBoBwsG7vdxHA.png" /><figcaption>SCAFFOLD models <strong>diverse</strong> distributions of data robustly without a loss in performance with an improved communication efficiency concerning FedAvg</figcaption></figure><h3>Fair Resource Allocation in Federated Learning</h3><p>Federated learning involves training statistical models in massive, heterogeneous networks. Naively minimizing an aggregate loss function in such a network may disproportionately favour some of the devices. To achieve a more <strong>fair</strong> (or uniform) distribution of accuracy across devices in federated settings, optimization objectives inspired by fair resource allocation in wireless networks have been suggested in recent literature (q-FFL). The same authors behind q-FFL came up with a communication-efficient method q-FedAvg, to solve q-FFL. q-FedAvg outperforms existing baselines in terms of the resulting fairness, flexibility, and efficiency.</p><p>A typical objective that is solved for a Federated Learning problem is to fit a global model W by minimizing a loss function which is a weighted average of the local loss.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/345/0*q1b9SsrbAwwhItdd" /></figure><p>Where Fk is the loss on the kth device and p_k is the weight of the device.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3mVWIN8ILPQOJflL" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/950/0*C3MPIfuN-fEOIzCQ" /></figure><p>q-FFL minimizes an aggregate weighted loss parameterized by q such that the devices with higher loss are given higher relative weight. This objective was inspired by 𝛼-fairness for fair resource allocation in wireless networks. It enables flexible fairness accuracy trade-offs through a tunable parameter q. When q is equal to zero, q-FFL recovers the previous objective. When q is large enough (i.e. q = ∞), the objective reduces to classic minmax fairness, where the goal is to minimize the loss of the worst-performing device. Generalization guarantees are there for q-FFL in theory and also that increasing q results in more uniform accuracy distributions (in terms of variance uniform measures such as variance). The graph below shows the accuracy distribution of a model trained by the baseline approach and the q-FFL approach.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/388/0*-AaJ_Y30_-lZ7mtf" /><figcaption>The table shows almost equal values for accuracy, whether it be the average, the best or the worst 10%, but decreased variance by 45%</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/817/1*0QYJeGl27p8ezkcil22D8A.png" /><figcaption>In case you fell asleep while going through the math : )</figcaption></figure><h3>Byzantine Fault Tolerant Distributed Learning</h3><p>While distributed machine learning has become increasingly popular recently, it has largely ignored the possibility of failures, especially Byzantine failures. The most robust system is one that tolerates Byzantine failures, i.e., completely arbitrary behaviours of some of the processes. Byzantine failures can be caused by various factors, including software bugs, network asynchrony, biases in local datasets, and even attackers trying to compromise the entire system.</p><p>The most common method for handling failures in distributed systems is to use state machine replication protocol. However, in the context of distributed machine learning, this approach creates problems. There are two ways replication can be done for distributed machine learning. First, processes agree on a data sample to update their local parameter vectors, which requires heavy communication and computational cost. Alternatively, processes agree on how the parameter vector should be updated. However, the processes have no way to check if the chosen update for the parameter vector has indeed been computed correctly on real data: an impossibility due to adversarial processes carrying out data poisoning attacks or being the one proposing an update. Thus, neither of these approaches is suitable for realistic, scalable, distributed machine learning.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*2Uurrlg6CU7ieLAN" /><figcaption>Adversarial updates by even a single corrupt node can completely derail the convergence of SGD on even strongly convex loss functions.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/0*UiJgAoHLcYtmLk9_" /></figure><p>Most approaches for distributed machine learning use some linear combination of the updates provided by the individual processes; this typically involves averaging over the results of all processes. However, average is not a robust aggregator, and even a <strong>single</strong> adversarial process can completely derail convergence. In the last five years, several robust methods have been proposed by the research community drawing into the literature of robust statistics; these include aggregations such as Krum, Coordinate-wise Median, and Robust Federated Average, amongst others. While these new aggregators are provably robust (under some strong assumptions) against Byzantine attackers, they come at the cost of slower aggregation algorithms and increased communication costs. Creating provably robust Byzantine Fault Tolerant yet efficient distributed algorithms for machine learning is still an active research field, with a paper from 2021 demonstrating that even the robust aggregation schemes such as Krum and RFA fail to converge even on some <strong>convex</strong> functions under weaker, more realistic assumptions.</p><h3>A Case Study for Decentralized Parallel Stochastic Gradient Descent</h3><p>Traditionally, Distributed Machine Learning systems (including the ones described in the blog ) are centralized, with all computations and communications handled by a central node. However, this architecture can introduce bottlenecks. Performance can suffer when the central node is overwhelmed by high communication costs for data processing. This is where the distributed algorithms of distributed machine learning come into play. Decentralized algorithms distribute the computational and communication load across multiple nodes instead of relying on a single central node. This approach helps reduce communication costs, improve performance, and reduce bottlenecks.</p><p>A recent study performed a theoretical analysis of distributed PSGD algorithms (D-PSGD), a class of distributed parallel stochastic gradient descent algorithms. The results show that under certain conditions, the D-PSGD algorithm outperforms the centralized one (C-PSGD) due to its lower communication cost. The researchers then validated their results through empirical studies across multiple frameworks and platforms, including CNTK and Torch. The results show that the D-PSGD algorithm is orders of magnitude faster than well-optimized centralized algorithms in low-bandwidth or high-latency network configurations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/538/1*djjHsvHwFx40MC3wFiNjdQ.png" /><figcaption>DPSGD being faster came out as a pleasant surprise!</figcaption></figure><p>This study also analyzed the performance of distributed algorithms in a special network topology called a ring network. Each node can only communicate with its two neighbours in this network topology. The results showed that the distributed algorithm could achieve a linear boost. This means that the algorithm&#39;s performance improves linearly as more nodes are added to the network. There were also certain upper bounds on acceleration given as K ^ 1/9 and K ^ 1/13 in various scenarios, where k is the number of PSGD iterations. These upper bounds indicate that the algorithm’s performance can be further improved.</p><h3>Conclusion</h3><p>To summarise, we sped up SGD using parallelism and some sorcery. After that, we dived into Federated Learning: using local datasets to train a global model and tackled the <em>client-drift</em> issue using SCAFFOLD. Ultimately we learnt about fair resource allocation in federated learning. We studied Byzantine Fault Tolerance and finally learnt about fully decentralised results. We found some simple, not trivial and effective methods that yielded surprising results and helped us effectively integrate Distributed Systems with Machine Learning!</p><h3>References</h3><ol><li>Niu, F., Recht, B., Re, C., &amp; Wright, S. J. (2011). HOGWILD!: A Lock-Free Approach to Parallelizing Stochastic Gradient Descent. doi:10.48550/ARXIV.1106.5730</li><li>Blanchard, P., El Mhamdi, E. M., Guerraoui, R., and Stainer, J. Machine Learning with Adversaries: Byzantine Tolerant Gradient Descent. In Advances in Neural Information Processing Systems 30, pp. 119–129, 2017.</li><li>Pillutla, K., Kakade, S. M., and Harchaoui, Z. Robust Aggregation for Federated Learning. arXiv 1912.13445, 2019.</li><li>Yin, D., Chen, Y., Ramchandran, K., and Bartlett, P. Byzantine-robust distributed learning: Towards optimal statistical rates.</li><li>Sai Praneeth Karimireddy, Lie He, Martin Jaggi Proceedings of the 38th International Conference on Machine Learning, PMLR 139:5311–5319, 2021</li><li>Lian, X., Zhang, C., Zhang, H., Hsieh, C.-J., Zhang, W., &amp; Liu, J. (2017). Can Decentralized Algorithms Outperform Centralized Algorithms? A Case Study for Decentralized Parallel Stochastic Gradient Descent. doi:10.48550/ARXIV.1705.09056</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f563cfc5975" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>