Add Modal GPU testing infrastructure #1032
Draft
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
This PR adds comprehensive GPU testing infrastructure using Modal, a serverless GPU compute platform. Tests are automatically triggered on PRs labeled with
gpu-testsormodal-tests, enabling cost-effective GPU testing without maintaining dedicated hardware.Key Features
GPU Test Suites (1,571 lines across 11 files):
test_training_gpu.py): GPU memory management, forward/backward passes, loss computation, gradient accumulation, end-to-end trainingtest_inference_gpu.py): Batch inference benchmarks, mixed precision inference, throughput measurement, large batch handlingtest_distributed.py): GPU availability, DataParallel wrapper, gradient synchronization, device consistency, multi-GPU training loopsInfrastructure:
tests/modal_runner.py): Serverless GPU functions with 4 test suites + orchestratortests/modal_config.py): Pytest fixtures, markers, and configuration constants.github/workflows/modal-gpu-tests.yml): Label-triggered CI/CD on 3 Python versions with T4 GPUsdocs/modal-testing.md): 434-line guide covering setup, usage, cost breakdown, and troubleshootingCost Optimization:
Test Coverage
Setup Requirements
MODAL_TOKEN_IDandMODAL_TOKEN_SECRET(obtainable from Modal dashboard)pip install modal>=0.63.0+modal token newgpu-testsormodal-teststo trigger automated testingFiles Added/Modified
.github/workflows/modal-gpu-tests.yml(164 lines) - CI/CD workflowtests/modal_runner.py(327 lines) - Modal serverless functionstests/modal_config.py(106 lines) - Test configuration & fixturestests/test_gpu/test_training_gpu.py(174 lines) - Training teststests/test_gpu/test_inference_gpu.py(158 lines) - Inference teststests/test_gpu/test_distributed.py(197 lines) - Distributed testsdocs/modal-testing.md(434 lines) - Complete documentationmodal.toml(2 lines) - Modal configurationrequirements-modal.txt(7 lines) - Modal dependenciespyproject.toml(+1 line) - Added modal>=0.63.0How to Test
Run locally (requires Modal setup):
Trigger in CI/CD:
gpu-testslabel to PRManual workflow dispatch (coming in next update):
Documentation
See
docs/modal-testing.mdfor:Dependencies:
modal>=0.63.0(optional, only needed for CI/CD and local Modal testing)