Set up your environment
Keep an environment record for every experiment
Start with a short output, then increase the context length and batch size. Unified memory is shared by the system, model weights, cache, and other processes, so the advertised capacity isn’t all available to your model.
Check Python
First, run python3 --version. We recommend creating a virtual environment with Python 3.11 or a newer supported version. Requirements depend on the installed versions of MLX and mlx-lm. Don’t overwrite the system environment.
Run uname -m to check the process architecture. A native Apple Silicon environment should show arm64. Also note the Python path to avoid using different interpreters in your terminal and task scripts.
Install dependencies
In your virtual environment, run python -m pip install mlx mlx-lm so pip and Python use the same interpreter. If installation fails, save the final part of the error output. Don’t switch back and forth between system-wide and virtual environment installs.
Once everything works, run python -m pip freeze to save a dependency list. When comparing model results later, also record dependency versions and the model’s quantization method.
Store model weights
For an initial small-scale test, you can use $HOME/models. Before downloading, run df -h to check available space on the target volume. Leave extra room for extracted files, converted copies, caches, and experiment outputs.
If you add an SSD, use its actual mount path and update both the model download directory and the model path in your commands. Don’t move only the weights while leaving the download cache on the original drive.
Check memory
In the macOS graphical interface, open Activity Monitor to check memory pressure and swap usage. From the command line, run vm_stat to view virtual memory statistics. Use the page size shown on the first line of the output.
Record memory before loading, after loading, and during generation. If memory pressure keeps rising, first shorten the context, reduce the batch size, or use suitably quantized weights. Then decide whether you need a higher-memory tier.