@@ -170,10 +170,38 @@ def test_get_launcher_prefix(self):
170170 launcher_mock = MagicMock ()
171171 launcher_mock .nsys_profile = True
172172 launcher_mock .get_nsys_prefix .return_value = ["nsys" , "profile" ]
173+ launcher_mock .nsys_gpu_metrics = False
173174
174175 with patch .object (executor , "get_launcher" , return_value = launcher_mock ):
175176 assert executor .get_launcher_prefix () == ["nsys" , "profile" ]
176177
178+ def test_get_launcher_prefix_with_gpu_metrics (self ):
179+ """Test the get_launcher_prefix method with nsys_profile when gpu metrics is enabled."""
180+ executor = SlurmExecutor (account = "test" )
181+
182+ # Test with launcher that has nsys_profile
183+ launcher_mock = MagicMock ()
184+ launcher_mock .nsys_profile = True
185+ launcher_mock .get_nsys_prefix .return_value = ["nsys" , "profile" ]
186+ launcher_mock .nsys_gpu_metrics = True
187+
188+ with patch .object (executor , "get_launcher" , return_value = launcher_mock ):
189+ assert executor .get_launcher_prefix () == ["nsys" , "profile" , "$GPU_METRICS_FLAG" ]
190+
191+ def test_get_nsys_entrypoint (self ):
192+ """Test the get_nsys_entrypoint method with nsys_profile."""
193+ executor = SlurmExecutor (account = "test" )
194+
195+ # Test with launcher that has nsys_profile
196+ launcher_mock = MagicMock ()
197+ launcher_mock .nsys_gpu_metrics = True
198+
199+ with patch .object (executor , "get_launcher" , return_value = launcher_mock ):
200+ assert executor .get_nsys_entrypoint () == (
201+ 'bash -c \' GPU_METRICS_FLAG=""; if [ "$SLURM_PROCID" -eq 0 ]; then GPU_METRICS_FLAG="--gpu-metrics-devices=all"; fi; nsys' ,
202+ "'" ,
203+ )
204+
177205 def test_supports_launcher_transform (self ):
178206 """Test the supports_launcher_transform method."""
179207 executor = SlurmExecutor (account = "test" )
0 commit comments