Skip to content

macOS/Apple Silicon support via the ggml Metal backend - #44

Open
fernandotonon wants to merge 1 commit into
pwilkin:mainfrom
fernandotonon:macos-metal
Open

macOS/Apple Silicon support via the ggml Metal backend#44
fernandotonon wants to merge 1 commit into
pwilkin:mainfrom
fernandotonon:macos-metal

Conversation

@fernandotonon

Copy link
Copy Markdown

This adds working macOS/Apple Silicon support — verified end-to-end on an Apple M5 (macOS 26, 24 GB unified memory).

What it does

  • CMakeLists: recognize the ggml-metal target (GGML_METAL defaults ON for Apple builds of the vendored ggml), link it into trellis_core, and label the build backend metal. Nothing else was needed on the dispatch side — make_backend()'s generic device enumeration already discovers and picks the Metal GPU.
  • ss_decoder: use ggml_conv_3d_direct on __APPLE__. ggml_conv_3d lowers to IM2COL_3D + GEMM, and ggml-metal implements the direct CONV_3D op but not IM2COL_3D; since graphs run on a single backend, the sparse-structure decode aborted on Apple GPUs with unsupported op 'IM2COL_3D'. Same math and layouts; CUDA/Vulkan/HIP keep the validated im2col path (zero change off-Apple).
  • The two custom kernels (BiRefNet deformable conv, QEM decimation) run their existing CPU fallbacks on this backend.
  • Smoke tool prints "GPU" instead of hardcoded "CUDA"; README gains the macOS build one-liner and measured numbers.

Measured (M5, res 512, seed 42, F16 GGUFs from ilintar/trellis2-gguf)

  • image → textured GLB: 560.9 s end-to-end incl. model loads, peak RSS 5.6 GB
  • all neural stages report [trellis] using MTL0; 2.43M decoded voxels, 4.84M-face raw mesh; SS voxel count deterministic for the seed
  • Metal device init reports bfloat + f16 tensor API support on M5 (M2+ generally); on M1 (no bfloat) TRELLIS_FA_FAST=1 is the escape hatch for the default bf16 K/V FlashAttention cast

Happy to adjust anything — e.g. gating the conv3d change differently, or adding a CI lane for macOS.

🤖 Generated with Claude Code

* CMakeLists: recognize the ggml-metal target (GGML_METAL defaults ON on
  Apple) — link it into trellis_core and label the build backend "metal".
  make_backend()'s generic device enumeration already picks the Metal GPU;
  the two custom kernels (deform_conv, decimate_qem) use their existing
  CPU fallbacks.
* ss_decoder: use ggml_conv_3d_direct on __APPLE__. ggml_conv_3d lowers to
  IM2COL_3D + GEMM, and ggml-metal implements the direct CONV_3D op but not
  IM2COL_3D; since graphs run on a single backend (no sched fallback), the
  sparse-structure decode aborted on Apple GPUs ("unsupported op
  'IM2COL_3D'"). Same math and layouts; non-Apple backends keep the
  validated im2col path.
* smoke test: print "GPU" instead of the hardcoded "CUDA" for gpu >= 0.
* README: macOS build one-liner + measured M5 numbers.

Verified end-to-end on Apple M5 (macOS 26, 24 GB): res-512 image -> textured
GLB in 560.9 s, peak RSS 5.6 GB, all neural stages on MTL0 (2.43M decoded
voxels, 4.84M-face raw mesh).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

1 participant