Files
rustytorch/crates/tooling/rtx-bench/README.md
T
2026-03-04 00:08:42 +00:00

236 lines
7.8 KiB
Markdown

# RTX Benchmark Suite
A comprehensive benchmarking framework for the RustyTorch++ platform, providing performance analysis across all components of the ML/AI stack.
## Features
### Core Infrastructure Benchmarks
- **Tensor Operations**: Creation, arithmetic, linear algebra, reductions, shape manipulation
- **Memory Management**: Allocation patterns, pool performance, GPU memory, fragmentation analysis
- **Autograd System**: Forward/backward passes, computation graphs, gradient computation
- **Runtime Performance**: Device management, context switching, kernel compilation
- **GPU Kernels**: CUDA/ROCm kernel execution, compilation time, memory transfers
### Model Architecture Benchmarks
- **Transformer Models**: BERT, GPT, T5 with different sizes and configurations
- **Vision Models**: ResNet, ViT, EfficientNet with various input sizes
- **Multimodal Models**: CLIP, DALL-E, cross-modal attention mechanisms
- **Scaling Analysis**: Batch size optimization, sequence length impact, memory usage
### Distributed Training Benchmarks
- **Multi-GPU Scaling**: Efficiency analysis across GPU counts
- **Communication Patterns**: Gradient synchronization, bandwidth utilization
- **Load Balancing**: Work distribution effectiveness
- **Fault Tolerance**: Recovery time analysis
### Production Inference Benchmarks
- **Latency Analysis**: Single request latency (p50, p95, p99)
- **Throughput Testing**: Batch processing performance, concurrent requests
- **Memory Efficiency**: Peak allocation, garbage collection impact
- **Model Loading**: Initialization and warm-up performance
### Compression & Optimization Benchmarks
- **Quantization**: Accuracy vs speed tradeoffs across bit depths
- **Model Pruning**: Sparsity impact on performance and memory
- **Knowledge Distillation**: Student model convergence rates
- **Optimization Techniques**: Various acceleration methods
### Competitive Analysis Framework
- **Framework Comparisons**: PyTorch, TensorFlow, ONNX Runtime
- **MLPerf Benchmarks**: Industry-standard compliance testing
- **Hardware Optimization**: Platform-specific performance analysis
- **Statistical Validation**: Rigorous comparison methodology
## Architecture
### TDD Implementation
The benchmark suite follows strict Test-Driven Development:
- All benchmarks start with failing tests
- Statistical rigor with confidence intervals
- Regression detection and alerting
- Comprehensive validation of measurements
### Statistical Analysis
- Coefficient of variation tracking
- Outlier detection using IQR method
- Welch's t-test for significance testing
- Confidence interval calculation
- Performance regression detection
### Reporting System
- **HTML Reports**: Interactive visualizations and detailed analysis
- **JSON Export**: Machine-readable results for automation
- **CSV Data**: Raw measurements for external analysis
- **Regression Alerts**: Automated performance regression detection
## Usage
### Command Line Interface
```bash
# Run all benchmark suites
rtx-bench all --gpu --competitive
# Run specific benchmark categories
rtx-bench core --devices cpu,cuda:0 --iterations 100
rtx-bench models --models bert,gpt,resnet --batch-sizes 1,8,16,32
rtx-bench distributed --num-gpus 4 --backend nccl
rtx-bench inference --concurrency-levels 1,10,50,100 --batch-processing
rtx-bench competitive --frameworks pytorch,tensorflow --mlperf
# Generate reports from existing results
rtx-bench report --input results/ --regression --historical --formats html,json
```
### Programmatic API
```rust
use rtx_bench::{BenchmarkConfig, BenchmarkSuite};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
// Configure benchmarks
let config = BenchmarkConfig::default()
.with_warmup_iterations(10)
.with_measurement_iterations(100)
.with_gpu_enabled(true)
.with_confidence_level(0.95);
// Run comprehensive benchmark suite
let suite = BenchmarkSuite::new(config);
let results = suite.run_all_benchmarks().await?;
// Generate detailed report
let report_config = ReportConfig::default();
let generator = ReportGenerator::new(report_config.clone());
let report = generator.generate_report(&results, &report_config).await?;
println!("Benchmark completed: {}", report.summary.average_execution_time_ms);
Ok(())
}
```
## Benchmark Categories
### 1. Core Infrastructure Performance
- Tensor operations across different sizes and data types
- Memory allocation patterns and pool effectiveness
- GPU memory transfer optimization
- Autograd computation graph efficiency
- Kernel compilation and execution timing
### 2. Model Architecture Analysis
- Forward pass latency and throughput
- Training step performance including backward pass
- Memory usage profiling during training/inference
- Batch size scaling characteristics
- Sequence length impact analysis
### 3. Distributed Training Evaluation
- Multi-GPU communication efficiency
- Gradient synchronization overhead
- Load balancing across devices
- Fault recovery mechanisms
- Scaling efficiency with device count
### 4. Production Inference Metrics
- Single request latency distribution
- Concurrent request handling capability
- Batch processing throughput optimization
- Model loading and initialization time
- Memory efficiency under production load
### 5. Competitive Performance Analysis
- Head-to-head comparisons with leading frameworks
- MLPerf benchmark compliance validation
- Hardware-specific optimization effectiveness
- Industry standard performance verification
## Output and Reporting
### Statistical Validation
All benchmarks include:
- Minimum sample size validation (configurable)
- Outlier detection and filtering
- Coefficient of variation analysis
- Statistical significance testing
- Confidence interval calculation
### Performance Regression Detection
- Automated comparison against historical baselines
- Statistical significance testing for changes
- Severity classification (Low/Medium/High/Critical)
- Root cause analysis suggestions
- Alert generation for significant regressions
### Report Formats
- **Interactive HTML**: Rich visualizations, charts, and drill-down analysis
- **JSON**: Structured data for integration with CI/CD pipelines
- **CSV**: Raw data export for custom analysis tools
- **Regression Alerts**: Automated notifications for performance issues
## Configuration
### Benchmark Configuration
```rust
BenchmarkConfig {
warmup_iterations: 5,
measurement_iterations: 50,
max_duration: Duration::from_secs(300),
enable_gpu: true,
enable_distributed: false,
confidence_level: 0.95,
min_sample_size: 30,
collect_memory_stats: true,
target_devices: vec!["cpu", "cuda:0"],
}
```
### Report Configuration
```rust
ReportConfig {
include_statistics: true,
include_regression_analysis: true,
include_historical_comparison: true,
generate_html: true,
generate_json: true,
generate_csv: false,
regression_threshold: 5.0, // 5% performance change threshold
}
```
## Integration
### CI/CD Pipeline Integration
```yaml
- name: Performance Benchmarks
run: |
rtx-bench all --output-dir results/ --formats json
rtx-bench report --input results/ --regression --formats html
```
### Automated Regression Detection
The benchmark suite automatically detects:
- Performance regressions above configurable thresholds
- Memory usage increases
- Statistical significance of changes
- High variance indicating unstable performance
## System Requirements
- Rust 1.70.0 or later
- CUDA 12.0+ (for GPU benchmarks)
- 16GB+ RAM recommended for full benchmark suite
- Multi-GPU setup for distributed training benchmarks
## Contributing
The benchmark suite follows strict quality standards:
- All benchmarks must include statistical validation
- Minimum 95% test coverage for new components
- Performance regression tests for all changes
- Documentation with runnable examples
## License
Licensed under either Apache 2.0 or MIT at your option.