Skip to content

Instantly share code, notes, and snippets.

@devxoul
Last active April 14, 2026 02:23
Show Gist options
  • Select an option

  • Save devxoul/dc01c7c82335b6d1c1054c294eaa547e to your computer and use it in GitHub Desktop.

Select an option

Save devxoul/dc01c7c82335b6d1c1054c294eaa547e to your computer and use it in GitHub Desktop.

Running Gemma 4 in LM Studio 0.4.x (mlx-vlm Upgrade)

Just paste this gist link to your AI agent and ask to do.

LM Studio 0.4.x bundles older versions of mlx-vlm and mlx-lm that don't support Gemma 4. This guide upgrades both packages and removes a hardcoded block.

LM Studio MLX Engine Bundled mlx-vlm Bundled mlx-lm Gemma 4
0.4.9 1.4.0 0.4.0 0.30.8
0.4.11 1.5.0 0.4.0 0.31.2

⚠️ Important

LM Studio code-signs all bundled native libraries (.so, .dylib) with its own Team ID. A full pip install --upgrade would replace these files with unsigned PyPI versions, causing dlopen errors.

Both mlx-vlm and mlx-lm are pure Python packages (no .so files), so upgrading them with --no-deps is safe.

Steps

1. Quit LM Studio

killall "LM Studio"

2. Find your runtime name

~/.lmstudio/bin/lms runtime ls

Look for the mlx-llm-mac-arm64-apple-metal-* entry marked with and note the full name.

3. Reinstall the MLX runtime (skip if already working)

RUNTIME="<your-runtime-name-from-step-2>"  # e.g. mlx-llm-mac-arm64-apple-metal-nax-advsimd@1.5.0

~/.lmstudio/bin/lms runtime remove "$RUNTIME" -y
~/.lmstudio/bin/lms runtime get "$RUNTIME" -y
~/.lmstudio/bin/lms runtime select "$RUNTIME"

4. Upgrade mlx-vlm and mlx-lm in all runtime copies (--no-deps is required!)

LM Studio keeps multiple runtime versions internally. Upgrade all of them.

mlx-lm doesn't have a Gemma 4 release on PyPI yet, so install from GitHub main:

PYTHON=$(ls ~/.lmstudio/extensions/backends/vendor/_amphibian/cpython3.11-mac-arm64@*/bin/python3.11 | head -1)

for sp in ~/.lmstudio/extensions/backends/vendor/_amphibian/app-mlx-generate-mac*-arm64@*/lib/python3.11/site-packages; do
  "$PYTHON" -m pip install --target "$sp" --upgrade --no-deps mlx-vlm
  "$PYTHON" -m pip install --target "$sp" --upgrade --no-deps "mlx-lm @ git+https://github.com/ml-explore/mlx-lm.git"
done

5. Remove the Gemma 4 block in mlx-engine

LM Studio 0.4.11+ ships with a hardcoded check in mlx_engine that rejects Gemma 4 models (mlx-engine#301). Remove it:

for f in ~/.lmstudio/extensions/backends/vendor/_amphibian/app-mlx-generate-mac*-arm64@*/lib/python3.11/site-packages/mlx_engine/generate.py; do
  sed -i '' '/if model_type == "gemma4":/,/raise ValueError.*Gemma 4/d' "$f"
done

6. Launch LM Studio → Load Gemma 4 🎉

Notes

  • After LM Studio updates, the runtime may reset. Re-run steps 4–5 if Gemma 4 stops loading.
  • Paths vary by macOS version — the glob patterns above handle both mac14 (macOS 14) and mac26 (macOS 26) automatically.
  • Once mlx-lm releases Gemma 4 on PyPI, step 4 can use mlx-lm instead of the git URL.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment