Repository navigation
Conversation
The worker-start CUDA init and GPU benchmark checks imported torch themselves. On a cold worker that import is ~1.5s, about 90% of the check, and it ran before the first job-take even for handlers that never use torch or import it lazily (every Flash handler). - Use torch or CuPy only if the handler already imported it (sys.modules); never import either from the check - Skip both checks before calling nvidia-smi when neither is loaded; the gpu_test binary still verifies device init and allocation - Unchanged behavior when torch or CuPy is loaded Real GPU worker (RTX 4090, Flash handler): worker-start fitness pass went from 1339/2147ms to 31ms. Linear: SLS-815
There was a problem hiding this comment.
馃煝 Approval recommended
The focused changes match the intended startup optimization, include regression coverage, and have no identified blocking issues.
No open issues 馃帀
What changed in this PR
Reduces worker startup latency by running framework-based GPU fitness checks only when PyTorch or CuPy is already loaded.
Changes:
- Skips CUDA initialization and benchmark checks before GPU detection when neither framework is loaded.
- Adds regression tests for skip behavior and the loaded-CuPy benchmark path.
| File | Description |
|---|---|
tests/鈥媡est_serverless/鈥媡est_modules/鈥媡est_fitness/鈥媡est_system_checks.py |
Tests import-free skipping and CuPy benchmark execution. |
runpod/鈥媉health/鈥媠ystem.py |
Gates GPU checks on loaded frameworks and documents the behavior. |
Review effort: Balanced
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The worker-start
_cuda_init_checkand_benchmark_checkimported torch themselves. On a cold worker that import is ~1.5s, about 90% of the check, and it ran before the first job-take. That happens even for handlers that never use torch, or that import it lazily inside the handler function (every Flash handler does, because Flash ships only the function body).sys.modules); they never import eithernvidia-smi. Thegpu_testbinary, which runs at import time, still verifies device init (cudaSetDevice) and allocation (cudaMalloc) on every GPUWhy gate instead of drop: for handlers that import torch at module level, the check reuses the loaded framework at almost no cost and still catches torch-level problems (missing kernels for the GPU arch, cuBLAS failures). Dropping only
_cuda_init_checkwould not help, because_benchmark_checkwould then pay the same torch import.Impact
Breakdown on a real RTX 4090 serverless worker, torch 2.9.1+cu128:
import torchzeros(1024)on devicegpu_testbinaryWorker-start fitness pass on the same worker type, Flash handler:
_cuda_init_check1211 / 2021 ms)For a handler that uses torch, the import moves to its first job (1591 ms measured); for one that doesn't, it is gone. Either way the worker starts taking jobs 1.3-2.1s sooner.
Test plan
nvidia-smiwhen the handler loaded neither (fails on main)make quality-check: 1482 passed, 91.70% coverageLinear: SLS-815