RSSAmplifier

Blog

Nitin Gupta

Recent content on Nitin Gupta

nitingupta.devRSS feed ↗24 posts

Latest posts

Tensor Deduplication for Multi-Model Inference

Summary 
 
 Problem : Multi-model workloads are the norm: A/B tests, customer fine-tunes, safety variants, multi-stage pipelines. GPU memory scales linearly with model count, and VRAM is the limiting resource. 
 Solution : Tensor deduplication automatically identifies and shares bit-identical weight tensors across models, requiring no checkpoint modifications. 
 Results : Across…

Shared Backbones: Loading Weights Once, Serving Many Models

I keep running into the same pattern when trying to self-host models (which is a lot of fun): we run several big models side by side, all of them valuable, all of them slightly different, and all of them wasting VRAM by reloading nearly the same weights. 
 This post is my attempt to explore a specific idea: 
 Can we load a shared backbone of weights once on a GPU, then load only the small,…

Proactive Compaction

This feature has now been accepted and merged in the upstream kernel and will be part of kernel release 5.9. This post has been updated to match the upstream version of this feature. 
 
 In my previous post , I described how on-demand compaction scheme hurts hugepage allocation latencies on Linux. To improve the situation, I have been working on Proactive Compaction for the Linux kernel,…

Linux kernel hugepage allocation latencies

Some drivers needs to allocate almost all memory as hugepages to reduce (on-device or CPU) TLB pressure. However, on a running system, higher order allocations can fail if the memory is fragmented. Linux kernel can do on-demand compaction as we request more hugepages but this style of compaction incurs very high latency. 
 To show the effect of on-demand compaction on hugepage allocation…

A layered object store design in Elixir (Part VI)

We built an object store from scratch in Elixir using a layered design approach. The overall theme has been to avoid generalizing the design too much which kept implementation of each layer/module simple. We were also careful when adding any third-party dependencies which has multiple advantages: deeper understanding of your codebase, easier debugging (I hate unknown code-paths in backtraces).…

A layered object store design in Elixir (Part V)

Part I , introduces the overall design of our object store. In this post we focus on the Web layer. This is the final layer for our object store responsible for exposing it over the web. It will expose endpoints: /upload for uploading a file and /file/:file_id for getting a file by ID. A typical GraphQL application with also expose endpoint /graphql which directly plugs into your API layer,…

A layered object store design in Elixir (Part IV)

Part I , introduces the overall design of our object store. In this post we focus on the API layer. All layers till now were just concerned about storing the input file together with some file-format specific transforms (like thumbnails). It is at the API layer where we will be storing per-file system and user metadata. This metadata can be used to support application specific business logic and…

A layered object store design in Elixir (Part III)

Part I layer. 
 ImageStore 
 The ImageStore module is responsible for storing images along with their thumbnail. It will use the FileStore layer to actually store files on disk. Before we define module interfaces, lets see our application requirements: 
 
 All images must be stored in the jpg format. 
 Images cannot be larger than 1920x1080. We do not want to store user…

A layered object store design in Elixir (Part II)

Part I , introduces the overall design of our object store. In this post we focus on its first layer, the FileStore . 
 The FileStore layer is responsible for actually storing the file in our object store. At this level, we are not concerned about what kind of file it is (image, video, document, or whatever else), nor do we have any notion of security. We just store whatever input path is…

A layered object store design in Elixir (Part I)

I recently designed an object store from scratch in Elixir. It has been serving me well as a backend for an app which needs to store all kinds of files: images, videos, documents. I wanted something simple to avoid dealing with off-the-shelf object stores which require complex configurations and to avoid cloud storage which is dead simple to use but can get very expensive, very quickly. For this…

Elixir collections

Elixir is a function programming language that I have been using a lot in recent months to build all kinds of applications. Understanding of built-in collection types is essential to use any language effectively and Elixir is no different. 
 This posts summarizes all collection type along with pros/cons/gotchas for each one of them. 
 
 
 
 Collection 
 Example 
 When…

Subtle Errors in C++ Programs

I recently stumbled upon a subtle bug in a benchmark code which again reminds me to never use C++ again, if I can. &#xA; Here&rsquo;s a buggy snippet from this code (simplified): &#xA; // BUGGY&#xA; ostringstream os;&#xA; int i = 1 ;&#xA; os << 'foo-' << i << '.dat' ;&#xA; const char * filename = os.str().c_str();&#xA; int fd = open(filename, O_RDONLY);&#xA; You may expect above code to try open a…

Setting Up Backup Snapshots on Linux

For some time I&rsquo;ve been looking for a backup solution for Linux that can periodically take snapshots of data, allowing me to go back in history of any file just like git. I finally found restic which fits these requirements. Here is how I set it up to take snapshots of particular directories, say every 15 minutes. &#xA; Installing restic &#xA; Though restic is available in repositories of…

Google Drive on Linux

There is no official Google drive client for Linux. I tried many different clients found all over GitHub but none of them worked reliably for me except rclone . I also tried third-party proprietary clients like Insync but allowing read-write access to all your Google drive files to a closed source blob is too much to swallow. &#xA; Once caveat with rclone is that it does not natively support…

Faster compilation with distcc

Often, you have more than one system at your disposal but no clear way&#xA;of distributing your compilation workloads over to all or some of them.&#xA;They might be running different OSes which makes it look even more&#xA;difficult. In my case, I have one laptop (2 cores) and a desktop (4&#xA;cores) connected with a WiFi network. The laptop runs Linux (Fedora 13&#xA;64-bit) while the desktop runs…

Compressed RAM disk for Windows, The Virtual Way!

Recently, I developed Linux kernel driver which creates generic RAM&#xA;based compressed block devices (called zram ). Being RAM disks, they&#xA;do not provide persistent storage but there are many use cases where&#xA;persistence is not required: /tmp, various caches under /var, swap disks&#xA;etc. These cases can benefit greatly from high speed RAM disks along&#xA;with savings which compression…

Comprehensive graphical Git diff viewer

Since a long time, I was looking for a graphical git diff viewer which&#xA;could show original and modified file side-by-side and highlight the&#xA;changes. There are few solutions but none of them is sufficient: &#xA; &#xA; A tool included with git called &lsquo;git-difftool&rsquo; is partially helpful&#xA;&ndash; it can show changes graphically but diff for each file is shown&#xA;one-by-one.…

Linux kernel workflow with Git

You worked on some part of Linux kernel. It works great. Now, how to&#xA;generate the patch series and send it out for review? For this, I always&#xA;used to generate diffs, create a set of draft mails (one for each patch)&#xA;in KMail or Thunderbird, and send all these mails one-by-one. This&#xA;workflow quickly became a big headache. Then I learned Git (and some&#xA;related tools) to do all this…

ccache to speed-up Linux kernel compile

In case you are unfamiliar with ccache, its a &ldquo;compiler cache&rdquo;.&#xA;Compiling is primarily CPU intensive task. So, ccache caches compiled&#xA;objects - so next time we compile same code, it reuses these objects&#xA;thereby significantly &#xA;speeding-up compilation. &#xA; I need to recompile Linux kernel usually several times a day, with&#xA;different permutations of config settings.…

SLOB memory allocator

Linux kernel has few SLAB allocator variants included: SLAB, SLUB and&#xA;SLOB. Of these, SLOB is especially meant to be used on embedded devices&#xA;&ndash; it tries to be more memory space efficient than other SLAB&#xA;variants. &#xA; Yesterday, I had a detailed look at SLOB allocator for possible use in&#xA; compcache poject and found it&#xA;unacceptable for the purpose. I did it in response to…

Anti-tip of the month

Very old but still as relevant&hellip; and very interesting too! Directly go&#xA;to &ldquo;anti-tip&rdquo; section of this article . &#xA; &ldquo;The moral of the story is: don’t get tricky. C programmers often try to minimize the number of lines of C in their program without consideration for what the compiler will generate. When in doubt, write clear code and give the optimizer a chance to…

Fedora 10 instability issue solved!

One of my Fedora 10 systems used to freeze very frequently. After lot of&#xA;looking around I found its because of &ldquo;KWin Composing&rdquo; which gives&#xA;OpenGL driven special effects for desktop. Unfortunately, Linux has&#xA;always been bad at radeon drivers, so it better to disable these effects&#xA;especially if you have radeon video cards. &#xA; in ~/.kde/share/config/kwinrc: &#xA; in…

Difference Engine - Harnessing Memory Redundancy in Virtual Machines

Here is link to paper&#xA;( pdf )&#xA;( MP3 ) &#xA; Recently I came across this paper published in OSDI&#xA;&lsquo;08 . Its an extension to VMware&rsquo;s&#xA;page-sharing and shows some amazing and hard to believe results. VMware&#xA;page-sharing mechanism scans memory for all VMs and maps pages with&#xA; same contents to a single page.&#xA;This achieves memory savings if multiple VMs are hosted…

Nitin Gupta

I am deeply passionate about optimizing GPU performance and delving into the intricacies of resolving bottlenecks within render and compute workloads. &#xA; With nearly 15 years of experience delving into the nitty-gritty details of technology, I&rsquo;ve dedicated a significant portion of my career to working on various low-level components, including Linux Kernel Proactive Compaction ( LWN.net…