Hardware-Aware Model Optimization

Michael BrenndoerferDecember 1, 20262 min read
Language AI HandbookAll chapters
Part 43 of 67Small and On-Device Language Models
Chapter 328Hardware-Aware Model Optimization
Reading section 1 of 11 · Hardware-Aware Model Optimization · 2 minSection 1 of 11 · 2 min

Section 1 of 11 · 2 min read

Reading settings

Definitions

Choose how many terms have tooltips.

Article links

Make inline references clickable

Notes & comments

Memory bandwidth, kernels, quantization formats, sparsity, and co-design for phones, browsers, and edge devices.

At 16 bits per parameter, a billion parameters require two billion bytes of raw weight storage. That is 2 GB in decimal units or about 1.86 GiB in binary units. On a phone, the weights compete for memory with the application and the rest of the system. Once the model fits, a second question determines how fast it can answer. How many bytes must cross the memory bus for each generated token? When a batch-one decode repeatedly reads large weight matrices from DRAM, moving those bytes can cost more time than the multiply-adds. The examples below let you estimate that cost, then check whether quantization and a different kernel change it.

Hardware-aware optimization matches a language model to a target’s memory hierarchy, instruction set, and thermal envelope. Start with a roofline estimate to see which resource could limit the workload. Then use the actual weight layout, scale overhead, and cache size to narrow the options. The worked example uses a small decoder, and its bandwidths and operation rates are inputs to a model. Use them to check the arithmetic before replacing them with measurements from your device.

Packed four-bit weights can save bandwidth when a kernel consumes the packed representation efficiently. If the runtime expands the entire tensor before the hot loop, where the expanded tensor lives determines which traffic savings remain. The same question applies to sparse weights. Check the path that runs, including the transfers it performs.

Comments

Add to the conversation

A question, a correction, or an example from your own work.

No comments yet. Be the first to share your thoughts!

Newsletter

Stay up to date

Get new articles, book updates, and notes on AI and technology.

Unsubscribe at any time. Privacy policy