From 9d1fad3cde0acb95eb0bb0a1025f40a0eb614147 Mon Sep 17 00:00:00 2001 From: localai-org-maint-bot <306269227+localai-org-maint-bot@users.noreply.github.com> Date: Tue, 4 Aug 2026 10:08:14 +0000 Subject: [PATCH] fix(metal): scope MLX AppleClang warning suppression Keep MLX headers behind the imported SYSTEM dependency boundary and also suppress -Wgnu-folding-constant only while parsing the MLX public includes. Extend the regression guard to require both protections. FOLLOWING_AGENTS_PROTOCOL Assisted-by: Codex:gpt-5 [systematic-debugging] [test-driven-development] --- docs/BENCHMARKS.md | 11 +++--- docs/STATUS.md | 6 ++-- src/vt/metal/metal_mlx_provider.mm | 7 ++++ tests/scripts/test_mlx_system_headers.py | 46 ++++++++++++++++++++++-- 4 files changed, 61 insertions(+), 9 deletions(-) diff --git a/docs/BENCHMARKS.md b/docs/BENCHMARKS.md index 02c11b0ad..c3c398f61 100644 --- a/docs/BENCHMARKS.md +++ b/docs/BENCHMARKS.md @@ -6883,11 +6883,12 @@ us by about 1.5 points. The default (non-MLX) build is **95.9%** against this corrected baseline, not 96.4%. -The 2026-08-03 MLX system-header dependency correction is **NOT APPLICABLE** to -benchmark results: it replaces translation-unit warning suppression with an -imported CMake dependency whose public headers are `SYSTEM`. Darwin CI remains -the build-verification gate; no runtime path, measurement, or binding number -changed. +The 2026-08-04 MLX system-header warning correction is **NOT APPLICABLE** to +benchmark results: the imported CMake dependency keeps its public headers +`SYSTEM`, and the provider now also scopes AppleClang's +`-Wgnu-folding-constant` suppression to those MLX public includes. Darwin CI +remains the build-verification gate; no runtime path, measurement, or binding +number changed. **Everything qualitative in the entry below still holds** — MLX wins prefill, the shape gate is the right disposition, the fallback hoist was worth 27.2 vs 17.8 — diff --git a/docs/STATUS.md b/docs/STATUS.md index 6c727884d..94c71684d 100644 --- a/docs/STATUS.md +++ b/docs/STATUS.md @@ -1447,8 +1447,10 @@ per-lever chronology: [docs/BENCHMARKS.md](BENCHMARKS.md) and [.agents/specs/metal-dispatch-attribution.md](../.agents/specs/metal-dispatch-attribution.md). The MLX-enabled Darwin build remains **build-verification pending**: MLX is now an imported CMake dependency whose public include directory is explicitly -`SYSTEM`; third-party header diagnostics stay outside project `-Werror`, while -vllm.cpp warnings remain fatal. Darwin CI is the binding AppleClang gate. +`SYSTEM`, and the provider additionally scopes AppleClang's +`-Wgnu-folding-constant` suppression to the MLX public includes. Third-party +header diagnostics stay outside project `-Werror`, while vllm.cpp warnings +remain fatal. Darwin CI is the binding AppleClang gate. **CUDA architectures.** The production target is GB10/`sm_121a` (runtime-gated, both gate models token-exact + at/above vLLM speed). The arch-additivity diff --git a/src/vt/metal/metal_mlx_provider.mm b/src/vt/metal/metal_mlx_provider.mm index 524fbb7c4..75a8a1725 100644 --- a/src/vt/metal/metal_mlx_provider.mm +++ b/src/vt/metal/metal_mlx_provider.mm @@ -52,12 +52,19 @@ // MLX public headers. Deliberately NOT mlx/backend/metal/*: those pull in // metal-cpp and, as noted above, their entry points are not exported anyway. +#if defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu-folding-constant" +#endif #include "mlx/allocator.h" #include "mlx/array.h" #include "mlx/dtype.h" #include "mlx/ops.h" #include "mlx/stream.h" #include "mlx/transforms.h" +#if defined(__clang__) +#pragma clang diagnostic pop +#endif #include "metal_buffers.h" #include "metal_context.h" diff --git a/tests/scripts/test_mlx_system_headers.py b/tests/scripts/test_mlx_system_headers.py index 1185329c1..bfbefc102 100644 --- a/tests/scripts/test_mlx_system_headers.py +++ b/tests/scripts/test_mlx_system_headers.py @@ -15,8 +15,50 @@ class MlxSystemHeadersTest(unittest.TestCase): - def test_dependency_module_is_shipped(self) -> None: - self.assertTrue((ROOT / "cmake" / "MLXDependency.cmake").is_file()) + def test_dependency_target_marks_mlx_headers_as_system(self) -> None: + dependency = (ROOT / "cmake" / "MLXDependency.cmake").read_text( + encoding="utf-8" + ) + self.assertIn("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES", dependency) + + def test_mlx_includes_have_source_scoped_clang_warning_suppression(self) -> None: + provider = (ROOT / "src" / "vt" / "metal" / "metal_mlx_provider.mm").read_text( + encoding="utf-8" + ) + required_pragmas = ( + "#pragma clang diagnostic push", + '#pragma clang diagnostic ignored "-Wgnu-folding-constant"', + "#pragma clang diagnostic pop", + ) + for pragma in required_pragmas: + self.assertIn(pragma, provider) + self.assertEqual(provider.count("#if defined(__clang__)"), 2) + self.assertIn( + "#if defined(__clang__)\n" + "#pragma clang diagnostic push\n" + '#pragma clang diagnostic ignored "-Wgnu-folding-constant"\n' + "#endif\n", + provider, + ) + self.assertIn( + '#include "mlx/transforms.h"\n' + "#if defined(__clang__)\n" + "#pragma clang diagnostic pop\n" + "#endif\n", + provider, + ) + push = provider.index("#pragma clang diagnostic push") + ignored = provider.index( + '#pragma clang diagnostic ignored "-Wgnu-folding-constant"' + ) + first_mlx_include = provider.index('#include "mlx/allocator.h"') + last_mlx_include = provider.index('#include "mlx/transforms.h"') + pop = provider.index("#pragma clang diagnostic pop") + first_project_include = provider.index('#include "metal_buffers.h"') + self.assertLess(push, ignored) + self.assertLess(ignored, first_mlx_include) + self.assertLess(last_mlx_include, pop) + self.assertLess(pop, first_project_include) @unittest.skipUnless( shutil.which("cmake") and shutil.which("clang++") and shutil.which("ar"),