How does an NPU work?

Authors
How does an NPU work?

An NPU is a special chip built to run AI tasks very fast using very little power. It works by doing a huge number of multiply-and-add operations in its MAC units at once.

In this blog, we will learn about how an NPU works. We will also see why it was created, the multiply-and-add operation at the core of AI, how a CPU, a GPU, and an NPU each do this work, how an NPU keeps data close and saves power, and where we see NPUs in real life.

We will cover the following:

  • What is an NPU?
  • Why do we need an NPU?
  • What does an AI model actually do inside?
  • The core operation: multiply and add
  • How a CPU does this work
  • How a GPU does this work
  • How an NPU does this work
  • The MAC unit inside an NPU
  • How an NPU keeps data close
  • How an NPU saves power
  • A simple step-by-step walkthrough
  • CPU vs GPU vs NPU
  • Where we see NPUs in real life

I am Amit Shekhar, Founder @ Outcome School, I have taught and mentored many developers, and their efforts landed them high-paying tech jobs, helped many tech companies in solving their unique problems, and created many open-source libraries being used by top companies. I am passionate about sharing knowledge through open-source, blogs, and videos.

I teach AI and Machine Learning at Outcome School.

Let's get started.

What is an NPU?

NPU stands for Neural Processing Unit.

An NPU is a special chip built to run AI tasks very fast and using very little power.

In simple words, it is a chip inside our phone or laptop that is made for one main job. That job is to run neural networks.

A neural network is the kind of AI model that powers things like face unlock, voice assistants, photo cleanup, and LLMs. We will learn what a neural network does in a simple way later in this blog.

So, the NPU is not a general worker. It is a specialist. It does AI math, and it does it more efficiently than the other chips on the device.

Why do we need an NPU?

Let's say we want to unlock our phone using our face.

The phone must look at the camera image and decide, "Is this the owner or not?" This decision needs a lot of math, and it must happen in less than a second.

Now, suppose we ask the normal chip of the phone to do this math.

The normal chip can do it. But it will be slow, and it will drain the battery fast. The phone may also become hot.

So, we have a problem. AI tasks need a huge amount of math, and they need it fast, cheap, and cool.

So, here comes the NPU to the rescue.

The NPU is built only for this AI math. It finishes the same work much faster, and it uses far less battery. The phone stays cool, and the result comes instantly.

This is why most modern phones and many laptops now have an NPU inside.

What does an AI model actually do inside?

Before we learn how the NPU works, we must understand what an AI model does. Once we understand the work, the chip will make sense.

A neural network is made of numbers and simple math.

Let's say we show the model a photo. The photo is just a grid of numbers. Each number is the brightness or color of one tiny dot, called a pixel.

The model takes these numbers and passes them through many layers. Each layer is a step that changes the numbers a little, using more numbers called weights.

A weight is just a number the model learned during training. The weights decide what the model pays attention to.

So, most of the work inside an AI model is one thing repeated millions, sometimes billions, of times. It takes some numbers, multiplies them by weights, and adds the results together.

If we want to go deep into Neural Networks and Feed Forward Neural Networks, and even build a Neural Network from scratch, check out our AI and Machine Learning Program at Outcome School.

The core operation: multiply and add

Let's make this very concrete with a small example.

Suppose the input numbers are 2, 3, and 4.

Suppose the weights are 5, 6, and 7.

To process one step, the model does this:

(2 * 5) + (3 * 6) + (4 * 7)
= 10 + 18 + 28
= 56

Here, we can see that we multiplied each input by its weight, and then we added all the results into one final number.

This pattern of "multiply each pair, then add them all up" is the most important operation in AI. It is so important that it has a name. It is called MAC.

MAC = Multiply + Accumulate.

To accumulate means to keep adding into a running total. So, MAC means "multiply two numbers and add the result to the running total".

In our example above, we did three MAC operations to get 56.

A real AI model does not do three MACs. It can do billions of them for a single answer.

So, the goal of AI hardware is to do a massive number of MAC operations as fast as possible while using as little power as possible. We have a detailed blog on how matrix multiplication works in neural networks that explains this step by step.

Now that we understand the work, let's see how each chip handles it.

How a CPU does this work

The CPU (Central Processing Unit) is the main chip of any computer or phone. It is a general-purpose chip. It runs our apps, our browser, our games, and the operating system.

But the CPU is built to do a few tasks at a time, one after another, very quickly.

Let's say we have one billion MAC operations to do. The CPU has only a few workers inside, called cores. A typical CPU has 4 to 16 cores.

So, the CPU does a small batch, then the next, then the next. It is fast per step, but there are far too many steps. Doing AI on a CPU is like emptying a swimming pool with a bucket. The bucket is good, but the pool is huge.

This is why the CPU is not the best choice for heavy AI work.

Planning your move into AI?

No matter which tech domain you work in today, with your effort, you can transition to these roles:

  • AI Engineer
  • Forward Deployed Engineer
  • AI Agent Engineer
  • Harness Engineer
  • Voice AI Engineer
  • AI Architect
  • LLM Engineer
  • LLM Inference Engineer
  • Gen AI Engineer
  • MLOps Engineer
  • ML Engineer
  • Deep Learning Engineer

Our AI and Machine Learning Program at Outcome School takes you there.

How a GPU does this work

The GPU (Graphics Processing Unit) was first built to draw images and run games.

Drawing a screen also needs the same kind of math on many numbers at once. So, the GPU was designed to do many small calculations in parallel.

Parallel means doing many things at the same time, side by side, instead of one after another.

A GPU does not have 4 or 16 cores. It has thousands of small cores. So, it can do thousands of MAC operations at the same moment.

This is why the GPU is much faster than the CPU for AI. Going back to our pool example, the GPU is like using thousands of buckets at once.

So, the GPU is great for AI. In fact, most large AI models in data centers run on GPUs.

The GPU is a general parallel machine. It still spends extra power and extra steps moving data around and managing all those cores. On a small device like a phone, the GPU works hard and uses a lot of battery.

We needed something even more focused for small devices. So, the NPU was introduced to solve this problem.

How an NPU does this work

Now, it's time to learn about the NPU.

The NPU is designed mainly for MAC operations and the few other operations that neural networks need.

Because it does one main job, it can be designed specially for that job. It does not carry the extra weight of running apps or drawing games.

The NPU is full of tiny multiply-and-add machines, packed very close together, working all at the same time.

So, the NPU does the same AI math as the GPU, but it is shaped exactly for it. The result is high speed with far less power.

Let's open up the NPU and see the parts that make this possible.

The MAC unit inside an NPU

Inside the NPU, there are thousands of small units. Each one is called a MAC unit.

A MAC unit does one thing. It takes two numbers, multiplies them, and adds the result to a running total. This is exactly the multiply-and-accumulate work we learned earlier.

Now, the important part is how these MAC units are arranged.

In an NPU, the MAC units are placed in a neat grid, like a chessboard. This grid is often called a systolic array.

The word systolic comes from the heart. Just like our heart pumps blood in a steady rhythm, this array pumps numbers through the grid in a steady rhythm.

Numbers flow into the grid from the side. As a number enters the first MAC unit, it gets multiplied by the weight stored there and added to a running total. Then the input number moves to the next MAC unit on the right, and the running total moves down to the MAC unit below, and so on.

So, the numbers keep flowing through the grid. Once the grid is full, every MAC unit is busy at the same time.

We can see this in a diagram like below:

   Weights stay in place inside each MAC unit

   Inputs flow in -->

   +------+   +------+   +------+   +------+
   | MAC  |-->| MAC  |-->| MAC  |-->| MAC  |
   +------+   +------+   +------+   +------+
      |          |          |          |
      ↓          ↓          ↓          ↓
   +------+   +------+   +------+   +------+
   | MAC  |-->| MAC  |-->| MAC  |-->| MAC  |
   +------+   +------+   +------+   +------+
      |          |          |          |
      ↓          ↓          ↓          ↓
   +------+   +------+   +------+   +------+
   | MAC  |-->| MAC  |-->| MAC  |-->| MAC  |
   +------+   +------+   +------+   +------+

                                  Results flow out

Here, we can see that the inputs flow in from the side and move from one MAC unit to the next. Each unit multiplies, adds to a running total, passes the input to the right, and passes the running total down. Every unit is busy at the same time, and the results come out at the end.

For example, suppose we have a grid of 256 by 256 MAC units. That is over sixty-five thousand MAC operations happening together in every single tick of the clock.

This is how an NPU does a giant amount of math in a tiny moment.

A quick note for you

No matter which tech domain you work in, get familiar with these topics:

  • LLM
  • RAG
  • MCP
  • Agent
  • Fine-tuning
  • Quantization

We put it all together in one video:

AI Engineering Explained: LLM, RAG, MCP, Agent, Fine-Tuning, and Quantization

No need to stop reading - bookmark it and watch later when you get time. Future you will thank you.

Now, let's get back to the topic.

How an NPU keeps data close

Speed is not only about doing math fast. It is also about getting the numbers to the math units fast.

Let's understand this with a real-life example.

Suppose we are cooking. If all the ingredients are right next to the stove, we cook fast. But if we have to walk to another room for every ingredient, we waste a lot of time, even if we chop very fast.

In a chip, the "other room" is the main memory, called RAM. RAM is large, but reaching it is slow and uses a lot of power.

In AI chips, moving data from the main memory often costs much more energy than doing the math itself.

So, the NPU is designed to keep numbers close to the MAC units. It uses small, fast memory placed right next to the grid. This small nearby memory is called on-chip memory or SRAM.

We can see the layout in a diagram like below:

+--------------------------------------------+
| Far away RAM (large but slow)              |
| Reaching it costs a lot of time and power  |
+--------------------------------------------+
                      ↓
            Fetch once, then reuse
                      ↓
+--------------------------------------------+
| NPU                                        |
|                                            |
|  +----------------+   +----------------+   |
|  | On-chip memory |-->| MAC grid       |   |
|  | (SRAM, close)  |   | (the math)     |   |
|  +----------------+   +----------------+   |
|                                            |
|  Numbers stay close to the math            |
+--------------------------------------------+

Here, we can see that the far away RAM is reached as few times as possible. After that, the numbers sit in the small on-chip memory right next to the MAC grid, so the math units can reach them fast and reuse them.

The NPU loads the weights once and reuses them many times right where they sit. The input numbers flow through the grid and are reused as they pass from one MAC unit to the next.

So, the same number does a lot of work before it is thrown away. We fetch less from the far away RAM. We save time, and we save power.

This is one of the biggest reasons an NPU is more power-efficient than a CPU and a GPU for on-device AI.

How an NPU saves power

Now, let's understand the power saving in a simple way.

The first trick we already learned. The NPU moves data less by keeping it close. Less movement means less energy.

The second trick is about the size of the numbers.

A CPU usually works with very precise numbers that take a lot of space, like 32 bits each.

But AI models often do not need such high precision. A rough number is good enough for the model to give a correct answer.

So, the NPU uses smaller numbers, often just 8 bits each. Using smaller numbers is called quantization.

Quantization means turning big, precise numbers into smaller, simpler numbers that are good enough.

Smaller numbers need less memory, move faster, and use less power. And the model usually still gives the right answer for things like recognizing a face or a voice.

The third trick is focus. The NPU has no extra parts for running apps or games. Most of its area is used for AI math.

So, less data movement, smaller numbers, and focus together make the NPU very power friendly.

To master Quantization and Optimizations, Model Deployment and Serving, and Cloud vs On-device Deployment in depth, we have a complete program: our AI and Machine Learning Program at Outcome School.

A simple step-by-step walkthrough

Let's put everything together with one full example. Suppose our phone wants to recognize a cat in a photo using the NPU.

Step 1: The camera gives a photo. The photo becomes a big grid of numbers, where each number is one pixel.

Step 2: The phone sends these numbers and the model weights to the NPU.

Step 3: The NPU loads the weights into its small, fast on-chip memory, right next to the MAC grid.

Step 4: The input numbers start flowing into the systolic array from the side.

Step 5: Each MAC unit multiplies an input by a weight and adds it to a running total, then passes the number forward to the next unit.

Step 6: Thousands of MAC units do this at the same time, layer after layer, using small 8-bit numbers to stay fast and cool.

Step 7: After all the layers, the NPU produces a final set of numbers. One of these numbers is the highest, and it points to the answer.

Step 8: The answer comes out. It says, "This is a cat." The result appears quickly, using very little battery.

This is how an NPU works, from the photo to the answer.

Stay updated: Subscribe to our newsletter to get our latest AI and Machine Learning blogs straight to your inbox.

CPU vs GPU vs NPU

Let me tabulate the differences between the CPU, the GPU, and the NPU for your better understanding.

PointCPUGPUNPU
Main jobRun everything, general tasksDraw graphics and heavy parallel mathRun AI neural networks
Workers insideA few coresThousands of coresThousands of MAC units in a grid
Style of workOne after another, very fast per stepMany tasks in parallelAI math only, in steady flow
Power use for AIHighMedium to highLow
Best forApp logic, operating systemBig AI in data centers, gamingOn-device AI on phones and laptops

Here, we can see that each chip is best at its own job.

In fact, a modern phone uses all three together. The CPU runs the app, the GPU draws the screen, and when an AI task arrives, the work is often handed to the NPU.

We have a detailed blog on how an LPU works that covers another chip built just for AI, made to run LLMs and produce text as fast as possible.

Where we see NPUs in real life

We use NPUs every day, often without knowing it.

When we unlock our phone with our face, the NPU is doing the matching.

When we talk to a voice assistant and it understands us without the internet, the NPU is running the speech model.

When our camera removes a stranger from the background or sharpens a blurry photo, the NPU is cleaning the image.

When an LLM runs directly on our laptop without sending our words to a server, the NPU can run the model.

Now we must have understood how an NPU works and how it makes AI run fast on our phones and laptops.

Frequently Asked Questions

Does an NPU replace the CPU and the GPU in a phone?

No. An NPU does not replace them. A modern phone uses all three together. The CPU runs the app, the GPU draws the screen, and when an AI task arrives, the work is often handed to the NPU, which runs it faster and with far less battery.

Why does an NPU use 8-bit numbers instead of 32-bit numbers?

Because AI models often do not need such high precision. A rough number is good enough for the model to give a correct answer. Smaller numbers need less memory, move faster, and use less power, and the model usually still gives the right answer for things like recognizing a face or a voice.

Can an NPU run an LLM?

Yes. When an LLM runs directly on our laptop without sending our words to a server, the NPU can run the model. An LLM is a neural network, and an NPU is a chip made for one main job: running neural networks with a huge number of multiply-and-add operations.

Do large AI models in data centers run on NPUs?

Mostly no. Most large AI models in data centers run on GPUs, which are great general parallel machines. The NPU is best for on-device AI on phones and laptops, where it gives high speed with far less power and keeps the device cool.

That's it for now.

Thanks

Amit Shekhar
Founder @ Outcome School

You can connect with me on:

Follow Outcome School on:

Read all of our high-quality blogs here.