Lesson 1 · Unit 04
Why GPUs
Parallel arithmetic, and the two limits of a device
What you practise
- Matrix multiplies run in parallel, memory against compute as the limit, moving data on and off the device, splitting a model across devices in outline
Try a question from this lesson
Pick one
Multiplying a 1,000 × 1,000 matrix by a vector is 1,000 separate dot products. Does any of them need the result of another?
Correct answer
No: all 1,000 can be computed at the same time
Why
Each output is one row dotted with the same vector, independent of every other row. Work with no dependencies can be spread across as many simple cores as you have. A model is almost entirely this kind of work.
The ideas
Concept cards are short on purpose. In the app they appear between questions, after you have met the idea.
Concept
Two kinds of processor
A CPU has a few powerful cores, good at branching, step-by-step work. A GPU has thousands of simple cores that do the same arithmetic on many numbers at once, and its own memory to hold them.
A model is mostly large matrix multiplies: exactly the shape of work a GPU is built for.
Concept
Copies cost time
Data has to travel between main memory and the device. Token ids going in and results coming out are tiny. The weights are not: loading them is the slow part of starting a server.
So keep the model resident on the device, keep intermediate results there, and copy back only what you need.
10 more exercises in the app
- 2× type the answer
- 5× multiple choice
- 1× true or false
- 1× match the pairs
- 1× order the lines
Bitpath is an iOS app in development. Join the waitlist and you get one email when it is ready to try.