Skip to content

Fix MPS/Metal crash: embed Metal library at build time + add comfy-action CI#8

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/fix-execution-error-mps
Draft

Fix MPS/Metal crash: embed Metal library at build time + add comfy-action CI#8
Copilot wants to merge 4 commits intomainfrom
copilot/fix-execution-error-mps

Conversation

Copy link
Contributor

Copilot AI commented Mar 1, 2026

On macOS Apple Silicon, ace-qwen3 aborts immediately (exit -6 / SIGABRT) because ggml JIT-compiles embedded Metal shader source at runtime via newLibraryWithSource:, and certain macOS/Xcode SDK combinations reject that source with MTLLibraryErrorDomain template type-mismatch errors in kernel_col2im_1d / kernel_snake — before any model file is touched.

Fix

-DGGML_METAL_EMBED_LIBRARY=ON added to cmake Metal flags (both nodes.py and install.py):

# Before
"metal": [],  # Metal is auto-enabled on macOS by ggml

# After
"metal": ["-DGGML_METAL_EMBED_LIBRARY=ON"],  # pre-compile shaders at build time

ggml then compiles the Metal shaders at cmake build time (xcrun metal) and embeds the resulting binary .metallib directly in the executable — no runtime JIT, no runtime shader errors.

Additional changes

  • Better error surfacing — when ace-qwen3 fails on macOS and stderr contains MTLLibraryErrorDomain, generate() now appends a targeted message explaining the cause and directing the user to rebuild or switch to backend=cpu.
  • New CI workflow (.github/workflows/ci-mps.yml) using Comfy-Org/comfy-action@main on macos-latest (GitHub-hosted Apple Silicon runner):
    1. Installs ComfyUI via comfy-cli into the workspace root (required for comfy-action's python main.py)
    2. Copies this node into custom_nodes/ and builds binaries with the embed flag
    3. Metal smoke test — runs ace-qwen3 at startup against a nonexistent model; exit 134 (SIGABRT) means Metal JIT failed, catches the regression without any model downloads
    4. Downloads minimum GGUF set (0.6B LM + Q4_K_M DiT, cached between runs)
    5. Runs acestep-cpp-text2music.json end-to-end via Comfy-Org/comfy-action — a full workflow failure would have been the first visible symptom of the original bug

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits March 1, 2026 18:00
Co-authored-by: lmangani <1423657+lmangani@users.noreply.github.com>
Co-authored-by: lmangani <1423657+lmangani@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix execution failure on MPS with acestep.cpp Fix MPS execution failure: embed Metal library at build time + add comfy-action CI Mar 1, 2026
Copilot AI changed the title Fix MPS execution failure: embed Metal library at build time + add comfy-action CI Fix MPS/Metal crash: embed Metal library at build time + add comfy-action CI Mar 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants