Repository navigation
Description
Describe the bug
metal_capture does not capture a working GPU trace on MacOS 26.1
It generates the file mlx_trace.gputrace, but opening it results in multiple errors
To Reproduce
With Xcode 26.1.1 on MacOS 26.1 on MacMini M1:
git clone https://github.com/ml-explore/mlx.git
mkdir build && cd build
cmake .. -DMLX_METAL_DEBUG=ON -G Xcode
open mlx.xcodeprojEnable 'Automatically managing signing' and set Team in 'Signing & Capabilities' for metal_capture
Run metal_capture
open examples/cpp/Debug/mlx_trace.gputraceenable 'Profile after replay' IMPORTANT: (You won't see the errors unless you enable this, or click the Profile button (in the Performance section) afterwards)
click replay
'Unexpected Replayer Termination' see below [1] for error text
// secondary error, likely partially resolved if the above is fixed. Debugging (somewhat) seems to work if you don't try to profile first. MacOS 15.7 also gives the 'No Function Found' error, so likely a seperate issue.
Switch to Group by Pipeline State
Open the first Compute Pipeline
Click arrangefloat32
Right click in shader source and select 'Debug Function...'
Click OK on 'No Function Found' error
Click Debug
'No Replay Device' see below [2] for error text
[1]
=== Crash Info ===
Signal: SIGABRT
=== Error summary: ===
1x DYErrorDomain (512) - guest app crashed (512)
1x com.apple.gputools.MTLReplayer (150) - Metal object creation failed.
25x com.apple.gputools.MTLReplayer (200) - The replayer encountered a Metal validation layer error.
1x com.apple.gputools.MTLReplayer (100) - Abort trap: 6
=== First Error ===
Domain: com.apple.gputools.MTLReplayer
Error code: 150
Description: Metal object creation failed.
=== Setup ===
Capture device: Macmini9,1 - macOS 26.1 (25B78)
Replay device: Macmini9,1 - macOS 26.1 (25B78)
Host: Macmini9,1 - macOS 26.1 (25B78)
Tool: Xcode (17B100)
Known SDKs:
[2]
=== First Error ===
Domain: GPUShaderDebuggerTraceErrorDomain
Error code: 0
Description: Internal error: No replay device
=== GPUDebugger Item ===
API Call: 43 [dispatchThreads:{9, 1, 1} threadsPerThreadgroup:{9, 1, 1}]
Resource: arangefloat32
=== Setup ===
Capture device: Macmini9,1 - macOS 26.1 (25B78)
Replay device: Macmini9,1 - macOS 26.1 (25B78)
Host: Macmini9,1 - macOS 26.1 (25B78)
Tool: Xcode (17B100)
Known SDKs:
Expected behavior
metal_capture should generate a working GPU trace on MacOS 26.1 with XCode 26.1.1
Desktop (please complete the following information):
- OS Version: MacOS 26.1
- Version XCode 26.1.1
Additional context
GPU traces from frame captures of various samples in Metal Sample Code work correctly in MacOS 26.1 with XCode 26.1.1
metal_capture generates a working trace on MacOS 15.7.2 with XCode 26.1.1 (and XCode 16.4)
I believe metal_capture generates similar errors on MacoS 26.1.1 with XCode 16.4, so more likely an OS compatibility issue than XCode issue.
Activity
Sahilbhatane commentedon Nov 28, 2025
@mrcodechef can i work on this bug? if you need a planning map i can provide you one of solving this issue.
mrcodechef commentedon Nov 28, 2025
@Sahilbhatane I'm not the one to ask. I only reported the bug and don't have any association with the mlx project.
Sahilbhatane commentedon Nov 28, 2025
are you working on this? by any chances, if not @kashif or @jaju please check this issue and assign to me.
mrcodechef commentedon Nov 28, 2025
@Sahilbhatane Given this issue seems to be MacOS 26+ specific, it may be an OS issue. Unless you have access to fix the MacOS source code, it seems likely there is nothing you can do for this.
(I've tested back to v.27.1, so I don't think it's specific to the Metal 4 stuff.)
mrcodechef commentedon Dec 4, 2025
Still broken in MacOS 26.2rc and Xcode 26.2rc
awni commentedon Dec 4, 2025
I reran the example on 26.2 (most recent beta) and it worked fine for me.
awni commentedon Dec 4, 2025
I ran it on an M5 however.. so it's possible it doesn't work on M1
mrcodechef commentedon Dec 4, 2025
It still works in MacOS 15.7 on M1, so likely a MacOS 26+ M1-M? issue? I've submitted the error via the Feeback tool, but is there a better way to get it looked at? I've never had any success getting a feedback issue resolved in the past.
mrcodechef commentedon Dec 12, 2025
Still broken in release version of Xcode 26.2 and MacOS 26.2 on Mac Mini M1
mrcodechef commentedon Jan 13, 2026
Still broken in Xcode 26.2 and MacOS 26.3 Beta 2 on Mac Mini M1 (through Mx ??)
[-][BUG] metal_capture does not capture working GPU trace in MacOS 26.1[/-][+][BUG] metal_capture does not capture working GPU trace in MacOS 26+ On Mac Mini M1[/+]mrcodechef commentedon Feb 3, 2026
Still broken in Xcode 26.3 RC and MacOS 26.3 current beta on Mac Mini M1 (through M? - works on M5)
robertmsale commentedon Feb 8, 2026
@mrcodechef I followed the repro on an M1 Ultra running macOS 26 and I wasn’t able to reproduce the replay/crash errors — the
.gputraceopened and replayed cleanly for me.Since this issue seems to reproduce for some M1 systems but not others (and works on newer chips), it’d be useful to rule out an environment / build configuration difference.
Could you share the output of:
sw_vers(already present in your bug report, useful for anyone else trying to reproduce the issue)xcodebuild -version(already present)cmake --version(and where it comes from:which cmake)xcodebuild -showsdks | grep "macOS"(or at least the macOS SDK version used)Also to rule out any sneaky environment variables, you might try the reproduction steps using
/bin/zsh -f -c 'cmake .. -DMLX_METAL_DEBUG=ON -G Xcode'.On my end, if you share the exact mlx version or commit hash you have checked out I'd like to try it with that specific version for consistent reproducibility.
mrcodechef commentedon Feb 8, 2026
@robertmsale (CC: @awni in case this is why he couldn't reproduce it as well)
There is another necessary condition, that you seem to have missed. Sorry it wasn't more explicit.
Turn on "Profile after replay" (or click the Profile button (in Performance) after loading the replay). I also don't see an errors without it.
I rebuilt with latest commit (8fe1d09) and the error still occurs.
robertmsale commentedon Feb 8, 2026
@mrcodechef I have good news! Xcode crashed when I tried to profile the gputrace. Sorry I missed that detail in the original post.
I was able to get more diagnostic information:
I think this is something that can be fixed! When I get back to my desk tomorrow I'll dig into it further :)
mrcodechef commentedon Feb 8, 2026
I hope so! Based on the fact it works on older MacOS versions, yet fails in MacOS 26+ even with the same build of XCode, I suspect it's an OS issue. No luck getting any response from my Feedback submissions though.
robertmsale commentedon Feb 8, 2026
Good news! It's not an OS issue, but I bet in macOS 26.x.x the Metal library imposed a limit on the number of mutations to a residency set during gputrace replaying. And perhaps the limit is hardware-based, which would explain why @awni was unable to reproduce it on a M5 chip.
The problem is the allocator is performing residency set mutations during GPU capture, and there is a hard limit during replay (32 on our machines, test was performing 56 adds, giving us 24 add errors). The fix was to disable residency set mutations during capture, and I was able to run a complete profile and view all of the execution paths in the graphs! You're welcome to give my PR a spin just to double-confirm the fix works.
zcbenz commentedon Aug 16, 2026
I'm closing this since this is a macOS issue and we haven't seen similar reports recently.