<?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 Shubham Urkade on Medium]]></title>
        <description><![CDATA[Stories by Shubham Urkade on Medium]]></description>
        <link>https://medium.com/@shubhamurkade?source=rss-8a0fcc5e67a3------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*oWi4XcJxrlFi_wqR.</url>
            <title>Stories by Shubham Urkade on Medium</title>
            <link>https://medium.com/@shubhamurkade?source=rss-8a0fcc5e67a3------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 17:41:53 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shubhamurkade/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[Understanding Sub-Linear Deep Learning Engine]]></title>
            <link>https://medium.com/@shubhamurkade/understanding-sub-linear-deep-learning-engine-75943487718a?source=rss-8a0fcc5e67a3------2</link>
            <guid isPermaLink="false">https://medium.com/p/75943487718a</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[sparse-coding]]></category>
            <category><![CDATA[model-optimization]]></category>
            <category><![CDATA[model-training]]></category>
            <dc:creator><![CDATA[Shubham Urkade]]></dc:creator>
            <pubDate>Fri, 05 May 2023 07:53:44 GMT</pubDate>
            <atom:updated>2023-05-05T07:53:44.681Z</atom:updated>
            <content:encoded><![CDATA[<p>Anybody working in the field of ML/Data science is quite aptly aware of the increasing size of the models which ultimately increases the computing power required by these models both for training and inferencing. A general trend in the contemporary world of ML has been to either distribute the model or use specialized hardware called accelerators to achieve the desired computing power. The flip side of using accelerators is that these can be quite expensive.</p><p>There’s a lot of research going on to find ways to design better algorithms for training than developing specialized hardware. One such algorithm is called SLIDE (Sub-Linear Deep Learning Engine).</p><p>In this article, we’ll explore SLIDE in brief.</p><h3>What is SLIDE?</h3><p>Generally during model training, we parse the input through all the neurons, which triggers activation functions for each of them, and during backpropagation, we again update the weights for each of them.</p><p>The argument that this algorithm makes is that instead of activating each of the neurons there must be a way to find out which of the neurons are most likely to be activated by the current input and only selectively activate those. This process is called selective sparsification. Now, it must be noted that the efficiency of this process is actually dependent on how we selectively sparsify the neurons. A brute-force way to achieve this would be to calculate the activation functions for all the neurons and select the ones with the highest value of the activation function but this won’t be efficient. SLIDE proposes the use of LSH (Locality sensitive hashing), which is a more efficient way of selectively sparsifying. In fact, it is claimed that this approach when used on a 44-core CPU is more than 3.5 times (1 hour vs. 3.5 hours) faster than the same network trained using TF on Tesla V100.</p><h3>What is LSH?</h3><p>LSH (Locality-sensitive hashing) is a method of hashing. In this type of hashing, the inputs which are similar have a higher probability of colliding than dissimilar ones.</p><p>Let’s assume the following shapes are the inputs to an LSH function:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/351/1*e1WakeeXAJnOTeJx2z8KkA.png" /><figcaption>Inputs to an LSH function</figcaption></figure><p>The LSH will try to group similar items together and here’s how the hash table will look after LSH has processed the inputs:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/391/1*Y6a2-3lQuCCGOWTTAl_ouw.png" /><figcaption>Similar items have been grouped together</figcaption></figure><p>As can be seen from the above picture, the LSH function has grouped similar items together.</p><p>LSH usually works with two variables K and L, where L is the number of hash tables and K is the number of hash functions used per table. The inner working of the LSH algorithm and the significance of these variables is out of the scope of this article. I’ll be publishing another article where we’ll discuss these topics.</p><h3><strong>How does SLIDE use LSH?</strong></h3><p>The property of LSH to group similar items together is what helps SLIDE in figuring out the neurons that are most likely to get activated with the current input.</p><p>One LSH hash table is maintained per layer of the model. Each of these tables uses K hash functions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/764/1*46899pXTKc7QR9DUTu-AXg.png" /><figcaption>Each layer has its own hash function</figcaption></figure><p>For example, let’s assume a network has L layers, then there will be a total of L hash tables. Each of those tables is composed of K hash functions.</p><p><strong>Initialization of the network</strong></p><p>During the network initialization, the weights of the neurons are updated randomly.</p><p>Afterward, K*L hash tables are updated. Let’s assume the hash code of weight vectors is represented as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/75/1*SwqM9lO9pRLIgp6CAjSflQ.png" /></figure><p>where,</p><p><em>l </em>→ The layer number in the neural network</p><p>a → The position of neuron in layer <em>l.</em></p><p>w → The weight vector of the particular neuron represented by the above variables.</p><p>For example, if <em>l</em>=2, <em>a</em>=3, then the above equation calculates the hash codes for the weights of the third neuron of layer two.</p><p>The neuron number (<em>a</em> in this case) is placed in the bucket of the hash code calculated above.</p><p>It can be seen that since we are only working with a subset of neurons for a given input, the other neurons can be worked upon by the remaining inputs parallelly.</p><p><strong>Feed-Forward pass</strong></p><p>During the feed-forward pass, at each layer of the neuron, the hash codes are calculated:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/75/1*PwEPjLWjU7gXsN7MSiNj8Q.png" /></figure><p>where, <em>l</em> → Layer number</p><p><em>x</em> → Input at layer <em>l</em></p><p>These hash codes at layer <em>l</em> will be used to retrieve the neurons that are most likely to get activated and only calculate the activation functions for those neurons. The activations for the other neurons at this level are assumed to be 0. The same happens at the other layers too. This way only a subset of neurons are activated, which drastically reduces the compute required.</p><p><strong>Backpropagation</strong></p><p>At the end of the feed-forward step, the output of the network is compared with known labels. The errors are then back propagated layer-by-layer to update the weights by calculating the gradient descent.</p><p>It must be noted that after the weights have been updated, it might be required to update the hash tables too as the neurons might fall into new hash buckets now.</p><h3><strong>Summary</strong></h3><ol><li>SLIDE selectively activates neurons based on the input. This process is called selective sparsifying.</li><li>Similar neurons are grouped together with LSH (Locality-sensitive hashing).</li><li>Since we are only working with a subset of neurons for a given input, the other neurons can be worked upon by remaining inputs parallelly.</li></ol><h3>References</h3><p>SLIDE research paper: <a href="https://arxiv.org/pdf/1903.03129.pdf">https://arxiv.org/pdf/1903.03129.pdf</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=75943487718a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Distributed vs Federated learning]]></title>
            <link>https://medium.com/@shubhamurkade/distributed-vs-federated-learning-1fae4bc4c9f1?source=rss-8a0fcc5e67a3------2</link>
            <guid isPermaLink="false">https://medium.com/p/1fae4bc4c9f1</guid>
            <category><![CDATA[machie-learning]]></category>
            <category><![CDATA[distributed-systems]]></category>
            <category><![CDATA[distributed-training]]></category>
            <category><![CDATA[federated-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Shubham Urkade]]></dc:creator>
            <pubDate>Fri, 28 Apr 2023 11:23:35 GMT</pubDate>
            <atom:updated>2023-04-28T11:26:56.974Z</atom:updated>
            <content:encoded><![CDATA[<p>Anybody new to the AI/ML phase is usually burdened with a lot of buzzwords. Two of those buzzwords are distributed and federated machine learning. In this article, we’ll try to understand each of them in brief and then compare and contrast them.</p><h3>Background</h3><p>Let’s first try to understand the typical ML training workflow. A data scientist/ML engineer who would like to train their model usually does so on a centralized server or on their local machine. The model is present on the machine while the data can reside elsewhere.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/301/1*QmHT7byI5G335yloZUTscw.png" /><figcaption>Training on a centralized host</figcaption></figure><p>The drawback of this type of training is that the time complexity of the training operation is bounded by the resources available on a single host. To optimize it, we could distribute the training onto a cluster of nodes.</p><h3>Distributed training</h3><p>As with any other software system, to optimize an operation, we distribute it across different workers. That’s exactly what distributed training does for ML models. There are two approaches that we can take to achieve this:</p><ol><li>Data parallel training</li><li>Model parallel training</li></ol><p>Let’s explore in a little more detail what each of these means.</p><h4>Data parallel training</h4><p>As can be inferred from the name, we are going to slice the data and split it across a group of worker nodes. Each of these workers has the same copy of the model but takes in a different slice of the data.</p><p>At the end of a training cycle for a worker, the worker would have computed its own vector of parameters. The parameters from each of the workers are collated and then the copy of the model on each worker is updated with the new collated paramters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*ogK_H4qntQUgs__tGJ2aIw.png" /><figcaption>Data parallel training</figcaption></figure><h4>Model Parallel training</h4><p>Again, as the name suggests, in this type of training the model is sliced. Each slice of the model is deployed on a different worker node. The data remains the same across all of them. Unlike, the data-parallel approach, the workers don’t have to synchronize all of the parameters rather they just have to synchronize the shared parameters which are common to all the slices of the model. These parameters can be synchronized after every forward/backward pass. Due to less amount of synchronization required, mode-parallel outperforms data-parallel training.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*gGtGPm_86iYZU0RJUFgztw.png" /><figcaption>Model parallel training</figcaption></figure><h3>Federated learning</h3><p>In this approach, the learning happens at the edge where the data is generated. In previous approaches, we saw that while the training was distributed across different nodes, the data was fetched from a server that was hosting the data.</p><p>The server could be receiving the data from various sources (like mobiles, sensors, etc) and storing it. So, why not train the model at the edge from where it&#39;s generated?</p><p>In federated learning, a server sends out the initial version of the model to various edge nodes. Each of these nodes then trains its own model with the data that it generates. The learned parameters are sent out to the server periodically. The server uses all the parameters from each of the nodes to train a global model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/471/1*Y8vqAMubMWPt7_pPJd-SMw.png" /><figcaption>Federated learning</figcaption></figure><h3>When do we use distributed vs federated learning?</h3><p>The choice that one would have to make to choose either of the approaches depends on various factors. We’ll discuss some of the factors here.</p><h4>Privacy</h4><p>The main advantage that federated learning has is that the training happens at the edge. Hence, the nodes that generate the data do not have to send the data to a server. In cases where privacy is a big concern, this approach makes more sense. Would you like your edge devices to share data with a server hosted on a public cloud? If the answer is no, then you use federated learning.</p><h4>Performance</h4><p>We saw that among the two approaches for distributed training, model-parallel outperforms data-parallel in terms of performance. So, for our discussion let’s compare model-parallel distributed training with federated learning.</p><p>If the nodes training our model are connected over the internet then federated learning can outperform distributed training. The reason is that in distributed training, the nodes have to keep synchronizing among themselves. The speed of synchronization will be limited by the slowest link among the nodes. Also, each of the nodes has to pull the data from a common server and again this link can be a limiting factor while in federated learning, the data and model both reside on the same node. There’s no limiting factor. The nodes have to keep sending the parameters to a common server but that doesn’t impact the runtime of the training process.</p><p>If the nodes are on the same network then distributed training can perform better. The reason is that these nodes are usually quite powerful as compared to the edge nodes of federated learning. Coupling them with a fast network is quite powerful.</p><h4>Cost</h4><p>Federated learning beats distributed training hands down in this parameter. The reason is that it reuses the data-generating edge devices for training as well, while in distributed training we will have to purchase new hardware just for training.</p><h3>References:</h3><ol><li><a href="https://learn.microsoft.com/en-us/azure/machine-learning/concept-distributed-training?view=azureml-api-2">https://learn.microsoft.com/en-us/azure/machine-learning/concept-distributed-training?view=azureml-api-2</a></li><li><a href="https://en.wikipedia.org/wiki/Federated_learning">https://en.wikipedia.org/wiki/Federated_learning</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1fae4bc4c9f1" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>