Staged MVP implementation for an automated CUDA optimization platform.
This project generates build variants, compiles them with nvcc, benchmarks each
variant, validates correctness from program output, and writes Markdown/JSON
reports.
- Tune CUDA launch/configuration macros such as
BLOCK_SIZEandUNROLL. - Try multiple compiler flag sets.
- Benchmark each compiled executable repeatedly.
- Parse validation and timing output from the benchmark binary.
- Select the fastest valid variant.
- Generate
reports/summary.mdandreports/results.json. - Static CUDA analysis for kernel patterns, shared memory, reductions, matrix multiplication hints, divergence risk, and occupancy risk.
- Nsight Compute, Nsight Systems, and
nvidia-smiprofiling wrapper. - Conservative rule-based source rewriting with unified diffs.
- Baseline/candidate validation by benchmark output.
- Budgeted grid/random search.
- GPU knowledge-base lookup.
- Agent-style optimization planning and staged project orchestration.
- Windows, Linux, or WSL
- CUDA Toolkit with
nvccon PATH - Python 3.10+
GPU-free development mode:
cd C:\projectCUDA
python -m cuda_auto_optimizer.cli tune --config .\configs\vector_add.mock.jsonOr override any config:
python -m cuda_auto_optimizer.cli tune --config .\configs\vector_add.json --backend mockCUDA hardware mode:
cd C:\projectCUDA
python -m cuda_auto_optimizer.cli tune --config .\configs\vector_add.jsonIf Python is installed as py:
py -3 -m cuda_auto_optimizer.cli tune --config .\configs\vector_add.jsonpython -m cuda_auto_optimizer.cli analyze --source .\examples\vector_add\vector_add.cuAnalyze a whole project:
python -m cuda_auto_optimizer.cli analyze --source . --project --jsonStage 1 tuner:
python -m cuda_auto_optimizer.cli tune --config .\configs\vector_add.jsonStage 2 static analyzer:
python -m cuda_auto_optimizer.cli analyze --source . --project --jsonStage 3 profiler wrapper:
python -m cuda_auto_optimizer.cli profile --executable .\build\vector_add\vector_add.exeStage 4 rule-based rewriter:
python -m cuda_auto_optimizer.cli rewrite --source .\examples\vector_add\vector_add.cu --output .\build\rewrites\vector_add.optimized.cuStage 5 validation:
python -m cuda_auto_optimizer.cli validate --baseline .\baseline.exe --candidate .\candidate.exe --tolerance 0.0001Stage 6 budgeted search:
python -m cuda_auto_optimizer.cli search --config .\configs\vector_add.json --strategy random --budget 8Stage 7 optimization plan:
python -m cuda_auto_optimizer.cli plan --project . --target-gpu "RTX 4090"Stage 8-10 staged orchestration:
python -m cuda_auto_optimizer.cli optimize --project . --config .\configs\vector_add.json --target-gpu "RTX 4090" --backend mockGPU knowledge base:
python -m cuda_auto_optimizer.cli kb --gpu "RTX 4090"The compiled CUDA benchmark should print one line containing:
validation=PASS elapsed_ms=0.123 checksum=123.456
Only variants with validation=PASS are eligible to become the winner.
cuda_auto_optimizer/ Python tuner implementation
configs/ Tuning configs
examples/ Example CUDA benchmark projects
scripts/ Convenience scripts
tests/ Standard-library unit tests
docs/ Roadmap notes from the product plan
All roadmap stages now have an executable MVP surface. The implementation is deliberately conservative: semantic rewrites, profiler interpretations, and agent decisions produce inspectable reports/diffs instead of silently changing algorithmic logic.
Use backend=mock while developing on a laptop without an NVIDIA GPU. Move the
same project to a CUDA machine and switch to backend=cuda for real compilation
and benchmarking.