The meta-problem nobody warns you about
Here's the dirty secret of working with MLX in 2026: when you ask an LLM coding assistant to write MLX code, it confidently produces output that looks plausible and is often wrong. Functions that don't exist (mx.linalg.det, anyone?). Method signatures that were renamed two releases ago. Patterns from PyTorch that don't translate. The output is fluent, syntactically valid Python — and broken.
This is not the LLMs' fault, exactly. MLX is too young and too distinct from PyTorch to live in pretrained-LLM weights at the level of fluency they manage for older frameworks. The training data has thousands of examples of torch.tensor.to(device) and a few dozen of mlx.core.array. The model averages, hallucinates, and produces confident wrong answers.
This lesson is the field guide to surviving it. The rituals I use to keep myself honest, and the disposition that lets you treat LLM-written MLX code as a rough draft you must verify, never as a finished artifact.
Smell the hallucination
Common patterns of bad LLM-generated MLX code:
- References to functions that don't exist — the LLM extrapolates from PyTorch / NumPy / JAX and invents an MLX equivalent that sounds right.
mx.linalg.det,mx.tensor,mx.no_grad(),mx.cuda.is_available(). Ask yourself: "would I bet money this exists?" If you can't, look it up. - Mixed-up API surfaces — code that mixes
torch.tensorandmx.array, or importsmlx.nn as nnandtorch.nn as nnwithout realizing. The LLM is patching together patterns from multiple frameworks. - Stale API names — code using API names that mlx-lm or mlx-vlm renamed in the last few releases. The LLM's training cutoff is the wrong date for MLX.
- Suspiciously confident architecture details — "the default group_size for quantization is 32" (it's 64 in mlx-lm). The LLM fills in details rather than admitting uncertainty.
The verification rituals
- Run it. Always. The fastest way to catch a hallucinated function is to run the snippet — Python's import-time errors are unforgiving in a useful way.
- Check against the real source.
mlx_lm's GitHub repo is small enough to grep — when in doubt, search for the function name in the actual code. - Use --help and dir().
python -m mlx_lm convert --helptells you the real flag list.dir(mlx.core)in a REPL tells you what's actually exposed. - Cite the version. When you ask an LLM about MLX, prefix with "as of mlx 0.31.x" or whatever version you're on. Doesn't fix the problem, but makes the model less likely to draw on stale snippets.
- Trust mlx-examples and mlx-lm source over LLM output. The reference repos are the ground truth; the LLM is a paraphrase.
What I do differently when writing this quest
Every code block in MLX Quest was actually run in the verification env before it was written down. Not just "compiled in my head" — actually run, with the actual output captured and pasted into the comments. That's the only way I trust the code I'm asking you to learn from. The lesson is: do the same when you're writing MLX in production. Run before you ship.