Skip to content
High-Performance Augmentation Benchmarking

High-Performance Augmentation Benchmarking

Benchmarking & Optimizing Kornia Augmentations

Created on 17th January 2026

•

High-Performance Augmentation Benchmarking

High-Performance Augmentation Benchmarking

Benchmarking & Optimizing Kornia Augmentations

The problem High-Performance Augmentation Benchmarking solves

The problem High-Performance Augmentation Benchmarking solves

The Challenge: Silent Regressions & Generic Logic
Kornia currently lacks a robust, automated way to track performance, making speed fragile and prone to silent regressions. Additionally, "one-size-fits-all" operators often underperform because they don't fully exploit specific hardware architectures.

My Solution: Device-Aware Speed & Automated Safety
This project optimizes Kornia through a dual approach:

  • Device-Aware Optimization: I am refactoring kornia.augmentation to use dynamic dispatching utilizing einsum for CPU memory efficiency and switching to conv2d on GPU to maximize CUDA parallelism.

  • CI/CD Benchmarking: I will build a standardized suite that runs on every Pull Request. This acts as a safety net to automatically flag performance drops and scientifically prove Kornia’s throughput advantage against competitors like Albumentations.

Challenges I ran into

Challenges I ran into

1. The "Metric Mismatch" Trap
During my initial profiling, I found that standard benchmarks often skewed results by focusing solely on Single-Image CPU performance—a scenario where general-purpose tensors naturally have overhead compared to specialized CPU-only arrays.

  • Overcoming it: I realized I was optimizing for the wrong contest. I shifted my profiling strategy to focus on Batched GPU throughput, designing a "Matrix Benchmark" that highlights where differentiable vision actually excels, rather than chasing CPU-specific metrics.

2. The CPU vs. GPU Logic Divergence
I initially prioritized code cleanliness, attempting to use torch.einsum everywhere for its mathematical elegance. However, profiling revealed a hardware conflict: einsum struggled with memory bandwidth on CPU, while conv2d was superior on GPU.

  • Overcoming it: I had to sacrifice the "one-line" elegance for Device-Aware Branching. I designed a logic flow that detects the hardware at runtime and dispatches the optimal operator (einsum for CPU, conv2d for GPU), ensuring peak performance without compromising the user API.

Technologies used

Discussion

Builders also viewed

See more projects on Devfolio