Skip to content

Commit 3c69761

Browse files
committed
fix(fitness): address PR feedback on fitness checks system
- Use configurable GPU_BENCHMARK_TIMEOUT instead of hardcoded 100ms threshold - Change test assertion from >= to == to prevent accidental check registration - Remove empty TestFallbackExecution class (covered by integration tests) - Make error message limit configurable via RUNPOD_GPU_MAX_ERROR_MESSAGES env var All 83 fitness check tests pass with these changes.
1 parent bd1d464 commit 3c69761

5 files changed

Lines changed: 16 additions & 21 deletions

File tree

runpod/serverless/modules/rp_gpu_fitness.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
# Configuration via environment variables
2525
TIMEOUT_SECONDS = int(os.environ.get("RUNPOD_GPU_TEST_TIMEOUT", "30"))
26+
MAX_ERROR_MESSAGES = int(os.environ.get("RUNPOD_GPU_MAX_ERROR_MESSAGES", "10"))
2627

2728

2829
def _get_gpu_test_binary_path() -> Optional[Path]:
@@ -151,7 +152,7 @@ async def _run_gpu_test_binary() -> Dict[str, Any]:
151152
if not result["success"]:
152153
error_msg = "GPU memory allocation test failed"
153154
if result["errors"]:
154-
error_msg += f": {'; '.join(result['errors'][:3])}" # Limit to 3 errors
155+
error_msg += f": {'; '.join(result['errors'][:MAX_ERROR_MESSAGES])}"
155156
raise RuntimeError(error_msg)
156157

157158
log.info(

runpod/serverless/modules/rp_system_fitness.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -379,15 +379,16 @@ async def _check_gpu_compute_benchmark() -> None:
379379
# Do computation
380380
A = torch.randn(size, size, device="cuda")
381381
B = torch.randn(size, size, device="cuda")
382-
C = torch.matmul(A, B)
382+
torch.matmul(A, B)
383383
torch.cuda.synchronize() # Wait for GPU to finish
384384

385385
elapsed_ms = (time.time() - start_time) * 1000
386+
max_ms = GPU_BENCHMARK_TIMEOUT * 1000
386387

387-
if elapsed_ms > 100:
388+
if elapsed_ms > max_ms:
388389
raise RuntimeError(
389390
f"GPU compute too slow: Matrix multiply took {elapsed_ms:.0f}ms "
390-
f"(max: 100ms)"
391+
f"(max: {max_ms:.0f}ms)"
391392
)
392393

393394
log.info(f"GPU compute benchmark passed: Matrix multiply completed in {elapsed_ms:.0f}ms")
@@ -407,15 +408,16 @@ async def _check_gpu_compute_benchmark() -> None:
407408

408409
A = cp.random.randn(size, size)
409410
B = cp.random.randn(size, size)
410-
C = cp.matmul(A, B)
411+
cp.matmul(A, B)
411412
cp.cuda.Device().synchronize()
412413

413414
elapsed_ms = (time.time() - start_time) * 1000
415+
max_ms = GPU_BENCHMARK_TIMEOUT * 1000
414416

415-
if elapsed_ms > 100:
417+
if elapsed_ms > max_ms:
416418
raise RuntimeError(
417419
f"GPU compute too slow: Matrix multiply took {elapsed_ms:.0f}ms "
418-
f"(max: 100ms)"
420+
f"(max: {max_ms:.0f}ms)"
419421
)
420422

421423
log.info(f"GPU compute benchmark passed: Matrix multiply completed in {elapsed_ms:.0f}ms")

tests/test_serverless/test_modules/test_gpu_fitness.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -268,18 +268,10 @@ async def test_binary_failure_output(self):
268268

269269

270270
# ============================================================================
271-
# Fallback Tests
271+
# Note: Fallback execution tests are covered by integration tests since
272+
# they involve subprocess calls that are difficult to mock cleanly.
272273
# ============================================================================
273274

274-
class TestFallbackExecution:
275-
"""Tests for Python fallback GPU check.
276-
277-
Fallback tests are primarily covered by integration tests since
278-
the fallback involves subprocess calls that are difficult to mock cleanly.
279-
"""
280-
pass
281-
282-
283275
# ============================================================================
284276
# Health Check Logic Tests
285277
# ============================================================================

tests/test_serverless/test_modules/test_gpu_fitness_integration.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def mock_gpu_test_binary():
4848
""")
4949
binary_path = f.name
5050

51-
os.chmod(binary_path, 0o755)
51+
os.chmod(binary_path, 0o700)
5252
yield Path(binary_path)
5353

5454
# Cleanup
@@ -70,7 +70,7 @@ def mock_gpu_test_binary_failure():
7070
""")
7171
binary_path = f.name
7272

73-
os.chmod(binary_path, 0o755)
73+
os.chmod(binary_path, 0o700)
7474
yield Path(binary_path)
7575

7676
# Cleanup
@@ -98,7 +98,7 @@ def mock_gpu_test_binary_multi_gpu():
9898
""")
9999
binary_path = f.name
100100

101-
os.chmod(binary_path, 0o755)
101+
os.chmod(binary_path, 0o700)
102102
yield Path(binary_path)
103103

104104
# Cleanup

tests/test_serverless/test_modules/test_system_fitness.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ def test_auto_register_all_checks_with_gpu(self, mock_gpu_available):
501501
mock_gpu_available.return_value = True
502502
auto_register_system_checks()
503503
# Should register: memory, disk, network, cuda_version, cuda_init, benchmark
504-
assert len(_fitness_checks) >= 6
504+
assert len(_fitness_checks) == 6
505505

506506
@patch("runpod.serverless.modules.rp_system_fitness.gpu_available")
507507
def test_auto_register_cpu_only(self, mock_gpu_available):

0 commit comments

Comments
 (0)