Skip to content
Strengthening Open Source Infrastructure

Strengthening Open Source Infrastructure

Prevent performance regressions in Kornia

Created on 19th January 2026

•

Strengthening Open Source Infrastructure

Strengthening Open Source Infrastructure

Prevent performance regressions in Kornia

The problem Strengthening Open Source Infrastructure solves

Modern computer vision systems rely heavily on image augmentation pipelines for training robust models. While Kornia is designed as a high-performance, GPU-accelerated augmentation library, there is currently no standardized or automated way to measure, compare, or track its performance over time.

This creates several problems:

  • Performance regressions can be introduced unknowingly in new pull requests
  • Maintainers lack objective, reproducible benchmarks to guide optimization decisions
  • Users cannot make data-driven comparisons between Kornia, torchvision, and Albumentations
  • Contributors have no clear performance baseline to validate changes

This project solves these issues by introducing a reproducible, CI-driven benchmarking framework for Kornia’s augmentation pipeline.

What users can do with it

  • Automatically detect performance regressions before code is merged
  • Compare Kornia’s augmentation speed against torchvision and Albumentations
  • Measure CPU vs GPU throughput and single-image vs batched execution
  • Make performance a first-class, testable property of the library

By integrating benchmarking into the CI pipeline, this project helps Kornia maintain its core promise of speed, while making performance transparent, measurable, and reproducible for maintainers, contributors, and users.

Challenges I ran into

1. Fair Cross-Library Benchmarking

Different libraries follow different assumptions for:

  • Input formats (NumPy vs Tensor, channel order)
  • Memory layouts
  • CPU vs GPU execution paths

Solution:
A standardized input pipeline was designed to normalize:

  • Image sizes, batch sizes, and dtypes
  • Tensor layouts and device placement
  • Equivalent augmentation parameters

Where exact output equivalence was not possible, fairness constraints were documented explicitly to ensure meaningful comparisons.


2. Benchmark Noise and CI Stability

Performance benchmarks are inherently sensitive to:

  • System load
  • GPU warm-up behavior
  • Short-running timing instability

This makes CI-based benchmarking especially challenging.

Solution:

  • Used torch.utils.benchmark for statistically robust timing
  • Added warm-up iterations and minimum run durations
  • Focused on relative regression thresholds, not absolute timings
  • Ensured benchmarks were non-flaky and deterministic before CI integration

3. Balancing Coverage vs Execution Time

Benchmarking many operators, batch sizes, and devices can easily exceed CI time limits.

Solution:

  • Carefully selected a representative subset of augmentations
  • Designed benchmarks to be parameterized and extensible
  • Split “full benchmarks” (local / scheduled) from CI-safe regression checks

4. Avoiding Misuse of AI-Generated Code

While AI tools can accelerate development, they can also introduce:

  • Incorrect benchmarking logic
  • Unfair comparisons
  • Performance anti-patterns

Solution:
AI assistants were used only for scaffolding and refactoring, while:

  • Benchmark design
  • Performance analysis
  • Validation decisions
    were done manually with careful review and local testing.

Discussion

Builders also viewed

See more projects on Devfolio