<?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 d-Matrix on Medium]]></title>
        <description><![CDATA[Stories by d-Matrix on Medium]]></description>
        <link>https://medium.com/@d-matrix?source=rss-5b5b4e83744d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Lxd1ZXUAUxd7wrToybzTYA.jpeg</url>
            <title>Stories by d-Matrix on Medium</title>
            <link>https://medium.com/@d-matrix?source=rss-5b5b4e83744d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 19:44:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@d-matrix/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[Introducing dmx.compressor]]></title>
            <link>https://medium.com/@d-matrix/introducing-dmx-compressor-08a8570b91a9?source=rss-5b5b4e83744d------2</link>
            <guid isPermaLink="false">https://medium.com/p/08a8570b91a9</guid>
            <category><![CDATA[large-language-models]]></category>
            <category><![CDATA[pytorch]]></category>
            <category><![CDATA[transformer-model]]></category>
            <category><![CDATA[generative-ai-tools]]></category>
            <category><![CDATA[developer-tools]]></category>
            <dc:creator><![CDATA[d-Matrix]]></dc:creator>
            <pubDate>Wed, 16 Oct 2024 14:30:08 GMT</pubDate>
            <atom:updated>2024-10-16T14:30:08.750Z</atom:updated>
            <content:encoded><![CDATA[<p>by Zifei Xu, Tristan Webb, and Xin Wang</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fcw6dSlmMwj8%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dcw6dSlmMwj8&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fcw6dSlmMwj8%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/644ee95086b3a94b613e578e97208ccc/href">https://medium.com/media/644ee95086b3a94b613e578e97208ccc/href</a></iframe><p><strong>Quantization</strong> plays a key role in reducing memory usage, speeding up inference, and lowering energy consumption at inference time. As large language models (LLMs) continue to grow exponentially in size — some now exceeding a trillion parameters — quantization becomes crucial to running these large models efficiently on specialized hardware, such as, d-Matrix’s Corsair hardware (<a href="https://www.d-matrix.ai/product/">https://www.d-matrix.ai/product/</a>).</p><p>In this article, we would like to introduce <em>dmx.compressor</em>, a user-friendly model compression toolkit for functional fake quantization of large language models (LLMs) and built on top of torch.fx. This toolkit simplifies the process involved in Post-Training Quantization (PTQ) and Quantization Aware Training (QAT), making them more accessible to users.</p><p>The key features of <em>dmx.compressor</em> include <strong>high customizability</strong>, supporting <strong>custom numerical formats, operations, and quantization configurations, </strong>which could be super powerful for research. The backward function is also available for <strong>fine-tuning</strong> with straight through estimators used for the quantization operations. The quantized model retains compatibility with the original model’s interface, so that it can be easily integrated with the <strong>PyTorch ecosystem</strong> and <strong>Hugging Face pipelines</strong>. In addition, we offer an API that enables users to apply other optimizations like <strong>quantization calibration, post-training quantization, and Quantization Aware Training</strong>. These features make <em>dmx.compressor</em> an ideal tool for researchers who want to experiment with <strong>new numerical formats, quantization algorithms, and chip design concepts</strong>. The fake-quantized models can be executed on any <strong>PyTorch-supported backend</strong>, including CPUs and GPUs.</p><p><strong>Torch.fx</strong> is a popular framework for fake quantization, it allows users to create a quantized GraphModule by symbolically tracing the original model and insert quantization operations or replace original operations with their quantized versions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pRB9EVq2wHWUf1yZ.png" /><figcaption>Quantization using Torch Fx</figcaption></figure><p>However, quantizing large language models using FX presents the following challenges:<br>1. The quantized model generated by torch.fx is a <strong>fx.GraphModule</strong>, which is <strong>incompatible</strong> with the original model’s API. For example, if a user obtains an LLM from Hugging Face, it will have specific functionalities like the generate method. Unfortunately, the fx.GraphModule loses all attributes and class methods of the LLM, making it incapable of tasks like text generation.<br>2. Torch.fx only supports <strong>static</strong> graphs, while LLMs have highly <strong>dynamic</strong> computation graphs. Consider the following code snippet as an example.</p><pre>from transformers import pipeline<br>pipe = pipeline(task=&quot;text-generation&quot;, model=&quot;meta-llama/Meta-Llama-3-8B&quot;)<br>pipe(&quot;Once upon a time, &quot;)  # this inference API invokes the LLM multiple times</pre><p>The pipeline call triggers the generate function of the Llama model, which iteratively calls the model’s forward function. As shown in the table below, the input signature differs between the first and second calls.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zttjJTjkt2ZUGj3U.png" /><figcaption>Input arguments to llama forward calls</figcaption></figure><p>Diving deeper into the Llama forward function, we see that some input arguments are conditional, determining which blocks of code are executed. For instance, when <em>past_key_values</em> is not None, additional handling of the KV cache occurs, resulting in different computation graphs.</p><pre>if past_key_value is not None:<br># sin and cos are specific to RoPE models; cache_position needed for the static cache<br>cache_kwargs = {&quot;sin&quot;: sin, &quot;cos&quot;: cos, &quot;cache_position&quot;: cache_position}<br>key_states, value_states = past_key_value.update(key_states, value_states, self.layer_idx, cache_kwargs)</pre><h3>Double Graph Representation</h3><p>To address the compatibility issue of quantized models, we introduce a <strong>double graph representation</strong> behind the scenes (Please play with the interactive image below to get more details). The process starts with an instance of a model, such as a Hugging Face Pretrained model or a standard Torch module. We then define tracing rules to instruct the FX tracer on which submodules to avoid tracing and preserve as module operations. After obtaining a GraphModule from tracing, we substitute the original operation nodes with new nodes that contain quantization. Substitution rules are specified to map original operations to corresponding <strong>DmxModules</strong>, which are modules wrapped in quantization operations. Once tracing and transformation are complete, we get a GraphModule containing DmxModules, which is then attached to the original model and packed into a <strong>DmxModel</strong>. This double graph representation is key to maintaining the original model’s structure while ensuring the forward call triggers the GraphModule’s forward function, encompassing all the quantization operations. Once we’ve inserted our compression-related operations, we configure them into the appropriate format. Users can define custom formats subclassing from Format class, which can be powerful for research. Alternatively, they can select from predefined formats, which includes the emerging Microscaling formats. After that, configuration rules define which formats apply to which operations, down to the granularity of a specific operation, leading to a fully quantized DmxModel.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fview.genially.com%2F66f6ff8928333c31456733f6&amp;display_name=Genially&amp;url=https%3A%2F%2Fview.genially.com%2F66f6ff8928333c31456733f6%2Finteractive-image-interactive-image&amp;image=https%3A%2F%2Fgenially-thumbnails.genially.com%2F66f6ff8928333c31456733f6.png%3Fts%3D1727464093644&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=genially" width="1194" height="289" frameborder="0" scrolling="no"><a href="https://medium.com/media/5f8dae6172827b2ce4602b907a4f2392/href">https://medium.com/media/5f8dae6172827b2ce4602b907a4f2392/href</a></iframe><p>If you are curious about how a DmxModule look like, let’s peek into one of them, for example, a DmxLinear module. We can see that it preserves the features of Torch Linear while adding quantization ops. After configuration, the format of the CastTos will change. More specifically, following the quantization config defined in the previous figure (click on the Quantization config block!), the format in input_cast and weight_cast has been updated. For memory efficiency, the parameters of DmxModules are tied to the original module.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0qkhDfOGuODvv-Pe.gif" /><figcaption>DmxLinear</figcaption></figure><h3>JIT Tracing</h3><p>Next, we tackle the issue of fx.Tracer only generating static graphs. Our solution is <strong>Just-In-Time (JIT) tracing</strong>, which defers model tracing and transformation to <strong>runtime</strong>, allowing the computation graph to be based on actual input arguments. If subsequent forward calls detect changes in the input signature that would lead to a new computation graph, <strong>retracing</strong> is automatically triggered. It’s important to note that the quantization configuration is <strong>decoupled</strong> from the GraphModule itself, meaning that even when retracing occurs and a new GraphModule is generated, the existing quantization configuration is seamlessly applied to the new graph.</p><p>Let’s dive deeper into the process, checkout the animation below for illustration. First, we instantiate a DmxModel. At this stage, no GraphModules have been created yet. The DmxModel closely resembles the original model, except that its forward function is refactored to handle JIT tracing. The next step is defining the quantization configuration. When an input is passed through the DmxModel, since no GraphModule exists yet, tracing and substitution are triggered, creating the GraphModule, and the quantization configuration is then applied. The input tensor proceeds through the GraphModule’s forward function, producing the output. For subsequent forward passes, the DmxModel checks whether the new input will result in a different computation graph. If no changes are detected, the input is passed directly to the existing GraphModule. However, if the input signature changes significantly, retracing is triggered, creating a new GraphModule with the same quantization configuration applied. The output is then produced using this updated graph module.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Sgk1IORr2NFh3WxR.gif" /><figcaption>JIT transformation</figcaption></figure><p>Note that the DmxConfig can be modified at any point of time and the future forward passes will use the updated DmxConfig to apply on the GraphModule.</p><h3>Toy Example</h3><p>Let’s summarize the flow of Dmx-Compressor with an example. Imagine a custom network containing a linear layer with two optional arguments in the forward function. The computation graph of this model varies depending on the input arguments, making it impossible to determine a static graph beforehand.</p><pre>class CustomNet(torch.nn.Module):<br>    def __init__(self) -&gt; None:<br>        super().__init__()<br>        self.layer = torch.nn.Linear(DIM, DIM)<br>        self.reset_params()<br><br>    def forward(<br>            self,<br>            x: torch.Tensor,<br>            old_x: Optional[torch.Tensor] = None,<br>            use_gelu: bool = False,<br>        ):<br>            x = self.layer(x)<br>            if use_gelu:<br>                x = torch.nn.functional.gelu(x)<br>            else:<br>                x = torch.nn.functional.relu(x)<br>            if old_x is not None:<br>                x += old_x<br>            return x</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*owXV7ueLsLVNC5KI.png" /><figcaption>Dynamic computation graph for toy example</figcaption></figure><p>When the <em>dmx.compressor</em> API is evoked, the process begins by instantiating a CustomNet instance. Wrapping this instance into a DmxModel initially does not trigger FX tracing and transformation. The configuration rules are registered to the model by calling the configure function.</p><pre>model = CustomNet()<br>model = DmxModel.from_torch(model)<br>x = torch.rand(1, DIM)<br>rules = (<br>  DmxConfigRule(<br>    module_types=(Linear,),<br>    module_config=dict(<br>      input_formats=[format.MXINT8_K64],<br>      weight_format=format.MXINT4_K64,<br>    ),<br>  ),<br>)<br>model.configure(None, *rules)</pre><p>When the model’s forward function is called, the input arguments are inspected, triggering tracing, and the static GraphModule is determined.</p><pre>&gt; model(x)<br>tensor([[0.0000, 1.1791, …</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cMsdrUsOILEO_XR4.gif" /></figure><p>To make things clearer, we provide a tool to visualize the GraphModule.</p><pre>model.visualize_graph()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/559/0*VaF7YgbAEDa-hFhN.png" /><figcaption>GraphModule visualization given input x</figcaption></figure><p>If subsequent inputs do not necessitate changes, retracing is not triggered, the same GraphModule is reused.</p><pre>&gt; model(-x)<br>tensor([[1.1308, 0.5489, …</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1017/0*mKPtodzPDOLliAoq.gif" /></figure><p>However, passing inputs that results in a different computation graph, such as passing <em>use_gelu=True</em> would trigger retracing.</p><pre>&gt; model(x, use_gelu=True)<br>tensor([[-1.6742e-01, 1.0386e+00, …</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1018/0*8ejOUMfNhaon-jhE.gif" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/559/0*GSve833B-M-cYSe0.png" /></figure><p>Passing <em>old_x</em> as a tensor instead of <em>None</em> would also trigger retracing.</p><pre>&gt; model(x, old_x=x, use_gelu=True)<br>tensor([[1.3736, 0.7451, …</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*D2oEM4Hm3lISZH5h.gif" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/697/0*3H2OefVvt775Lw9O.png" /></figure><p>Please visit our <strong>GitHub repo </strong>at <a href="https://github.com/d-matrix-ai/dmx-compressor">https://github.com/d-matrix-ai/dmx-compressor</a>. For questions and feedback, please open a GitHub issue. Community contributions are also greatly welcomed. For more information regarding d-Matrix, please visit <a href="https://www.d-matrix.ai/">https://www.d-matrix.ai/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=08a8570b91a9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ushering a New Era of AI Computing by Rethinking Hardware-Software Codesign]]></title>
            <link>https://medium.com/@d-matrix/ushering-a-new-era-of-ai-computing-by-rethinking-hardware-software-codesign-74172bb51335?source=rss-5b5b4e83744d------2</link>
            <guid isPermaLink="false">https://medium.com/p/74172bb51335</guid>
            <category><![CDATA[inference-acceleration]]></category>
            <category><![CDATA[hardware-software]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[generative-ai-solution]]></category>
            <category><![CDATA[computing]]></category>
            <dc:creator><![CDATA[d-Matrix]]></dc:creator>
            <pubDate>Mon, 30 Sep 2024 16:00:33 GMT</pubDate>
            <atom:updated>2024-10-14T23:41:50.361Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uaLomRYsq3ytaOE3Y05FvQ.png" /></figure><p>by Satyam Srivastava</p><h3><strong>Landscape of AI Computing</strong></h3><p>Artificial intelligence (AI) has permeated countless fields, powered by the advances in latest generative architectures, to a point where a form of artificial general intelligence (AGI) seems tantalizingly plausible in the near future. Years of virtuous cycle of co-design have also established transformers and GPUs as the unquestioned (and maybe a bit uncomfortable) <em>de facto</em> choice for cutting edge AI development. Yet, few realize that serving any generative AI model in an interactive application uses low single digit percentage of a modern GPU’s compute capabilities! Why then is the industry still paying huge premiums on GPU Infrastructure costs? A short history lesson might help but spoiler, it’s the software.</p><h3>Programming Abstractions and “New” Normals</h3><p>If you learnt programming in school, chances are that your first program was meant to run on a microprocessor (CPU) target. Today, for an AI program or model to run by default on a GPU, several things had to come together about a decade ago:</p><p>1. GPUs were already available in computing systems to accelerate…well…graphics. It was established over the years that GPUs provided enough benefits in that class of work (graphics) to merit a break from previously prevalent programming models for CPUs</p><p>2. Persistent and meticulous seeding of research labs by Nvidia had exposed a crop of engineers to the CUDA programming model and how to express non-graphics workloads, such as AI, to run on GPU programmable shaders</p><p>3. Matrix multiplications, key building blocks of the leading neural network architectures, mapped incredibly well to the massively parallel execution environment in the GPUs</p><p>As the AI SW ecosystem has matured with the development of powerful AI frameworks, middleware, optimization libraries, and distributed software, they are still built on top of the fundamental tenets of GPU programming — thread-block based parallelism, unified shared memory, and work delivered via dispatch of kernels.</p><p>It is an uphill climb for a promising new compute architecture to differentiate with sufficient value if it is also burdened with low level compatibility — as it was the case for GPUs when they first appeared to accelerate graphics. But after a period of perturbance, a new normal was established where graphics programs were written for GPUs. Is the computing industry at a point where a new normal of AI device abstraction is needed to truly deliver the performance jump it needs?</p><h3>Work Ahead and What We are Doing</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*xLRPhcEihdVL4gbUY2JyFg.png" /></figure><p>At d-Matrix, we are excited to be part of this era of AI technology and helping push the frontier of computing systems. Generative AI workloads are unique in that the prompt or prefill phase is compute-bound, while the token generation phase is memory-bound. We have been working on a variety of innovations in pursuit of the <em>next </em>new normal:</p><p>1. A novel in-memory computing-based hardware architecture that caters to the extremely high memory bandwidth needs of generative AI</p><p>2. Scaling from chiplets to clusters over a standard fabric</p><p>3. Tooling for efficient model optimization that leverages novel datatypes including MX. Our tools (DMX Compressor) were presented at the recently concluded PyTorch Conference and are available in the open source</p><p>4. Prototype backend in PyTorch for a dataflow architecture that utilizes the graph compilation support of Torch Dynamo to deliver work to the hardware while allowing graph breaks and debug hooks that users like</p><p>5. Programming models, DSLs, and IRs that deviate from GPU-like thread blocks but are more expressive for spatial architectures and devices with multi-level memory hierarchies</p><p>6. Primitives for efficient networking communication between devices and methods for achieving those with minimal synchronization between accelerators and hosts</p><h3>Software Building Blocks for a New Computing Paradigm</h3><p>Multiple custom chip solutions have demonstrated the value of novel architectures when not constrained by the burden of legacy. There are community efforts underway to make the software ecosystem more open to non-traditional designs. Notable examples include:</p><p>1. Torch Compile: Although vast majority of PyTorch programs run in imperative (“eager”) mode where each operator executes independently, <em>torch.compile</em> enables large parts of an AI model to be compiled and executed as one dispatch — something very desirable for dataflow architectures. <em>Compile </em>is a natural extension of the tracing and exporting facility in PyTorch which now allows the compiled models to execute within the PyTorch environment — opening the door to richer applications and complex control flows</p><p>2. MX Datatypes: After many iterations of vendor-defined datatypes (e.g. bFloat16 and variants of FP8), the Open Compute Project (OCP) has helped standardize micro-scaling datatypes (MX) which are immensely valuable for tensor representation in AI. It allows chip designers to leverage low precision computing and storage for higher efficiency, while also being interoperable with compatible external solutions</p><p>3. Triton DSL: In order to facilitate non-CUDA GPUs (or custom accelerators) to execute optimized kernel programs, the Triton domain specific language (DSL) provides a HW-agnostic device abstraction that can be readily mapped to CUDA but also lowered to other devices via a compilable intermediate representation (IR). Triton-native kernels promise portability between different accelerators without source modification which removes a huge friction point for existing users</p><p>While these efforts to make the computing ecosystem more accessible are commendable, there is more work to be done. To unlock a new era of AI compute solutions with innovative memory-compute integration and accelerate memory-bound GenAI workloads, it is critical to enable new software abstractions as well. Many of these and more require collaboration across companies, standards, and community participants and we look forward to working with them on these ambitious objectives.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=74172bb51335" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Transforming AI: d-Matrix’s Pivotal Moments in Pursuit of Gen AI Inference At Scale]]></title>
            <link>https://medium.com/@d-matrix/transforming-ai-d-matrixs-pivotal-moments-in-pursuit-of-gen-ai-inference-at-scale-ba927082e74b?source=rss-5b5b4e83744d------2</link>
            <guid isPermaLink="false">https://medium.com/p/ba927082e74b</guid>
            <dc:creator><![CDATA[d-Matrix]]></dc:creator>
            <pubDate>Wed, 26 Jun 2024 18:38:34 GMT</pubDate>
            <atom:updated>2024-06-26T20:57:35.500Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*qtdfQZFuwGtRzB9C" /><figcaption>d-Matrix founders: Sudeep Bhoja — CTO (left); Sid Sheth — President &amp; CEO (right)</figcaption></figure><p>by Sid Sheth &amp; Sudeep Bhoja</p><p>You’ve probably heard the adage, “hardware is hard.” That’s definitely true. When you’re making chips for the rapidly changing world of AI, things really get hard early on. The AI chip space was plenty crowded when we started (100 start-ups) and d-Matrix recently celebrated five years of successfully anticipating the market need, while working as quickly as possible to get there. But like any successful start-up, there were pivots along the way. I wanted to share our journey at d-Matrix over the past five years, and how we’ve gone from being told, “this sounds crazy, you are late and why would you want to leave what you have,” to being told now that, “you have prescient vision,” as the generative AI market has boomed. By the way, none of those descriptions really describe us.</p><p><strong>Year Zero (2019): “Taking the leap”</strong></p><p>When we left Inphi to start d-Matrix, it’s not like we were in our 20’s and 30’s — we were well into our 40’s. We had young teenage kids in various stages of schooling and starting from scratch seemed like a foolhardy thing to do.</p><p>However, we had the distinct advantage of seeing the AI wave in its early infancy with the rapid adoption of Inphi’s datacenter interconnect products in distributed AI compute applications across all the large cloud service providers. In speaking with these customers it was becoming clear that AI adoption would only accelerate over time, and specifically the AI inference opportunity would dwarf AI training.</p><p>I came from a family of generational “Gujarati <a href="https://en.wikipedia.org/wiki/Bania_(caste)">Bania</a>” entrepreneurs, my grandfathers, father, uncles were all entrepreneurs and ‘working for someone’ was generally frowned upon. Seeing this massive opportunity in front of us triggered my DNA and we took the leap outside of our comfort zone.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/0*gG-8r0oM18GJ_P9M" /><figcaption><em>Sid Sheth in his first office at d-Matrix, 3 months after formation in 2019</em></figcaption></figure><p><strong>Year One (2020): “Two weeks from running out of cash”</strong></p><p>We started building, then 2020 brought a global pandemic, Sudeep had recently lost his father, the team was working from home for the first time, there were #BlackLivesMatter movements around the country, and to top it, the worst fire season in California that led to mass evacuations close to home. There was a feeling of unease. Through it all, our former company was acquired for $10B while we had a “near-death experience” where we almost ran out of money at d-Matrix. But we focused on what we could control, our team grew to 10 people, and we successfully built and packaged our first chip in 12 months, complete with a software stack that could run live workloads.</p><p>Sudeep was adamant that we have the software working in tandem with the hardware from the beginning, and we’ve kept that focus on software and hardware throughout our growth. We initially used a charge based analog In Memory Compute architecture with a single slope analog to digital converter — but we quickly concluded that it was challenging to fit converters on each bitline and the effort was not worth the reward. We had to pivot.</p><p>There was a lot of uncertainty on the horizon. But we continued digging into the technology-market fit and the product-market fit problem relentlessly. This is where we ran into Transformer based workloads and the idea of using a digital approach to in-memory compute with SRAM bit cells combined with adders in a custom circuit fabric to make inference more efficient. So we quickly pivoted to an all digital solution that could scale and not sacrifice accuracy, predictability and programmability — a must for the inference at-scale datacenter market. It was a pretty crazy time!</p><p>We knew we needed at least an additional $2 million to get silicon manufactured for a customer demo, but were struggling to get investors to give us that extra cash. After much struggle, and coming within two weeks of running out of cash, we had an a-ha moment “What kind of chip company were we building with an additional $2m? Why don’t we go ask for $40 million and show a big vision to match the size of the opportunity we are going after?” That was one early lesson — don’t sell yourself short when you have the opportunity to make a bigger impact. Sometimes it’s easier to get $40 million than to get $2 million when you are serving a large market opportunity — you need to signal as such to investors. We pivoted our plans, became bold and decided to swing for the fences.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/468/0*H0mt33Myiv2vbFy1" /><figcaption><em>d-Matrix first POC chip — Nighthawk</em></figcaption></figure><p><strong>Year Two (2021): “Wait, I think we are onto something”</strong></p><p>Our new bold approach to fundraising, focus on Transformers and digital in-memory compute technology for inference, yielded results quickly. While our first Nighthawk chip wasn’t a home run (SRAM Analog in-memory compute), it showcased the grit and experience of the team’s ability to execute through adversity. All this led to a $40M Series A from Playground Global and Microsoft M12, and we realized we might be onto something. We felt like we were finally catching some wind.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KoXxSKUKmaTTJATD" /><figcaption><em>d-Matrix first Nighthawk demo for investors in 2021 at their Cupertino labs</em></figcaption></figure><p><strong>Year Three (2022): “Pre-ChatGPT”</strong></p><p>Now that we had set a course and made a bet, it was time to start the process of building a product. Our first product was built for non-generative Transformers (BERT, T5) being all the rage in early 2022. However, GPT3 had been launched and there was a lot of chatter about the “generative” capabilities of these new models. We had numerous conversations with our customers only to realize that we needed to pivot yet again. Our product architecture needed to accommodate these generative abilities of Transformers. By now, the team had become familiar with pivots and had been tested multiple times. So, we did what we do best — reacted quickly and pivoted to a new generative AI inference architecture. This is what became Corsair, our first chiplet based PCIe accelerator for Generative AI inference. Then ChatGPT took the world by storm that November. Our world, like everyone else’s, was about to change.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1WijhPlMAHA9I2zC" /><figcaption><em>d-Matrix Jayhawk I and Jayhawk II chips</em></figcaption></figure><p><strong>Year Four (2023): “Holy smokes moment”</strong></p><p>The launch of ChatGPT was a “holy smokes” moment for d-Matrix, to put it politely. We realized that not only were we on to something, we were on to something really, really big. It was time to accelerate our plans and raise more capital to double down on our bet. But as the world tried to figure out what the post-pandemic “new normal” was, VC funding dried up across the board as the Fed hiked rates, and almost 3,000 startups failed in a single year — what many called a mass extinction event for startups.</p><p>Amidst this headwind, we went out and raised $110 million for our Series B round. At least by this point, we were looking less like crazy and more prescient. It only took us four years! But we got through the trial by fire and it seemed we now had the capital to scale our dreams and ambitions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-Y_MysrJ3r9g6KbF" /><figcaption><em>Sid Sheth (President &amp; CEO) holding up their Nighthawk and Jayhawk chips</em></figcaption></figure><p><strong>Year Five and Beyond (2024-): “The world comes to you”</strong></p><p>d-Matrix turned five last month, and the team’s relentless faith and grit have paid off. Corsair promises to be the transformative platform for generative AI inference in the datacenter, featuring 2GB high-density SRAM, 8 chiplets, blazing 10 PetaOPS performance, 256G of DDR, all on a single card and a full-stack software suite built using open source frameworks, MLIR compiler stack and libraries. We are slowly but surely getting there, long way still to go, but you’ve just got to keep your head down, listen, stay humble, stay paranoid, execute and hopefully the world will come to you over time.</p><p>I want to take a moment to thank all of our d-Matrix employees. Beyond our Silicon Valley headquarters, we now have design centers in Bangalore, Sydney, Seattle and Toronto to capitalize on fast-growing talent hubs. With all this progress, we’ve reached an inflection point where talk turns to action for deploying AI. The world has seen what training can create, now we need superior inference solutions to bring the benefits of gen AI to companies across the business spectrum. With our launch on the horizon, we’re more excited than ever to drive greater efficiency and value, reshaping a more sustainable future for AI.</p><p>To join this industry-defining journey, check out our open roles at <a href="https://www.d-matrix.ai/careers/">d-matrix.ai/careers</a>. Learn more about our platform <a href="https://www.d-matrix.ai/wp-content/uploads/2023/10/d-Matrix-WhitePaper.pdf">here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ba927082e74b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Keyformer: KV Cache reduction through attention sparsification for Efficient Generative Inference]]></title>
            <link>https://medium.com/@d-matrix/keyformer-kv-cache-reduction-through-attention-sparsification-for-efficient-generative-inference-f4b659f5594e?source=rss-5b5b4e83744d------2</link>
            <guid isPermaLink="false">https://medium.com/p/f4b659f5594e</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[d-Matrix]]></dc:creator>
            <pubDate>Wed, 27 Mar 2024 15:27:39 GMT</pubDate>
            <atom:updated>2024-03-27T16:49:46.196Z</atom:updated>
            <content:encoded><![CDATA[<p><em>by Muhammad Adnan[1], Gaurav Jain[2], Akhil Arunkumar[2], Prashant J. Nair[1], Ilya Soloveychik[2], Utham Kamath[2]; [1] The University of British Columbia, [2] d-Matrix</em></p><p><strong>TL;DR:</strong> Generative AI inference is often bottlenecked by growing KV cache. There have been several numerous strategies proposed to compress the KVCache to allow longer inference-time context lengths. However, most of these techniques require fine-tuning and even pre-training in some cases. We introduce Keyformer, a novel token inference-time discarding technique to reduce KV cache size to improve the overall inference latency and token generation throughput while preserving accuracy. Keyformer capitalizes on the observation that during generative inference, approximately 90% of the attention weight is concentrated on a select subset of tokens called key tokens and discards the <em>irrelevant</em> tokens to reduce the overall size of the KVCache. Thus, with employing Keyformer we are able to reduce required the KV Cache size by 50% and the latency by up to 2.1x, and boost the token generation throughput by 2.4x, all while preserving the model’s accuracy. Further, we are able to support cases of larger batch sizes which otherwise result in Out-Of-Memory errors.</p><h3>How Keyformer works</h3><p>Attention mechanism exhibit varying amounts of sparsity throughout the large number of model decoder layers. As seen in Figure 1(Left), attention sparsity significantly varies for models of the same sizes and all for the same CNN/DailyMail dataset summarization task. On the other hand, Figure 1(Right), through a cumulative distributive function (CDF) shows how the attention score is concentrated within a with small number of tokens during text generation. What this translates into for us is the importance of certain key tokens during token generation and more importantly, the relative irrelevance of a majority of tokens during the same.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5hHLuR9Op9ppkNqDATF17g.png" /><figcaption><em>Figure 1: (Left) Default attention sparsity for different models across layers. (Right) CDF of attention score for different models with 90% of attention score dedicated to 40% of tokens.</em></figcaption></figure><p>In this work, Keyformer, we exploit this inherent sparsification within the decoder layers by identifying key tokens while still emphasizing on the recent tokens. We further adapt this behavior of discarding tokens by changing the score function and applying regularization to the unnormalized logits for key token(s) identification.</p><h3>What do we do for Regularization — Gumbel Distribution</h3><p>Once we have identified and discarded the irrelevant tokens, it is important we normalize the score function to account for this change. In that regard, we use the Gumbel distribution which enables our model to remain robust and adaptive. As an implementation strategy, we maintain a constant size, <em>k</em> of the KVCache and remove the <em>n − k</em> tokens from the context to avoid unwanted expansion of the memory.</p><h3>Bias Towards Initial Tokens</h3><p>Previous research has indicated a bias towards initial tokens. For instance, <a href="https://arxiv.org/abs/2309.17453">StreamingLLM</a> highlights the importance of initial tokens as attention sinks, particularly in streaming applications. Similarly, <a href="https://arxiv.org/abs/2306.14048">H2O</a> utilizes an accumulated attention score as a score function, which results in a predisposition towards initial tokens due to the cumulative effect during decoding iterations. To exploit this bias towards initial tokens and effectively model the distribution of maximum values (key tokens), we propose introducing a distribution that is skewed towards initial tokens while simultaneously features an asymmetric profile. This asymmetry introduces a pronounced right tail, which is characteristic of tokens typically drawn from the recent context window. Our choice of distribution is inspired by the <a href="https://arxiv.org/pdf/1502.02708.pdf">Gumbel distribution</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/853/1*hqFTwDhoa97sKofZGoLbeA.gif" /><figcaption><em>Figure 2: Overview of Keyformer during multiple phases. Prompt processing phase with n-tokens in KV cache along with induction of noise by Keyformer for key tokens identification. It selects w tokens from the recent window while k − w tokens from remaining n − w tokens to keep k tokens in KV cache. In text generation phase, decoding step with k-tokens in KV cache with tokens discarded from previous iteration.</em></figcaption></figure><h3>Keyformer Score Function</h3><p>To overcome the limitations of uneven score distribution and respective key tokens identification, we introduce a novel Keyformer score function. This score function incorporates the Gumbel distribution into the unnormalized logits. However, the discarded tokens are not incorporated in anyway in forming the probability distribution that underlies the score function. To address this oversight and incorporate the discarded tokens, we introduce a temperature parameter denoted as τ, as shown in below Equation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/937/1*A5dsygmStUYvyxnyrlXm1Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/853/1*HaWAYTx-lVzUWRFpSdCing.gif" /><figcaption><em>Figure 3: Design of Keyformer for a single decoder layer.</em></figcaption></figure><h3>Key Results</h3><p>We evaluate Keyformer across three significant model families: <a href="https://huggingface.co/EleutherAI/gpt-j-6b">GPT-J</a>, <a href="https://huggingface.co/cerebras/Cerebras-GPT-6.7B">Cerebras-GPT</a>, and <a href="https://huggingface.co/mosaicml/mpt-7b">MPT</a> and on two representative text generation tasks, i.e. summarization task using the <a href="https://huggingface.co/datasets/cnn_dailymail">CNN/DailyMail</a> dataset from <a href="https://crfm.stanford.edu/helm/latest/">HELM</a>, and the conversation task with the <a href="https://huggingface.co/datasets/allenai/soda">SODA</a>. GPT-J model is finetuned for summarization task, while Cerebras-GPT and MPT are pretrained models. For conversation tasks, we used the <a href="https://huggingface.co/mosaicml/mpt-7b-chat">MPT-chat</a> version of the MPT model, which is fine-tuned for dialogue generation. Figure 4 shows that Keyformer achieves the baseline accuracy with 70% prompt KV cache size for Summarization task across different models while 90% of prompt KV cache for Conversation task while other baselines couldn’t achieve the baseline accuracy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oa24AMSNeyWZgeBjSuJIlA.png" /><figcaption><em>Figure 4: Accuracy comparison of Full Attention, Window Attention, H2O and Keyformer with varying KV cache size. Solid black line shows Full Attention without discarding any token and full KV cache. Red dotted line shows 99% accuracy mark.</em></figcaption></figure><p>For long-context scenarios, we turned to the <a href="https://huggingface.co/datasets/ccdv/govreport-summarization">GovReport</a> for extended document summarization. To tackle long document summarization, we employed the <a href="https://huggingface.co/mosaicml/mpt-7b-storywriter">MPT-storywriter</a> version of the MPT model, fine-tuned for writing fictional stories with a context length of 65k and the ability to generate content as long as 84k tokens.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gVx_E2MCkoV3GHuiaB5tow.png" /><figcaption><em>Figure 5: (Left) Long context summarization using MPT-7B-storywriter model for GovReport dataset with a sequence length of 8k. (Right) Speedup of Keyformer with 50% KV cache reduction.</em></figcaption></figure><p>Figure 5 shows that for long context summarization, Keyformer achieves baseline accuracy with 50% of prompt KV cache, improving the inference latency by 2.1x and token generation throughput by upto 2.4x.</p><h3>Get Started with Keyformer</h3><p>We have implemented Keyformer for multiple autoregressive models and provided respective model cards to run different tasks. Please find detailed instructions to use Keyformer <a href="https://github.com/d-matrix-ai/keyformer-llm/blob/main/README.md">here</a>.</p><h3>Citation</h3><pre>@article{2024keyformer,<br>  title={Keyformer: KV Cache reduction through key tokens selection for Efficient Generative Inference},<br>  author={Adnan, Muhammad and Arunkumar, Akhil and Jain, Gaurav and Nair, Prashant and Soloveychik, Ilya and Kamath, Purushotham},<br>  journal={Proceedings of Machine Learning and Systems},<br>  volume={7},<br>  year={2024}<br>}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f4b659f5594e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Celebrating International Women’s Day 2024: Amplifying the Impact of Women in Tech]]></title>
            <link>https://medium.com/@d-matrix/celebrating-international-womens-day-2024-amplifying-the-impact-of-women-in-tech-e9047f66e8b2?source=rss-5b5b4e83744d------2</link>
            <guid isPermaLink="false">https://medium.com/p/e9047f66e8b2</guid>
            <category><![CDATA[d-matrix]]></category>
            <category><![CDATA[diversity]]></category>
            <category><![CDATA[international-womens-day]]></category>
            <category><![CDATA[generative-ai]]></category>
            <dc:creator><![CDATA[d-Matrix]]></dc:creator>
            <pubDate>Fri, 08 Mar 2024 00:48:34 GMT</pubDate>
            <atom:updated>2024-03-08T00:48:34.773Z</atom:updated>
            <content:encoded><![CDATA[<p>Every March 8th, International Women’s Day (IWD) offers us a moment to pause, reflect, and celebrate the vast contributions of women across all areas of life — especially in technology. At d-Matrix, we’re proud to champion the brilliance and innovation women and gender diverse employees bring to our mission of advancing generative AI and making it more accessible every day. Today, we work to <a href="https://www.internationalwomensday.com/Theme">#InspireInclusion</a> and acknowledge the social, economic, cultural, and political achievements of women toward equality — while recognizing the journey will continue tomorrow.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lPgRsUlq3QF3VhZ2BitYow.jpeg" /></figure><p><strong>The Pioneering Spirit of Women in Tech</strong></p><p>In the tech industry, where innovation and creativity are paramount, women have been breaking barriers and setting new benchmarks since the beginning. From Ada Lovelace, credited with writing the first computer algorithm in the 19th century, to Margaret Hamilton at MIT who wrote software for landing on the moon while coining the term “software engineering,” women have been integral to making new technology paradigms possible.</p><p>The same is especially true for artificial intelligence, which requires intentional collaboration to mitigate dangerous biases in data sets and algorithms. We believe having varied viewpoints in AI not only accelerates innovation, it’s a crucial step toward challenging harmful outcomes like models that perpetuate societal prejudices and discrimination. At d-Matrix, we’re equally passionate about the advancement of AI technology as we are about its ethical use in society.</p><p>I’d like to share a few of the perspectives of a few inspiring women technologists at <a href="https://www.d-matrix.ai/">d-Matrix</a> on what inclusion means to them, what motivated their unique career paths, and the impact of mentorship and representation.</p><p><strong>Irene Q.</strong>: To me, the theme of #InspireInclusion means that a diverse and inclusive culture fosters innovation and creativity. It is essential to have a diverse team with different backgrounds, perspectives, and experiences to tap into a larger pool of talent and ideas. I’ve been attracted to STEM since elementary school, building periscopes and an interactive periodic table. During middle school, all the girls were asking their parents if they should choose Home Economics or Technical electives. I chose Technical without hesitation. Gender shouldn’t be a deterrent when selecting a career path — everyone should be able to follow their passions, do what they enjoy, and this path will lead to success and happiness.</p><p><strong>Briana S.</strong>: I am most inspired by women who uplift and share their knowledge with others, creating communities and amplifying the work of those around them. I have experienced barriers and bias in my career, but also lots of opportunity. In the challenging moments I’ve found the most success leaning into the community of women around me for support, and I aim to do the same for others. If you try new things constantly, don’t be afraid to fail and find a path that brings you joy, everything else will fall into place.</p><p><strong>Sayeh S</strong>: When I was a teenager, I always heard that math was a “boys’ thing.” But in high school, I learned that Maryam Mirzakhani won the international gold medal in the Math Olympiad with a full score, showing me women can excel in math too. Later on, learning of Ada Lovelace’s achievements made me realize that women have been shaping the field of technology from the very beginning, and any woman today can do the same. Now I tell aspiring women in STEM: “Believe in yourself, follow your passion, try hard, never stop learning, and don’t be afraid to challenge the status quo. You are more than capable of having a meaningful impact in what you love doing.”</p><p><strong>Shravya J</strong>: For me, #InspireInclusion means acknowledging the accomplishments and struggles of women. It’s a chance to promote equal opportunities for women and ensure their voices are heard without preconceived notions. My mother was a first-generation graduate and working woman who paved the way for me and my sister to succeed, and I always found her ability to adapt to new ideas inspiring.</p><p><strong>Looking Ahead: Amplifying Diverse Voices in Technology</strong></p><p>The journey of women in tech is marked by resilience and determination. It’s an honor to work alongside so many diverse software developers, technical experts, and leaders as we continue to challenge stereotypes and for a more equitable tech landscape. Lifting up innovators from underrepresented backgrounds not only drives the industry’s growth but — more importantly — offers a path forward for future generations of women, nonbinary and gender diverse technologists who will play a crucial role ensuring the safe and beneficial implementation of AI.</p><p>As we celebrate International Women’s Day and Women’s History Month, let us also commit to a year-round effort of inclusion, mentorship, and advocacy. Together, we can build a tech industry where everyone’s contributions are valued and celebrated every day.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e9047f66e8b2" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>