Skip to content

Run GPU tests on Metal on Apple silicon and in a macos-15 job - #307

Merged
michakraus merged 2 commits into
mainfrom
ci/metal
Sep 24, 2026
Merged

michakraus merged 2 commits into
mainfrom
ci/metal

Conversation

@michakraus

Copy link
Copy Markdown
Member

Summary

The test suite now runs GPU tests on a real Apple GPU.

  • test/metal/ checks the two device paths that were measured by hand and not tested before: the products of a PoissonTensor with a wrapped device array, 𝕁 * view(A, [1, 2, 3, 4], :) and 𝕁 * B', which ext/GPUArraysCoreExt.jl carries; and the tensor_mat_mul! kernel on MetalBackend(). Each result must stay on the device and match the host in Float32, with scalar indexing off.
  • test/runtests.jl runs them last on every Apple-silicon Mac, so a failure on the device hides no host result. Where Metal.functional() is false (a Mac without a usable device, or a sandbox) they skip themselves.
  • Pkg.test(test_args = ["metal"]) runs them after the reachability and exports checks, and stops. Asked for that way, a missing device fails the run instead of skipping.
  • .github/workflows/Metal.yml runs them that way on macos-15, for Julia min and 1. GitHub's macOS runners have Apple's paravirtual GPU, which Metal.jl supports from 1.10 on macOS 15 or later (JuliaGPU/Metal.jl#789). The job is not a required check.
  • Metal (1.10) joins test/Project.toml on every platform. Its precompile workload is guarded by Sys.isapple() && Sys.ARCH === :aarch64, and nothing loads it off Apple silicon.
  • Comments and the GPU Support section of docs/src/index.md that said the suite or CI has no GPU test now name what test/metal/ covers.

Note for the required checks. CI's macOS-latest entry (macOS 26, arm64) is required and runs the full suite, so it now runs the Metal tests too.

The sibling change is JuliaGNI/GeometricOptimizers.jl#117. Its Metal job already passed on the macos-15 runner ("Apple Paravirtual device"): 817/817 in 2m46s, under --check-bounds=yes.

Verification

  • On an Apple M4 Max with Metal 1.11.1, test/metal/metal.jl passes 5/5.
  • With no Metal device, Pkg.test(test_args = ["metal"]) passes the reachability and exports checks, fails on @test Metal.functional(), and runs nothing else. Checked before and after the reorder.

Pre-PR verification

Fixed

  • test/runtests.jl: a full run on Apple silicon ran Metal before the subjects, against the ordering rule in the file's header; a Metal failure would have hidden every subject result. Metal now runs last in a full run; only the test_args = ["metal"] path runs it early, and then stops.
  • src/layers/positional_encoding.jl:75 ("the suite has no GPU test") and test/parameters/map_to_cpu_tests.jl:2 ("There is no GPU in CI") were made false by this change. Both now say that test/metal/ does not cover them.
  • test/runtests.jl: re-wrapped an overlong comment line.
  • test/metal/metal.jl: a comment that told the bug's history is now in the present tense.

Unresolved

  • None.

Pre-existing

  • ext/GPUArraysCoreExt.jl:10–12 tells history in the past tense (nit). Not in this PR.

Checked and clean

  • Aqua (project extras, deps compat, stale deps, piracy count 3) and ExplicitImports: 10/10 pass with Metal in the test environment. The in-process ambiguity count is 1 before and after using Metal, so the == 1 gate holds.
  • Test-environment resolve (Julia 1.13): Metal adds 23 packages. The only change to a shared package is GPUArraysCore 0.2.1 → 0.2.0, because GPUArrays pins GPUArraysCore = "= 0.2.0". The only difference is neutral_element, which this package does not use.
  • docs/src/index.md claims no more than test/metal/ asserts. macOS-latest is a required check, as the CHANGELOG states.
  • fatou lint is clean on the changed files apart from an intended duplicate-include advisory: metal/runtests.jl is included on two mutually exclusive paths. No method definition changed.

Not checked

  • Metal precompiling on Linux and Windows (the CHANGELOG claim): this PR's CI will show it.
  • The resolve on Julia 1.11: a local network error. The min jobs will show it.
  • Type stability: no package method changed.

🤖 Generated with Claude Code

michakraus and others added 2 commits September 24, 2026 10:40
test/metal/ checks the PoissonTensor products with a wrapped device array,
which ext/GPUArraysCoreExt.jl carries, and the tensor_mat_mul! kernel on
MetalBackend(). runtests.jl includes it on every Apple-silicon Mac; it
skips where Metal.functional() is false, and fails there when asked for
with test_args = ["metal"]. Metal.yml runs it that way on macos-15.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A failing top-level testset ends runtests.jl, so Metal now runs after
Aqua; test_args = ["metal"] still runs it alone and stops. Two comments
said the suite or CI has no GPU. Also from the branch verifier: a re-wrap
and a present-tense comment in test/metal/metal.jl.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings September 24, 2026 08:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@michakraus
michakraus merged commit 43b06ba into main Sep 24, 2026
12 of 13 checks passed
@michakraus
michakraus deleted the ci/metal branch September 24, 2026 10:07
@codecov

codecov Bot commented Sep 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.07%. Comparing base (cf1fbba) to head (7c59a5d).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #307   +/-   ##
=======================================
  Coverage   86.07%   86.07%           
=======================================
  Files          76       76           
  Lines        3016     3016           
=======================================
  Hits         2596     2596           
  Misses        420      420           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

2 participants