WEBVTT

1
00:00:00.700 --> 00:00:03.830
Inference means using a trained
model, not training one.

2
00:00:04.050 --> 00:00:07.360
Every time a chatbot answers,
that is inference happening.

3
00:00:07.580 --> 00:00:10.690
Local inference runs that
model on hardware you own.

4
00:00:10.910 --> 00:00:14.970
Prompts stay private, costs stay
fixed, and it works offline.

5
00:00:16.600 --> 00:00:20.190
Text becomes tokens, small
chunks of characters or words.

6
00:00:20.410 --> 00:00:23.540
The context window is how
many tokens fit in memory.

7
00:00:23.760 --> 00:00:25.760
The work then happens in two phases.

8
00:00:25.980 --> 00:00:29.550
Prefill, the first phase, reads
the whole prompt in parallel.

9
00:00:29.770 --> 00:00:33.200
Decode, the second phase,
writes one token at a time.

10
00:00:34.800 --> 00:00:38.540
A CPU has few fast cores;
a GPU has thousands.

11
00:00:38.760 --> 00:00:41.600
Apple Silicon uses
unified memory for both.

12
00:00:41.820 --> 00:00:44.500
An NPU speeds narrow work at low power.

13
00:00:44.720 --> 00:00:47.740
Decode speed follows
memory bandwidth closely.

14
00:00:47.960 --> 00:00:51.050
DDR5 moves 100 gigabytes per second.

15
00:00:51.270 --> 00:00:54.830
An M4 Pro moves 273 gigabytes per second.

16
00:00:55.050 --> 00:01:02.090
An RTX 4090 moves 1 terabyte per
second; an H100 moves 3.35 terabytes.

17
00:01:03.700 --> 00:01:07.260
Memory is a ladder, from fast
and tiny to slow and huge.

18
00:01:07.480 --> 00:01:09.640
Registers and SRAM sit on the chip.

19
00:01:09.860 --> 00:01:13.130
L2 is shared; HBM is the workspace.

20
00:01:13.350 --> 00:01:16.520
DRAM is system memory; SSDs store weights.

21
00:01:16.740 --> 00:01:19.940
If weights don't fit,
layers stream over PCIe.

22
00:01:20.160 --> 00:01:23.050
PCIe moves 64 gigabytes per second.

23
00:01:23.270 --> 00:01:25.930
Offloading layers costs tokens per second.

24
00:01:27.530 --> 00:01:31.150
The GPU runs thousands of
tiny programs called kernels.

25
00:01:31.370 --> 00:01:35.150
Matrix multiply dominates, so
kernels tile it into blocks.

26
00:01:35.370 --> 00:01:39.570
Attention is softmax of Q times
K transpose, over root dk.

27
00:01:39.790 --> 00:01:43.220
Softmax turns scores into
percentages summing to one.

28
00:01:43.440 --> 00:01:47.590
RoPE encodes position; LayerNorm
stabilizes activations.

29
00:01:47.810 --> 00:01:50.700
Kernel fusion merges steps
into one memory trip.

30
00:01:50.920 --> 00:01:53.810
FlashAttention does that,
keeping tiles on chip.

31
00:01:55.430 --> 00:01:58.780
A roofline chart plots speed
against arithmetic intensity.

32
00:01:59.000 --> 00:02:01.570
Intensity is math
performed per byte loaded.

33
00:02:01.790 --> 00:02:04.330
Below the ridge, a
workload is memory-bound.

34
00:02:04.550 --> 00:02:07.030
Above the ridge, it becomes compute-bound.

35
00:02:07.250 --> 00:02:10.710
Prefill handles many tokens at
once, so it is compute-bound.

36
00:02:10.930 --> 00:02:14.470
Decode reloads every weight per
token, so it is memory-bound.

37
00:02:16.100 --> 00:02:18.660
Quantization stores each
weight in fewer bits.

38
00:02:18.880 --> 00:02:23.410
FP16 uses two bytes, INT8
one, INT4 half a byte.

39
00:02:23.630 --> 00:02:27.810
An 8-billion-parameter model
needs 16 gigabytes at FP16.

40
00:02:28.030 --> 00:02:31.410
Q4_K_M cuts that to about 4.8 gigabytes.

