Establish comprehensive development guidelines including project overview, memory bank documentation requirements, technical patterns, and current status for ComfyUI-MultiGPU contributors. Includes critical CPU memory leak investigation details and mandated development philosophy.
282 lines
13 KiB
Markdown
282 lines
13 KiB
Markdown
# Performance Benchmarks & Hardware Analysis
|
||
|
||
## Executive Summary
|
||
|
||
Comprehensive benchmarking across 5 model architectures and 6 hardware configurations reveals **bandwidth is king** for DisTorch2 performance. NVLink provides near-native performance while PCIe 4.0 CPU offloading offers excellent price/performance for most users.
|
||
|
||
## Benchmark Configuration
|
||
|
||
### Test Systems
|
||
- **PCIe 3.0 System**: i7-11700F @ 2.50GHz, DDR4-2667, older motherboard
|
||
- **PCIe 4.0 System**: Ryzen 5 7600X @ 4.70GHz, DDR5-4800, modern motherboard
|
||
|
||
### Hardware Configurations Tested
|
||
1. **RTX 3090 (no donor)**: Baseline - 799.3 GB/s internal VRAM
|
||
2. **x8 PCIe 3.0 CPU**: 6.8 GB/s measured bandwidth
|
||
3. **x16 PCIe 4.0 CPU**: 27.2 GB/s measured bandwidth
|
||
4. **RTX 3090 (NVLINK)**: 50.8 GB/s high-speed interconnect
|
||
5. **RTX 3090 (x8)**: 4.4 GB/s P2P over limited bus
|
||
6. **GTX 1660 Ti (x4)**: 2.1 GB/s P2P over slow bus
|
||
|
||
## Model Performance Analysis
|
||
|
||
### QWEN Image (FP8 - 19GB Model)
|
||
|
||
| GB Offloaded | RTX 3090 (no donor) | x8 PCIe 3.0 CPU | x16 PCIe 4.0 CPU | RTX 3090 (NVLINK) | RTX 3090 (x8) | GTX 1660 Ti (x4) |
|
||
|--------------|---------------------|-----------------|------------------|-------------------|---------------|------------------|
|
||
| 0 | 4.28s | 4.28s | 4.45s | 4.28s | 4.28s | 4.28s |
|
||
| 1.2 | 4.28s | 4.71s | 4.59s | 4.37s | 5.77s | 6.64s |
|
||
| 2.4 | 4.28s | 5.16s | 4.71s | 4.45s | 7.27s | 9.01s |
|
||
| 4.8 | 4.28s | 6.07s | 4.89s | 4.63s | 10.28s | 13.79s |
|
||
| 9.5 | 4.28s | 7.84s | 5.39s | 4.95s | 16.21s | #N/A |
|
||
| 19 | 4.28s | 11.43s | 6.30s | 5.64s | 28.33s | #N/A |
|
||
|
||
**Key Insights**:
|
||
- **NVLink Excellence**: Only 32% slowdown at maximum offloading (5.64s vs 4.28s)
|
||
- **PCIe 4.0 Sweet Spot**: 47% slowdown at maximum offloading (6.30s vs 4.28s)
|
||
- **x8 GPU Penalty**: 562% slowdown shows P2P limitations (28.33s vs 4.28s)
|
||
|
||
### FLUX GGUF (Q8_0 - 12GB Model)
|
||
|
||
| GB Offloaded | RTX 3090 (no donor) | x8 PCIe 3.0 CPU | x16 PCIe 4.0 CPU | RTX 3090 (NVLINK) | RTX 3090 (x8) | GTX 1660 Ti (x4) |
|
||
|--------------|---------------------|-----------------|------------------|-------------------|---------------|------------------|
|
||
| 0 | 1.29s | 1.29s | 1.32s | 1.29s | 1.29s | 1.29s |
|
||
| 1.5 | 1.29s | 1.6s | 1.4s | 1.32s | 1.76s | 2s |
|
||
| 3 | 1.29s | 1.9s | 1.49s | 1.35s | 2.24s | 2.74s |
|
||
| 5.9 | 1.29s | 2.5s | 1.65s | 1.41s | 3.15s | #N/A |
|
||
| 11.8 | 1.29s | 3.76s | 1.99s | 1.52s | 5.04s | #N/A |
|
||
|
||
**Key Insights**:
|
||
- **GGUF Efficiency**: Pre-quantized format reduces transfer overhead
|
||
- **Linear Scaling**: Performance scales predictably with offload amount
|
||
- **Bandwidth Correlation**: Results align with measured connection speeds
|
||
|
||
### WAN 2.2 (FP8 Video - 14GB Model)
|
||
|
||
| GB Offloaded | RTX 3090 (no donor) | x8 PCIe 3.0 CPU | x16 PCIe 4.0 CPU | RTX 3090 (NVLINK) | RTX 3090 (x8) | GTX 1660 Ti (x4) |
|
||
|--------------|---------------------|-----------------|------------------|-------------------|---------------|------------------|
|
||
| 0 | 111.3s | 111.3s | 111.3s | 111.3s | 111.3s | 111.3s |
|
||
| 1.7 | 111.3s | 111.3s | 111.5s | 111.1s | 112.2s | 114.0s |
|
||
| 3.4 | 111.3s | 111.9s | 111.7s | 111.0s | 114.4s | 117.2s |
|
||
| 6.7 | 111.3s | 112.9s | 111.9s | 111.5s | 118.2s | #N/A |
|
||
| 13.3 | 111.3s | 115.5s | 112.3s | 111.9s | 126.1s | #N/A |
|
||
|
||
**Key Insights**:
|
||
- **Video Generation Resilience**: Minimal performance impact across all configurations
|
||
- **Compute-Heavy Workload**: Long inference times mask transfer latency
|
||
- **Hardware Tolerance**: Even slow connections deliver acceptable performance
|
||
- **Maximum Impact**: Only 4% slowdown with CPU offloading (115.5s vs 111.3s)
|
||
|
||
### FLUX-KONTEXT-FP16 (22GB Model)
|
||
|
||
| GB Offloaded | RTX 3090 (no donor) | x8 PCIe 3.0 CPU | x16 PCIe 4.0 CPU | RTX 3090 (NVLINK) | RTX 3090 (x8) | GTX 1660 Ti (x4) |
|
||
|--------------|---------------------|-----------------|------------------|-------------------|---------------|------------------|
|
||
| 0 | 2.74s | 2.74s | 2.66s | 2.74s | 2.74s | 2.74s |
|
||
| 1.4 | 2.74s | 2.78s | 2.65s | 2.52s | 2.94s | 3.17s |
|
||
| 2.8 | 2.74s | 3.06s | 2.71s | 2.53s | 3.38s | 3.84s |
|
||
| 5.6 | 2.74s | 3.63s | 2.88s | 2.61s | 4.27s | #N/A |
|
||
| 11.1 | 2.74s | 4.76s | 3.17s | 2.71s | 6.00s | #N/A |
|
||
| 22.17 | 2.74s | 7.03s | 3.81s | 2.92s | 9.54s | #N/A |
|
||
|
||
**Key Insights**:
|
||
- **Large Model Challenge**: 22GB model tests all configurations
|
||
- **NVLink Dominance**: Only 7% slowdown at full offload (2.92s vs 2.74s)
|
||
- **CPU Viability**: 39% slowdown acceptable for capability gain (3.81s vs 2.74s)
|
||
|
||
### QWEN Image FP16 (38GB Model - Extreme Test)
|
||
|
||
| GB Offloaded | x8 PCIe 3.0 CPU | RTX 3090 (NVLINK) | RTX 3090 (x8) | RTX 3090 (no donor - fp8) |
|
||
|--------------|-----------------|-------------------|---------------|---------------------------|
|
||
| 0 | #N/A | #N/A | #N/A | 4.28s |
|
||
| 16 | 10.02s | 4.61s | 14.15s | 4.28s |
|
||
| 19 | 11.12s | 4.73s | 16.07s | 4.28s |
|
||
| 22 | 12.25s | 4.88s | 17.99s | 4.28s |
|
||
| 27 | 14.13s | #N/A | #N/A | 4.28s |
|
||
| 32 | 16s | #N/A | #N/A | 4.28s |
|
||
| 38 | 18.29s | #N/A | #N/A | 4.28s |
|
||
|
||
**Key Insights**:
|
||
- **Impossible Made Possible**: 38GB model runs on any hardware
|
||
- **NVLink Superiority**: Maintains reasonable performance even at extreme scales
|
||
- **Quality vs Convenience**: FP8 offers convenience, FP16 offers ultimate quality
|
||
|
||
## Hardware Configuration Analysis
|
||
|
||
### Performance Hierarchy (Best to Worst)
|
||
|
||
1. **NVLink 2x3090** (50.8 GB/s)
|
||
- **Use Case**: Professional/enthusiast dual-GPU setups
|
||
- **Performance**: Near-native across all workloads
|
||
- **Investment**: High (requires compatible cards + motherboard)
|
||
|
||
2. **PCIe 4.0 x16 CPU** (27.2 GB/s)
|
||
- **Use Case**: Modern single-GPU systems with fast RAM
|
||
- **Performance**: Excellent for most workloads
|
||
- **Investment**: Moderate (modern motherboard + DDR5)
|
||
|
||
3. **PCIe 3.0 x16 CPU** (15.8 GB/s theoretical)
|
||
- **Use Case**: Older systems with capability upgrade
|
||
- **Performance**: Acceptable for most workloads, some penalty
|
||
- **Investment**: Low (leverage existing hardware)
|
||
|
||
4. **PCIe 3.0 x8 CPU** (6.8 GB/s measured)
|
||
- **Use Case**: Budget systems, older motherboards
|
||
- **Performance**: Noticeable slowdown but functional
|
||
- **Investment**: Minimal (system RAM upgrade recommended)
|
||
|
||
5. **PCIe 3.0 x8 P2P GPU** (4.4 GB/s measured)
|
||
- **Use Case**: Dual-GPU consumer motherboards (x8/x8 split)
|
||
- **Performance**: Significant slowdown for image work
|
||
- **Investment**: Poor ROI unless already owned
|
||
|
||
6. **PCIe 3.0 x4 P2P GPU** (2.1 GB/s measured)
|
||
- **Use Case**: Older secondary GPUs in slow slots
|
||
- **Performance**: Severe slowdown, capacity-only benefit
|
||
- **Investment**: Only for extreme VRAM needs
|
||
|
||
## Strategic Recommendations
|
||
|
||
### For Image Generation (FLUX, QWEN)
|
||
**Priority: Bandwidth Optimization**
|
||
|
||
1. **Gold Standard**: NVLink 2x3090 setup
|
||
- Effectively creates 48GB VRAM pool with minimal penalty
|
||
- Suitable for professional/enthusiast workflows
|
||
- Consider refurbished 3090s for cost optimization
|
||
|
||
2. **Modern Path**: RTX 5090/5080 + PCIe 4.0 + DDR5
|
||
- Single GPU with fast CPU offloading
|
||
- Future-proofs with PCIe 5.0 capabilities
|
||
- Best price/performance for new builds
|
||
|
||
3. **Budget Path**: Existing GPU + system RAM upgrade
|
||
- Maximize system RAM (64GB+) for large model storage
|
||
- Accept performance penalty for capability gain
|
||
- Most accessible entry point
|
||
|
||
**Avoid**: x8/x8 PCIe splits for P2P unless NVLink available
|
||
|
||
### For Video Generation (WAN, HunyuanVideo)
|
||
**Priority: Capacity Maximization**
|
||
|
||
1. **Any Available Hardware**: Video generation is bandwidth-tolerant
|
||
- Old GPUs in x4 slots provide meaningful capacity
|
||
- CPU offloading performs nearly as well as GPU storage
|
||
- Focus on total available memory over speed
|
||
|
||
2. **Mixed Architecture Builds**: Combine new + old hardware
|
||
- Primary: RTX 4090/5090 for compute
|
||
- Secondary: Any available GPU for model storage
|
||
- System RAM: As much as financially feasible
|
||
|
||
3. **Evolution Strategy**: Incremental hardware additions
|
||
- Start with single GPU + CPU offloading
|
||
- Add secondary GPUs as budget allows
|
||
- Each additional device provides capacity benefit
|
||
|
||
### Universal Low-VRAM Strategy
|
||
|
||
**Multi-Tool Approach**: Use entire ComfyUI-MultiGPU ecosystem
|
||
|
||
1. **Ancillary Models**: CLIP/VAE to secondary devices
|
||
```
|
||
CLIPLoaderMultiGPU → cuda:1 or cpu
|
||
VAELoaderMultiGPU → cuda:1 or cpu
|
||
```
|
||
|
||
2. **Main Model**: DisTorch2 for UNet distribution
|
||
```
|
||
UNETLoaderDisTorch2MultiGPU → expert allocation
|
||
```
|
||
|
||
3. **Memory Management**: Progressive offloading strategy
|
||
- Start conservative (minimal offloading)
|
||
- Increase offloading until workflow stable
|
||
- Monitor performance vs capability tradeoff
|
||
|
||
## Performance Scaling Laws
|
||
|
||
### Bandwidth vs Performance Relationship
|
||
|
||
**Linear Correlation Observed**:
|
||
- **Transfer Time = (GB Offloaded × Steps) ÷ Bandwidth**
|
||
- **Total Slowdown = Baseline Time + Transfer Time**
|
||
|
||
**Example Calculation** (QWEN 19GB, 10 steps, 19GB offloaded):
|
||
- **NVLink** (50.8 GB/s): 19×10÷50.8 = 3.7s transfer time
|
||
- **PCIe 4.0** (27.2 GB/s): 19×10÷27.2 = 7.0s transfer time
|
||
- **PCIe 3.0 x8** (6.8 GB/s): 19×10÷6.8 = 27.9s transfer time
|
||
|
||
**Measured vs Calculated** shows strong correlation, validating model.
|
||
|
||
### Model Architecture Impact
|
||
|
||
**Transfer Overhead by Model Type**:
|
||
|
||
| Model Type | Overhead Factor | Reason |
|
||
|------------|----------------|---------|
|
||
| GGUF Models | 0.8x | Pre-quantized, optimized transfers |
|
||
| FP16 SafeTensors | 1.0x | Standard transfer overhead |
|
||
| Video Models | 0.3x | Long compute masks transfer time |
|
||
| Image Models | 1.2x | Short compute exposes transfer time |
|
||
|
||
### Hardware Utilization Patterns
|
||
|
||
**GPU Utilization During DisTorch Operation**:
|
||
- **Compute GPU**: 95-100% during inference steps
|
||
- **Donor GPU**: 0-15% (transfer operations only)
|
||
- **System RAM**: Varies with offload amount
|
||
- **PCIe Bus**: Burst usage during layer swaps
|
||
|
||
**Memory Pressure Thresholds**:
|
||
- **90% VRAM**: Automatic offloading triggered
|
||
- **95% System RAM**: Performance degradation likely
|
||
- **100% Available Memory**: OOM failure imminent
|
||
|
||
## Benchmarking Methodology
|
||
|
||
### Test Validation
|
||
- **Consistent Environment**: Same ComfyUI version, same models
|
||
- **Multiple Runs**: 3 runs averaged, outliers discarded
|
||
- **Hardware Monitoring**: GPU-Z, HWiNFO64 for validation
|
||
- **Transfer Measurement**: Custom timing instrumentation
|
||
|
||
### Limitations
|
||
- **Single-User Testing**: Results may vary with different hardware combinations
|
||
- **Model-Specific**: Some architectures may exhibit different patterns
|
||
- **Dynamic Factors**: System load, thermal throttling not controlled
|
||
- **Sample Size**: Limited to available hardware configurations
|
||
|
||
### Reproducibility
|
||
```python
|
||
# Benchmark configuration used
|
||
BENCHMARK_CONFIG = {
|
||
"comfyui_version": "0.3.50",
|
||
"torch_version": "2.8.0+cu128",
|
||
"model_precision": "fp16",
|
||
"steps": 10,
|
||
"guidance_scale": 7.5,
|
||
"resolution": "1024x1024"
|
||
}
|
||
```
|
||
|
||
## Future Benchmarking Plans
|
||
|
||
### Next-Generation Hardware Testing
|
||
- **RTX 5090**: PCIe 5.0 validation when available
|
||
- **PCIe 5.0 Motherboards**: Maximum bandwidth testing
|
||
- **DDR5-6000+**: RAM speed impact on CPU offloading
|
||
- **AMD RDNA4**: HIP/ROCm performance characterization
|
||
|
||
### Extended Model Coverage
|
||
- **Mixture of Experts**: Sparse model behavior analysis
|
||
- **Multimodal Models**: Text+Vision combined workloads
|
||
- **Real-Time Models**: Streaming inference requirements
|
||
- **Custom Architectures**: Community model support
|
||
|
||
### Advanced Metrics
|
||
- **Power Efficiency**: Performance per watt analysis
|
||
- **Thermal Behavior**: Sustained performance under load
|
||
- **Quality Metrics**: Objective image/video quality measurement
|
||
- **User Experience**: Subjective workflow satisfaction surveys
|