LLMs on Battery-Powered Chips (Oh My!)
Original source (eejournal)
Share Article:

Heraclitus of Ephesus, an ancient Greek pre-Socratic philosopher, originated the theory that the world is in a state of constant flux, and the saying “the only constant is change” is widely attributed to him. All I can say is that there’s a pre-Socratic philosopher who “knew his onions,” as it were.

As one example of change, the beginning of this week (November 30) marked the fourth anniversary of the launch of ChatGPT. It’s hard to believe that, just four short years ago, few of us outside the AI research community had even heard the term “large language model” (LLM). Now, even my dear old mum wouldn’t raise a quizzical eyebrow if someone dropped an occasional “LLM” into a conversation.

Of course, the foundations for all this had been laid some years earlier. The concept of attention—which, in the context of language processing, allows a model to focus on the most relevant parts of its input—started to gain traction in 2014. Then, in 2017, a group of researchers at Google published a now-famous paper titled Attention Is All You Need, which introduced the Transformer architecture that underpins most of today’s LLMs (and from which the “T” in GPT is derived).

This development threw something of a spanner into the works for many of the early AI accelerator chips, which had been architected with convolutional neural networks (CNNs) in mind. In the ensuing years, we’ve grown accustomed to thinking of LLMs, with their billions (sometimes hundreds of billions) of parameters, as running on power-guzzling AI accelerator chips residing in humongous data centers.

But, as our old chum Heraclitus would doubtless be quick to point out, things change. No sooner had I started to wrap my brain around Transformers than I was introduced to an alternative deep learning architecture called Mamba, which boasts some significant advantages over its predecessor. Now, with Mamba in mind (no pun intended), the clever folks at BrainChip are telling me that we can run LLMs on battery-powered chips. Oh my!

Let’s take a step back and remind ourselves that, as we discussed in my Bodacious Buzz on the Brain-Boggling Neuromorphic Brain Chip Battlefront column, the guys and gals at BrainChip have made a name for themselves in neuromorphic space (where no one can hear you scream). In particular, we’re talking about their Akida AI Acceleration Processor IP, which features sparse, spiking neural networks (SNNs).

In addition to IP cores, which we can use as part of our own chip designs, the chaps and chapesses at BrainChip also offer development tools, neural models, hardware chips, and reference platforms.

I was just chatting with Steve Brightfield—BrainChip’s chief product officer—about the company’s latest offering, Sequora. Unlike its Akida counterpart, Sequora is not a spiking neuromorphic processor. Instead, it’s based on a completely different computational paradigm. Whereas Akida was conceived to address the problem of performing too many computations, Sequora was designed to tackle the issue of moving too much data, but I fear I’m getting ahead of myself…

The Trouble with Transformers

Before we plunge further into the fray with gusto and abandon, as is our wont, let’s first remind ourselves how conventional Transformer-based LLMs work and why persuading them to run on resource-constrained devices is such a challenge.

Let’s use a text-based LLM as an example. When we present such an LLM with a question, our text is broken down into chunks called tokens. These may correspond to complete words, parts of words, punctuation marks, and so forth. Each token is assigned a numerical identifier, which is subsequently mapped to a vector of numerical values.

Meanwhile, the billions of parameters we hear so much about are predominantly the weights (coefficients) associated with the model. These values, which are established during the training process, collectively determine how the model responds to its inputs.

One of the clever things about Transformers is their use of a mechanism called self-attention. Consider the two sentences “The chicken crossed the road because it was hungry” and “The chicken didn’t cross the road because it was busy.” In the first case, we would naturally associate “it” with the chicken; in the second, we’d almost certainly associate “it” with the road. The attention mechanism allows the model to establish relationships between tokens, including those separated by considerable distances in a sequence.

The problem is that, with conventional full attention, as the number of tokens increases, so does the work required to process each new token.

In conventional causal Transformer attention, each successive token can attend to an increasing number of preceding tokens (Source: Max Maxfield)

One way to avoid repeatedly performing some of the same computations is to store intermediate results associated with previously processed tokens in something called a key-value (KV) cache. Unfortunately, although this reduces the computational burden, it introduces an additional memory burden because the size of the KV cache grows in proportion to the number of tokens in the context.

Furthermore, irrespective of the KV cache, we still have to contend with moving the model’s parameters from wherever they are stored to wherever the computations are performed. In the case of large models, the energy consumed moving all this data around can be as much of a concern as—or even more of a concern than—the energy consumed performing the computations themselves.

This is one manifestation of what is commonly called the “memory wall.” Although the folks designing AI accelerators for data centers are happily throwing vast amounts of high-bandwidth memory (HBM) at the problem, this is hardly a practical proposition if the device in question is something you wish to pop into your ear.

Everything Old Is New Again

As an aside, I studied control engineering at Sheffield Polytechnic (now Sheffield Hallam University) in England in the latter half of the 1970s. Little did I suspect then that techniques rooted in control theory would one day be used to implement LLMs, not least because LLMs were still almost half a century in the future.

One mathematical technique used in modern control theory is the state-space representation. The underlying concept is that the behavior of a dynamic system can be described in terms of its inputs, outputs, and a set of internal state variables. The current state, in conjunction with the current input, is used to determine the next state and the output.

In recent years, researchers have adapted these concepts to create a class of deep learning architectures known as state-space models (SSMs). The fundamental difference between conventional Transformer-based models and SSMs, at least from our perspective here, is how they handle information associated with previously processed tokens.

A state-space model maintains a fixed-size internal state that is updated as each successive token is processed (Source: Max Maxfield)

We might liken a conventional Transformer to someone who maintains an increasingly voluminous transcript of a conversation and refers to it whenever a new question is posed. By comparison, we might liken an SSM to someone who maintains a continually updated set of notes summarizing the conversation’s salient points.

The advantage of the latter approach is that the amount of memory required to maintain the internal state doesn’t increase with the length of the conversation. Also, the amount of computation required to process each successive token doesn’t increase simply because the conversation has grown longer.

Of course, as anyone who has ever tried to take notes during one of my presentations will attest, the trick is knowing what to retain and what to discard. This brings us to December 2023, when Albert Gu and Tri Dao published a paper titled Mamba: Linear-Time Sequence Modeling with Selective State Spaces. One particularly clever aspect of Mamba is that the input itself influences what the model retains in its internal state and what it discards. This might be a good point to pause and watch a short video about Mamba and State Space Models (SSMs).

Does this mean that Transformers are destined for the dustbin of history? Not at all. Transformers do some things extremely well, including retrieving specific pieces of information from earlier in a sequence. By comparison, once information has been lost from an SSM’s internal state, there’s no guarantee it can be recovered.

Happily, these two approaches aren’t mutually exclusive. We’re now seeing hybrid architectures that combine elements of Transformers and SSMs, thereby potentially allowing us to enjoy the best of both worlds.

Enter Sequora

As it turns out, the clever folks at BrainChip have been working with state-space techniques for some time in the form of their Temporal Event-based Neural Networks (TENNs). These are particularly well suited to processing time-series data, such as audio, vibration, and radar signals.

Whereas the guys and gals behind Mamba were primarily interested in sequence modeling, including language processing, the chaps and chapesses at BrainChip were approaching things from a signal-processing perspective. The result, in the form of Sequora, is a native state-space processing engine that supports both types of applications.

Now, there’s nothing to prevent us from running an SSM on a conventional GPU or neural processing unit (NPU). However, as is so often the case in our world of computing, there are advantages to be had by architecting the hardware with the characteristics of the intended workload in mind.

Furthermore, while we can employ models that have been conceived as SSMs from the get-go, we can also use a technique known as “knowledge distillation” to transfer capabilities from an existing Transformer-based model to an SSM-based model. This is not necessarily a lossless process, but the resulting model may be more than adequate for the application at hand.

One interesting difference between Akida and Sequora is how they handle model storage. In the case of Akida, the models are relatively small, allowing all their parameters to be stored in on-chip SRAM. This is one of the reasons Akida can operate at such low power. By comparison, in the case of Sequora, we may be talking about models boasting billions of parameters. Attempting to accommodate all these parameters in on-chip SRAM would be prohibitively expensive for the types of applications we are discussing here.

Instead, the parameters are stored in external memory and streamed into Sequora as required. The beauty of this approach, when running pure SSMs that don’t require a Transformer-style KV cache, is that the parameters can be streamed directly from non-volatile flash memory, potentially obviating the need for external DRAM altogether.

Another piece of the puzzle involves quantization. Although models are commonly trained using higher-precision numerical representations, their parameters can often be represented using far fewer bits when it comes to performing inference. In the case of Sequora, BrainChip can employ four-bit representations of weights that are mapped to floating-point values for use in the actual computations (see also The Rise of 4-Bit and 6-Bit Floating-Point).

Consider the fact that the raw weights associated with a three-billion-parameter model would occupy a whopping 12 GB if represented using 32-bit floating-point values. Using four bits per parameter reduces this to a much more manageable 1.5 GB.

Of course, there’s no such thing as a free lunch. Even though we’ve dramatically reduced the amount of memory required to store the model, we still have to move those parameters into the processing engine at a rate sufficient to support our desired number of tokens per second. Thus, the bandwidth of the memory interface becomes a key consideration.

BrainChip envisages multiple configurations of its Sequora IP, ranging from the relatively small Sequora Nano, which can be used for things like speech recognition and speech synthesis, through a more powerful single-core configuration capable of supporting LLMs with up to three billion parameters, to multi-core configurations capable of supporting considerably larger models.

For those of us who like to get down and dirty with the hardware, Steve tells me that the Akida Pico IP core weighs in at around 150,000 equivalent logic gates, while the Sequora Nano and Sequora single-core IP cores boast around two million and 3.5 million equivalent gates, respectively (where, in this context, an equivalent gate is a two-input NAND).

Pulling It All Together

One thing that “tickles my fancy” is how the Akida and Sequora IP cores complement each other. Consider, for example, a voice-based user interface implemented in a pair of earbuds or smart glasses. 

We could employ an Akida Pico core to perform always-on keyword spotting, consuming around a milliwatt of power while listening for its wake word or phrase. Once the wake word is detected, the Akida Pico can wake a Sequora Nano, which performs automatic speech recognition (ASR), converting our spoken words into a form that can be presented to an LLM.

The resulting tokens can be passed to a more powerful Sequora core running the LLM. The tokens generated by the LLM can subsequently be passed back to a Sequora Nano, which performs text-to-speech (TTS) conversion, allowing the device to respond to us verbally. Note that this implementation could employ two instances of the Sequora Nano IP core, or a single instance could potentially be used to perform both tasks.

Akida and Sequora can be used in conjunction with each other to implement a voice-based interface in a battery-powered device (Source: Max Maxfield)

The key point in this scenario is that we have three distinct power domains. According to BrainChip’s estimates, the always-on keyword-spotting function consumes power on the order of a milliwatt, the speech-processing functions operate in the tens-of-milliwatts range, and the LLM itself operates in the hundreds-of-milliwatts range.

The trick, of course, is that the more power-hungry functions need only be activated when required. For much of the day, the only AI processing taking place may be that associated with the Akida Pico patiently waiting for us to say something interesting (in my case, it may have to wait quite some time).

And all of this can take place without the need for an internet connection, which has implications not only for latency and power consumption but also for privacy, security, and the ongoing costs associated with accessing cloud-based AI services.

Another example Steve and I discussed involved industrial predictive maintenance. We might use an Akida-based sensor node to monitor vibrations from a piece of machinery and detect anomalies that indicate an impending failure.

But detecting that something is amiss is one thing; understanding what’s happening and knowing what to do about it is another. A local language model, in conjunction with the appropriate technical documentation, could allow a maintenance engineer to interrogate the sensor node verbally, asking what has changed, what the likely cause of the problem is, and what steps should be taken to rectify the situation.

At the time of this writing, BrainChip is offering FPGA-based implementations of its Sequora IP for evaluation purposes. Developers can access these implementations remotely via BrainChip’s cloud-based facilities or employ an appropriate FPGA-based hardware platform locally.

I don’t know about you, but I’m finding it increasingly difficult to keep up with the pace of developments in the world of AI. The idea that techniques rooted in the control theory I learned in my misspent youth are now being used to bring generative AI to things like earbuds, toys, and industrial sensor nodes boggles (what little I have left of) my mind. Our old chum Heraclitus certainly had the right of it, didn’t he?

Source: EE Journal