Running Pi with Ollama and Qwen3.6 on an M3 Pro MacBook

Jul 11, 2026

I wanted a coding agent with a terminal interface that could run entirely on my 36 GB M3 Pro MacBook. The stack I settled on is intentionally small:

Pi TUI -> Ollama API -> Qwen3.6 -> Apple Metal

Ollama handles model downloads, Metal acceleration, and the local API. Pi provides the coding-agent loop and terminal UI.

Choosing the model

Qwen3.6-35B-A3B is a mixture-of-experts model with 35 billion total parameters and roughly 3 billion active parameters per token. The Q4_K_M build occupies about 24 GB, which leaves enough unified memory for macOS, Pi, and a moderate context cache.

The model advertises a 256K context window, but that does not mean allocating 256K is sensible on a 36 GB machine. I start with 32K and reduce it to 16K if memory pressure becomes a problem.

Install Ollama and Node.js

Using Homebrew:

brew update
brew install ollama node

Check the installation:

ollama --version
node --version
npm --version

Start the server if the Ollama macOS application is not already running:

ollama serve

Download Qwen3.6

ollama pull qwen3.6:35b-a3b-q4_K_M

Avoid the Q8, MXFP8, and BF16 variants on a 36 GB machine. They leave too little or no room for the operating system and context cache.

Confirm that the model works:

ollama list
ollama run qwen3.6:35b-a3b-q4_K_M

Use /bye to leave the model prompt.

Limit the context window

Export the model definition:

ollama show --modelfile qwen3.6:35b-a3b-q4_K_M > /tmp/qwen36.Modelfile

Append this setting to /tmp/qwen36.Modelfile:

PARAMETER num_ctx 32768

Create a named coding profile:

ollama create qwen36-coding -f /tmp/qwen36.Modelfile
ollama run qwen36-coding

If Activity Monitor shows sustained yellow or red memory pressure, repeat the process with num_ctx 16384.

Check the local API

Ollama exposes an OpenAI-compatible endpoint that Pi can use:

curl http://localhost:11434/v1/chat/completions \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "qwen36-coding",
    "messages": [
      {
        "role": "user",
        "content": "Reply with exactly: local model works"
      }
    ],
    "temperature": 0
  }'

Install and configure Pi

npm install -g @mariozechner/pi-coding-agent
pi --version
mkdir -p ~/.pi/agent

Create ~/.pi/agent/models.json:

{
  "providers": {
    "ollama": {
      "baseUrl": "http://localhost:11434/v1",
      "api": "openai-completions",
      "apiKey": "ollama",
      "compat": {
        "supportsDeveloperRole": false,
        "supportsReasoningEffort": false
      },
      "models": [
        {
          "id": "qwen36-coding",
          "name": "Qwen3.6 35B-A3B Q4",
          "reasoning": true,
          "contextWindow": 32768,
          "maxTokens": 16384
        }
      ]
    }
  }
}

Create ~/.pi/agent/settings.json:

{
  "defaultProvider": "ollama",
  "defaultModel": "qwen36-coding"
}

If either file already exists, merge these values instead of overwriting the existing configuration. Validate both files before starting Pi:

python3 -m json.tool ~/.pi/agent/models.json
python3 -m json.tool ~/.pi/agent/settings.json

Test the agent loop

Run Pi inside a repository:

cd ~/path/to/project
pi

Use /model to select ollama / qwen36-coding if necessary. I first give it a read-only task:

Inspect this repository without changing anything. Identify the build command,
test command, main entry point, and one small improvement.

Then I verify that tool-driven editing works:

Add a harmless comment to one suitable file, show me the diff, and do not commit.

The important test is whether the model invokes Pi's tools and edits the file. A model that merely describes an edit is not working correctly as a coding agent.

Day-to-day commands

# Show loaded models
ollama ps

# Unload the model and release memory
ollama stop qwen36-coding

# Update Pi
pi update --self

# Refresh the upstream model
ollama pull qwen3.6:35b-a3b-q4_K_M

If the 35B model feels too heavy, qwen3.6:27b-q4_K_M occupies approximately 17 GB and is the next model I would try.

References

RSS
https://blog.ssuyi.tw/posts/feed.xml