41
00:02:31.630 --> 00:02:35.090
Perplexity measures the error,
and flattens near 4 bits.

42
00:02:35.310 --> 00:02:38.230
GGUF file names show the
scheme and bit width.

43
00:02:39.830 --> 00:02:42.590
At 8 gigabytes, a 4-bit 7B fits.

44
00:02:42.810 --> 00:02:45.910
At 16, the same model, longer context.

45
00:02:46.130 --> 00:02:49.200
At 24 gigabytes, a 4-bit 13B.

46
00:02:49.420 --> 00:02:52.440
At 48 to 64, a quantized 70B.

47
00:02:52.660 --> 00:02:55.650
At 128, 70B at full precision.

48
00:02:55.870 --> 00:02:58.190
Dense models use all their parameters.

49
00:02:58.410 --> 00:03:02.060
Mixture-of-experts stores
100 billion and activates 10.

50
00:03:03.670 --> 00:03:07.090
Each token keeps keys
and values: the KV cache.

51
00:03:07.310 --> 00:03:11.500
Size is two, times layers, times
KV heads, times head width.

52
00:03:11.720 --> 00:03:15.090
Times context, times batch, times bytes.

53
00:03:15.310 --> 00:03:18.290
8,000 tokens: a gigabyte per sequence.

54
00:03:18.510 --> 00:03:20.550
A batch of 8: 8 gigabytes.

55
00:03:20.770 --> 00:03:23.880
Grouped-query attention shrinks
that cache several-fold.

56
00:03:24.100 --> 00:03:27.130
Prefix caching reuses a
shared prompt's entries.

57
00:03:28.730 --> 00:03:31.040
Runtimes run models on your own machine.

58
00:03:31.260 --> 00:03:35.230
llama.cpp is the lean
C++ engine behind GGUF.

59
00:03:35.450 --> 00:03:37.920
Ollama and LM Studio wrap it in apps.

60
00:03:38.140 --> 00:03:42.580
vLLM serves many users with
PagedAttention and continuous batching.

61
00:03:42.800 --> 00:03:47.570
MLX targets Apple Silicon;
TensorRT-LLM targets NVIDIA.

62
00:03:47.790 --> 00:03:50.720
Exo spreads one model
across several machines.

63
00:03:50.940 --> 00:03:53.170
Choose by hardware, not by hype.

64
00:03:54.770 --> 00:03:56.860
Two numbers describe how it feels.

65
00:03:57.080 --> 00:04:00.110
Time to first token is how long
you wait for the first word.

66
00:04:00.330 --> 00:04:03.060
Tokens per second is how
fast the rest arrives.

67
00:04:03.280 --> 00:04:06.800
Throughput counts everyone's
tokens; latency counts yours.

68
00:04:07.020 --> 00:04:10.470
Continuous batching lets new
requests join a running batch.

69
00:04:12.100 --> 00:04:15.190
Tensor parallelism splits
each layer across devices.

70
00:04:15.410 --> 00:04:18.020
Pipeline parallelism
gives each device layers.

71
00:04:18.250 --> 00:04:20.770
The interconnect speed decides the result.

72
00:04:20.990 --> 00:04:23.780
PCIe moves 64 gigabytes per second.

73
00:04:24.000 --> 00:04:27.960
Thunderbolt 5 gives 10,
200-gigabit Ethernet 25.

74
00:04:28.180 --> 00:04:31.410
NVLink reaches 900 gigabytes per second.

75
00:04:31.630 --> 00:04:36.460
DGX Spark: 128 gigabytes, 273 per second.

76
00:04:36.680 --> 00:04:39.450
Two to four nodes link via ConnectX-7.

77
00:04:39.680 --> 00:04:42.610
Mac minis cluster over
Thunderbolt 5 with Exo.

78
00:04:44.230 --> 00:04:47.760
Local inference is weights plus
cache, on hardware you own.

79
00:04:47.990 --> 00:04:51.350
Bandwidth sets the speed;
quantization sets the fit.

80
00:04:51.570 --> 00:04:53.960
Kernels and runtimes do the heavy lifting.

81
00:04:54.180 --> 00:04:57.480
One machine is often enough,
and clusters extend it.
