Running Pi with Ollama and Qwen3.6 on an M3 Pro MacBook
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:
Check the installation:
Start the server if the Ollama macOS application is not already running:
Download Qwen3.6
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:
Use /bye to leave the model prompt.
Limit the context window
Export the model definition:
Append this setting to /tmp/qwen36.Modelfile:
PARAMETER num_ctx 32768
Create a named coding profile:
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:
Install and configure Pi
Create ~/.pi/agent/models.json:
Create ~/.pi/agent/settings.json:
If either file already exists, merge these values instead of overwriting the existing configuration. Validate both files before starting Pi:
Test the agent loop
Run Pi inside a repository:
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
# Unload the model and release memory
# Update Pi
# Refresh the upstream model
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.