Skip to content

metal : fix graph capture and handle empty graphs - #29390

Merged
ggerganov merged 1 commit into
masterfrom
gg/metal-capture-fixes
Sep 24, 2026
Merged

ggerganov merged 1 commit into
masterfrom
gg/metal-capture-fixes

Conversation

@ggerganov

@ggerganov ggerganov commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

Overview

Small fixes to the Metal graph capture path in ggml_metal_graph_compute:

  • Return GGML_STATUS_SUCCESS early when the graph has no nodes, avoiding the command-buffer/capture machinery for an empty graph.
  • Drop the redundant reset of ctx->capture_compute: the decrement at the top of the function already transitions the counter from 0 to -1, so a capture happens exactly once (whether or not the capture scope starts successfully).
  • Surface a did you set METAL_CAPTURE_ENABLED=1 ? hint in the capture error message.
  • Pass ctx->capture_compute == 0 (rather than the raw counter) as the use_capture argument to ggml_metal_op_init. The counter is a countdown, so any non-zero value (including -1 after the first compute) coerced to true and caused per-node GPU debug-group markers to be emitted on every compute instead of only on the captured one.

Requirements

@ggerganov
ggerganov force-pushed the gg/metal-capture-fixes branch from 5a92090 to ac0c117 Compare September 24, 2026 16:52
- return early when the graph has no nodes
- drop the redundant reset of capture_compute: the decrement at the top
  of the function already transitions the counter from 0 to -1, so a
  capture happens exactly once
- hint at METAL_CAPTURE_ENABLED=1 in the capture error message
- pass capture_compute == 0 (not the raw counter) as use_capture to
  ggml_metal_op_init, so GPU debug-group markers are only emitted on the
  captured compute

Assisted-by: pi:llama.cpp/Qwen3.8-27B
@ggerganov
ggerganov force-pushed the gg/metal-capture-fixes branch from ac0c117 to ca6b39a Compare September 24, 2026 16:53
@ggerganov
ggerganov marked this pull request as ready for review September 24, 2026 17:12
@ggerganov
ggerganov requested a review from a team as a code owner September 24, 2026 17:12
@github-actions github-actions Bot added ggml changes relating to the ggml tensor library for machine learning Apple Metal https://en.wikipedia.org/wiki/Metal_(API) labels Sep 24, 2026
@ggerganov
ggerganov merged commit 84e76d8 into master Sep 24, 2026
15 checks passed
@ggerganov
ggerganov deleted the gg/metal-capture-fixes branch September 25, 2026 06:14
frostyautumnleaf pushed a commit to frostyautumnleaf/llama.cpp that referenced this pull request Oct 5, 2026
- return early when the graph has no nodes
- drop the redundant reset of capture_compute: the decrement at the top
  of the function already transitions the counter from 0 to -1, so a
  capture happens exactly once
- hint at METAL_CAPTURE_ENABLED=1 in the capture error message
- pass capture_compute == 0 (not the raw counter) as use_capture to
  ggml_metal_op_init, so GPU debug-group markers are only emitted on the
  captured compute

Assisted-by: pi:llama.cpp/Qwen3.8-27B
edwardyoon pushed a commit to edwardyoon/focus-llama that referenced this pull request Oct 7, 2026
- return early when the graph has no nodes
- drop the redundant reset of capture_compute: the decrement at the top
  of the function already transitions the counter from 0 to -1, so a
  capture happens exactly once
- hint at METAL_CAPTURE_ENABLED=1 in the capture error message
- pass capture_compute == 0 (not the raw counter) as use_capture to
  ggml_metal_op_init, so GPU debug-group markers are only emitted on the
  captured compute

Assisted-by: pi:llama.cpp/Qwen3.8-27B
(cherry picked from commit 84e76d8)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Apple Metal https://en.wikipedia.org/wiki/Metal_(API) ggml changes relating to the ggml tensor library for machine learning

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant