Mojo Puzzles fail to compile on a supported architecture (apple M2)

@debugging

Hi everyone

I have just started solving “Mojo GPU Puzzles”. However, I failed to compile puzzle 1 with this error.

/Users/<user>/mojo-gpu-puzzles/problems/p01/p01.mojo:24:5: error: function instantiation failed
def main() raises:
    ^
/Users/<user>/mojo-gpu-puzzles/problems/p01/p01.mojo:24:5: note: call expansion failed with parameter value(s): (...)
oss/modular/mojo/stdlib/std/gpu/host/info.mojo:2257:9: note: function instantiation failed
oss/modular/mojo/stdlib/std/gpu/host/info.mojo:2266:43: note: call expansion failed with parameter value(s): (...)
oss/modular/mojo/stdlib/std/gpu/host/info.mojo:2482:5: note: function instantiation failed
oss/modular/mojo/stdlib/std/gpu/host/info.mojo:2515:5: note: constraint failed: GPU architecture 'metal:2-metal4' is not supported.

Supported GPU architectures:

  NVIDIA: sm_52 (Maxwell), sm_60/sm_61 (Pascal), sm_75 (Turing), sm_80 (Ampere A100), sm_86 (Ampere A10), sm_87 (Orin), sm_89 (Ada L4/RTX4090), sm_90/sm_90a (Hopper H100), sm_100/sm_100a (Blackwell B100/B200), sm_110 (Jetson Thor), sm_120/sm_120a (Blackwell RTX5090), sm_121 (DGX Spark)
  See: https://developer.nvidia.com/cuda-gpus

  AMD: gfx90a (MI250X), gfx942 (MI300X), gfx950 (MI355X), gfx1030 (Radeon 6900), gfx1100 (Radeon 7900), gfx1101 (Radeon 7800), gfx1102 (Radeon 7600), gfx1103 (Radeon 780M), gfx1150/gfx1151/gfx1152 (Radeon 8xx), gfx1200 (Radeon 9060), gfx1201 (Radeon 9070)
  See: https://rocm.docs.amd.com/en/latest/release/gpu_os_support.html

  Apple: metal:1 (M1), metal:2 (M2), metal:3 (M3), metal:4 (M4)

I tried to find oss/modular/mojo/stdlib/std/gpu/host/info.mojo so I can change the string that checks the architecture as the exact architecture is detected as ‘metal:2-metal4’ but I couldn’t find it on my system. Moreover, I found the find on GitHub. So, I believe maybe the file is already compiled on my environment(?), which is set up by pixi.

Please help me finish my set up. Can’t wait to get my mojo stickers :slight_smile:

There was a temporary problem with GPU detection for Apple silicon GPUs on macOS 26 in the nightlies that was recently resolved. It looks like the Mojo GPU puzzles are pinned to the nightly version just after that was introduced and before it was fixed. We’ll see about updating those to the latest version.

In the meantime, you can work around this by changing the version line in pixi.toml to read

max = "==26.3.0.dev2026042105"

and then deleting the pixi.lock and doing a

pixi clean

The next time you run, it should pull a good version of Mojo / MAX that has the support fixed for Apple silicon GPUs on macOS 26.

I was already on the verge of recompiling stdlib :smiley: But you have already resolved it. Thank you!

It didn’t fix it and compiler asked me to report a bug, which I did.

Make sure you’ve run

xcodebuild -downloadComponent MetalToolchain

to install the proper Metal compilation tools first. When I did the above steps, pixi run -e apple p01 compiles correctly on my Mac with the same configuration as yours.

That fixed it. Thank you.

out: HostBuffer([10.0, 11.0, 12.0, 13.0])
expected: HostBuffer([10.0, 11.0, 12.0, 13.0])
Puzzle 01 complete ✅

Thanks @BradLarson! The mojo gpu puzzles are now updated to the latest nightly that includes the fix for Apple silicon GPU detection.