Helper script to list and filter TritonBench kernels for batch evaluation in KernelBand experiments.
scripts/list_kernels.py
When running KernelBand optimization experiments, you often need to select specific kernels based on:
- Difficulty level (1-5)
- Specific index range
- Total count for testing
This tool helps you:
- View available kernels and their difficulty ratings
- Filter kernels by difficulty or index
- Generate YAML configuration for direct use
- Update config files with selected kernels
# Show kernel count by difficulty
python scripts/list_kernels.py --statsOutput:
======================================================================
Kernel Statistics
======================================================================
Total kernels: 163
Kernels by difficulty:
Difficulty 1: 45 kernels (easiest)
Difficulty 2: 58 kernels
Difficulty 3: 35 kernels
Difficulty 4: 15 kernels
Difficulty 5: 10 kernels (hardest)
======================================================================
# List all easy kernels (difficulty 1-2)
python scripts/list_kernels.py --difficulty 1 2
# List medium difficulty kernels
python scripts/list_kernels.py --difficulty 3
# List hard kernels
python scripts/list_kernels.py --difficulty 4 5# List first 10 kernels
python scripts/list_kernels.py --range 0 10
# List kernels 20-30
python scripts/list_kernels.py --range 20 30# First 5 easy kernels
python scripts/list_kernels.py --difficulty 1 2 --range 0 5# Output in YAML format for config
python scripts/list_kernels.py --yaml --difficulty 1 2Output:
target_kernels:
- "add_example.py"
- "vector_addition.py"
- "elementwise_mul.py"
# ...# Update target_kernels in existing config
python scripts/list_kernels.py --config configs/examples/my_config.yaml --difficulty 1 2
# Update with specific range
python scripts/list_kernels.py --config configs/examples/test_config.yaml --difficulty 1 --range 0 5This will automatically replace the target_kernels field in your config file.
# Update test config with 2 easy kernels
python scripts/list_kernels.py --config configs/examples/test_config.yaml --difficulty 1 --range 0 2# Create configs for different difficulty levels
python scripts/list_kernels.py --config configs/easy.yaml --difficulty 1 2
python scripts/list_kernels.py --config configs/moderate.yaml --difficulty 3
python scripts/list_kernels.py --config configs/hard.yaml --difficulty 4 5# Update config with all kernels
python scripts/list_kernels.py --config configs/full_benchmark.yaml --all| Option | Description |
|---|---|
--stats |
Show kernel statistics by difficulty |
--all |
List all kernels |
--difficulty N [N ...] |
Filter by difficulty levels (1-5) |
--range START END |
Filter by index range |
--yaml |
Output in YAML format |
--config PATH |
Update target_kernels in config file |
The tool reads kernel information from:
data/TritonBench/statistics.json
Each kernel entry contains:
file: Kernel filename (e.g., "add_example.py")difficulty: Difficulty rating (1-5)instruction: Natural language descriptionlabel: Reference implementation