From 5af518335159513dc9a6f3f9173385608066b043 Mon Sep 17 00:00:00 2001 From: "Jae B." Date: Mon, 10 Aug 2026 21:44:16 -0400 Subject: [PATCH] test: isolate metal profiler tests from ambient SGLANG_USE_MLX (#34300) --- .../hardware_backend/mlx/test_metal_profiler.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/test/registered/unit/hardware_backend/mlx/test_metal_profiler.py b/test/registered/unit/hardware_backend/mlx/test_metal_profiler.py index c245a9267..fa50e3bc4 100644 --- a/test/registered/unit/hardware_backend/mlx/test_metal_profiler.py +++ b/test/registered/unit/hardware_backend/mlx/test_metal_profiler.py @@ -185,7 +185,21 @@ class TestMetalCaptureProfilerMPS(unittest.TestCase): @unittest.skipUnless(_IS_APPLE_SILICON and _HAS_MLX, _SKIP_REASON) class TestSchedulerProfilerManagerMPS(unittest.TestCase): - """SchedulerProfilerManager._start_profile handles Metal capture failures.""" + """SchedulerProfilerManager._start_profile handles Metal capture failures. + + apply_metal_profiler_patches() dispatches on use_mlx(), which reads + SGLANG_USE_MLX and is cached for the process (tensor_bridge.use_mlx). + This class exists to exercise the MPS strategy, so it pins use_mlx at + its point of use in profiler.py rather than the ambient environment; + an env-only pin would not reliably override an already-cached value. + """ + + def setUp(self): + patcher = patch( + "sglang.srt.hardware_backend.mlx.profiler.use_mlx", return_value=False + ) + patcher.start() + self.addCleanup(patcher.stop) def _make_manager(self, output_dir): from sglang.srt.managers.scheduler_components.profiler_manager import (