# Mac exercise for mission 9.3: Does the model fit on this Mac?

Part of the course “AI from Zero to Autonomous Agents” (https://llm.yoga/en). Page for humans: https://llm.yoga/en/mac-9-3

About 10 minutes at your computer · Type this address: **llm.yoga/en/mac-9-3**

You read out how much memory your Mac has, load qwen3:8b and have the page work out what share it takes up. With 8 GB, use qwen3:1.7b. Replace qwen3:8b in every command below, including cleanup.

**Before you start**

You need **Ollama** and Python 3 in the terminal. Ollama comes as an app: download it from ollama.com/download and drag it into your Applications folder. On first launch, the app asks permission, if needed, to set up the `ollama` terminal command. It requires macOS 14 or newer. More on this in [chapter 10](https://llm.yoga/en/10-lokale-modelle-4.md). Check:

```
ollama --version
```

Python 3 may need to be installed. On the first `python3` call, macOS may offer to install developer tools; alternatively, Python is available from python.org.

### 1. Read out the memory

```
sysctl -n hw.memsize
```

**Output on the test Mac (24 GB, in bytes)**

```
25769803776
```

### 2. Load the model

qwen3:8b is 5.2 GB. The prompt „Hallo“ (hello) is only there to load the model.

```
ollama pull qwen3:8b
```

```
curl -s http://localhost:11434/api/generate -d '{"model": "qwen3:8b", "prompt": "Hallo", "stream": false, "think": false, "keep_alive": "3m", "options": {"num_ctx": 4096, "num_predict": 1}}' > /dev/null
```

```
ollama ps
```

**Output (Measured on an M4 Mac (24 GB) on November 24, 2026)**

```
NAME        ID              SIZE      PROCESSOR    CONTEXT    RUNNER      UNTIL
qwen3:8b    500a1f067a9f    5.6 GB    100% GPU     4096       llamacpp    About a minute from now
```

With `"num_ctx": 16384` it was 7.0 GB. For 12,288 more tokens at 144 KiB, the formula predicts about 1.8 GB; here Ollama needed 1.4 GB more, a bit less than the simple calculation.

### 3. Let the page check the share

Paste the number from step 1 and the line from `ollama ps`. The page compares the display with a rough planning rule; it does not measure a fixed Mac memory limit.

### 4. For long context: quantize the KV cache

Ollama reads the setting `OLLAMA_KV_CACHE_TYPE=q8_0` when the server starts. A supported backend with Flash Attention is required. Ollama’s FAQ describes how to set environment variables for the app. (Checked against the documentation, not run here)

### 5. Clean up

```
ollama stop qwen3:8b
```

If you only pulled qwen3:8b for this exercise: `ollama rm qwen3:8b`.
