mirror of
https://github.com/ROCm/composable_kernel.git
synced 2026-05-12 09:16:52 +00:00
[CK] [CK_Tile] Add GroupConv to Kernel Dispatcher ## Motivation This PR adds CK Tile group convolution (forward, backward-data, backward-weight) support to the kernel dispatcher, matching and unifying with the existing dispatcher GEMM infrastructure in architecture and usability. The dispatcher provides a unified kernel dispatch system with both C++ and Python frontends, and until now only supported GEMM operations. This PR enables framework integrators to use the same declarative kernel workflow for convolutions as they do for GEMM: declare kernels, build a registry JIT, select kernels within the registry at runtime, and dispatch to GPU. Future PRs will include runtime kernel selection heuristics for autotuning of kernel parameters based on (problem, hardware arch). ## Technical Details Grouped convolution support has been added to the CK Tile Dispatcher with generated_conv_backend.hpp enabling dispatcher.run(in, wei, out, problem) for all 6 conv variants (fwd/bwdd/bwdw x 2D/3D), runtime heuristic kernel selection, and GroupedConvKernelKey with full ConvConfigBase fields. Python side adds parallel JIT via registry.build(max_workers) and heuristic registry.select(). Includes 7 C++ and 6 Python examples covering all directions with CPU reference validation, and shared infrastructure improvements (BaseRegistry CRTP, structured exceptions). As a sanity check, JIT compile times for a single kernel remains the same and for multiple kernels there is better parallelism: Kernels | 1 worker | 8 workers 1 | 7.7 s | 7.7 s 2 | 15.9 s | 8.2 s 4 | 33.4 s | 9.7 s 6 | 52.3 s | 10.2 s ## Test Plan 145 ephemeral unit tests have been added to test basic functionality. All 30 examples/integration tests run end-to-end on gfx950 (MI350): 7 C++ conv, 7 C++ GEMM, 6 Python conv, 10 Python GEMM. CPU reference validation for forward, backward-data, and backward-weight (2D) in both C++ and Python examples pass. ## Test Result 30 examples pass. Peak performance: 132 TFLOPS (Batch-32 forward 56x56), 53 TFLOPS (pointwise 1x1). CPU reference accuracy: max_abs_diff < 0.002 for all directions (fp16 vs fp32 reference). ## Submission Checklist - [x] Look over the contributing guidelines at https://github.com/ROCm/ROCm/blob/develop/CONTRIBUTING.md#pull-requests.
83 lines
2.5 KiB
Markdown
83 lines
2.5 KiB
Markdown
# CK Tile Dispatcher Python Utilities
|
|
|
|
This directory contains Python utilities used by the dispatcher examples.
|
|
|
|
## Contents
|
|
|
|
### Shared Utilities (used by both GEMM and Grouped Conv)
|
|
|
|
- `dispatcher_common.py` - Shared dispatcher infrastructure
|
|
- Path helpers (`get_dispatcher_root`, `get_build_dir`, etc.)
|
|
- `ValidationResultBase` - Structured validation feedback
|
|
- `validate_wave_config`, `validate_warp_tile_config`, `validate_trait_combo`
|
|
- `auto_correct_wave`, `auto_correct_trait` - Auto-correction helpers
|
|
- `Colors` - Cross-platform ANSI color support
|
|
- `print_phase`, `print_success`, `print_error`, `print_info` - Phased output
|
|
- `cleanup_generated_kernels` - Cleanup helper
|
|
|
|
### GEMM Utilities
|
|
|
|
- `ctypes_utils.py` - Core ctypes utilities for GEMM Python examples
|
|
- `KernelConfig` - Kernel configuration dataclass
|
|
- `setup_gemm_dispatcher()` - Setup dispatcher with auto-correction
|
|
- `cleanup_gemm()` - Cleanup dispatcher resources
|
|
- `GemmRunner` - GPU execution helper
|
|
- Auto-correction and validation utilities
|
|
|
|
### Grouped Convolution Utilities
|
|
|
|
- `grouped_conv_utils.py` - Utilities for grouped convolution
|
|
- `GroupedConvValidationResult` - Validation result (extends `ValidationResultBase`)
|
|
- `validate_grouped_conv_config` - Validate a grouped conv config
|
|
- `auto_correct_grouped_conv_config` - Auto-correct invalid configs
|
|
- `get_grouped_conv_default_config` - Get default config for a variant
|
|
- `GroupedConvDataType` - Data type enum (FP16, BF16, FP32, FP8, BF8, INT8)
|
|
- `format_grouped_conv_summary` - Human-readable config summary
|
|
|
|
## Usage
|
|
|
|
### GEMM Examples
|
|
|
|
The GEMM Python examples in `dispatcher/examples/gemm/python/` import:
|
|
|
|
```python
|
|
import sys
|
|
from pathlib import Path
|
|
sys.path.insert(0, str(Path(__file__).parent.parent.parent.parent / "python"))
|
|
|
|
from ctypes_utils import (
|
|
KernelConfig,
|
|
setup_gemm_dispatcher,
|
|
cleanup_gemm,
|
|
GemmRunner,
|
|
)
|
|
```
|
|
|
|
### Grouped Conv Usage
|
|
|
|
```python
|
|
import sys
|
|
from pathlib import Path
|
|
sys.path.insert(0, str(Path(__file__).parent.parent.parent.parent / "python"))
|
|
|
|
from grouped_conv_utils import (
|
|
validate_grouped_conv_config,
|
|
auto_correct_grouped_conv_config,
|
|
get_grouped_conv_default_config,
|
|
GroupedConvDataType,
|
|
)
|
|
|
|
# Get a default config
|
|
config = get_grouped_conv_default_config(variant="forward", arch="gfx942")
|
|
|
|
# Validate
|
|
result = validate_grouped_conv_config(config)
|
|
print(f"Valid: {result.is_valid}")
|
|
```
|
|
|
|
## Requirements
|
|
|
|
- Python 3.8+
|
|
- NumPy
|
|
- HIP runtime (for GPU execution)
|