Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CUDA Auto Optimization Platform

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.

Features

  • Tune CUDA launch/configuration macros such as BLOCK_SIZE and UNROLL.
  • 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.md and reports/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-smi profiling 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.

Requirements

  • Windows, Linux, or WSL
  • CUDA Toolkit with nvcc on PATH
  • Python 3.10+

Quick Start

GPU-free development mode:

cd C:\projectCUDA
python -m cuda_auto_optimizer.cli tune --config .\configs\vector_add.mock.json

Or override any config:

python -m cuda_auto_optimizer.cli tune --config .\configs\vector_add.json --backend mock

CUDA hardware mode:

cd C:\projectCUDA
python -m cuda_auto_optimizer.cli tune --config .\configs\vector_add.json

If Python is installed as py:

py -3 -m cuda_auto_optimizer.cli tune --config .\configs\vector_add.json

Analyze Kernels

python -m cuda_auto_optimizer.cli analyze --source .\examples\vector_add\vector_add.cu

Analyze a whole project:

python -m cuda_auto_optimizer.cli analyze --source . --project --json

Stage Commands

Stage 1 tuner:

python -m cuda_auto_optimizer.cli tune --config .\configs\vector_add.json

Stage 2 static analyzer:

python -m cuda_auto_optimizer.cli analyze --source . --project --json

Stage 3 profiler wrapper:

python -m cuda_auto_optimizer.cli profile --executable .\build\vector_add\vector_add.exe

Stage 4 rule-based rewriter:

python -m cuda_auto_optimizer.cli rewrite --source .\examples\vector_add\vector_add.cu --output .\build\rewrites\vector_add.optimized.cu

Stage 5 validation:

python -m cuda_auto_optimizer.cli validate --baseline .\baseline.exe --candidate .\candidate.exe --tolerance 0.0001

Stage 6 budgeted search:

python -m cuda_auto_optimizer.cli search --config .\configs\vector_add.json --strategy random --budget 8

Stage 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 mock

GPU knowledge base:

python -m cuda_auto_optimizer.cli kb --gpu "RTX 4090"

Benchmark Contract

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.

Project Layout

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

Current Scope

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.

About

CUDA_migration_tool_project

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages