π Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-ai
feat(benchmarks): add LAF-ops microbenchmark for kornia.feature (#4119)
Dmytro Mishkinf704eb3ecef5
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex fbde4545d..87c768e1d 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -10,6 +10,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0### Added+* `benchmarks/feature/laf_ops.py` microbenchmarks seven public LAF operations+ (`laf_from_center_scale_ori`, `make_upright`, `ellipse_to_laf`, `laf_to_boundary_points`,+ `laf_is_inside_image`, `extract_patches_simple`, `extract_patches_from_pyramid`) as kornia eager vs+ `torch.compile`, and its CPU and CUDA runs are the first committed non-Apple result set, so the docs+ performance page now shows CUDA numbers. The page labels its throughput column from a new optional+ `units` metadata key (`LAFs/s` here, `items/s` when absent) and identifies a row by every config field+ that varies within a result file rather than by `(op, batch)` alone, which a suite sweeping a second+ axis at a fixed batch would otherwise collapse onto one row. `run_batch_sweep` gained `label_fn`,+ `items_fn` and `units` so such a suite can use the shared sweep; the existing callers are unchanged.+ (#4119)+* Linux CPU half-precision CI now uses explicit reproducible profiles, exact phase/exception manifests, completelifecycle verification, and guarded candidate-only baseline regeneration. (#4154)* The documentation site was rebuilt on `pydata-sphinx-theme` with a top navigation bardiff --git a/benchmarks/README.md b/benchmarks/README.mdindex 5718238ca..38f8b80aa 100644--- a/benchmarks/README.md+++ b/benchmarks/README.md@@ -12,7 +12,7 @@ baselines. Goal: current, citable numbers with disclosed methodology β where k| [`geometry/`](geometry/) | [`flagship.py`](geometry/flagship.py): core geometry ops vs OpenCV/torchvision v2. || [`filters/`](filters/) | [`flagship.py`](filters/flagship.py): core filters vs OpenCV/albumentations/torchvision v2/kornia-rs/PIL. || [`color/`](color/) | pytest-benchmark microbenchmarks for color conversions. |-| [`feature/`](feature/) | Local-feature detector benchmarks incl. quality (matching) metrics; [`ellipse_to_laf.py`](feature/ellipse_to_laf.py) op microbenchmark (base-revision A/B, no cross-library baseline exists). |+| [`feature/`](feature/) | Local-feature detector benchmarks incl. quality (matching) metrics; [`laf_ops.py`](feature/laf_ops.py) microbenchmarks the shared LAF operations and [`ellipse_to_laf.py`](feature/ellipse_to_laf.py) drills into one of them (both base-revision A/B β no cross-library baseline exists). || [`common.py`](common.py) | Shared methodology utilities β use these in every new benchmark. |## Methodology contract@@ -94,7 +94,8 @@ One file per run:1. Check out the release tag you are measuring.2. Quiet the machine: close other applications, mains power, let it cool. Only aggregate loadnumbers (load average, memory) are recorded in the file - never process or app names.-3. Run each suite with `--contribute`:+3. Run each suite with `--contribute` (most suites are a `flagship.py`; the directory map above+ names the script for the ones that are not, such as `feature/laf_ops.py`):python benchmarks/augmentation/flagship.py --device cuda --contribute benchmarks/results@@ -177,6 +178,128 @@ NVIDIA RTX PRO 6000 Blackwell (AMD Turin host):compile-failure NOTE rather than silently skipped); eager still led OpenCV by ~23Γ onbatch-128 warp_perspective.+## Sample results β feature LAF ops++The full run is committed as+[`feature-laf-ops--i7-14700k-rtx-4090--cpu.json`](results/0.9.0rc1/feature-laf-ops--i7-14700k-rtx-4090--cpu.json)+and+[`feature-laf-ops--i7-14700k-rtx-4090--cuda.json`](results/0.9.0rc1/feature-laf-ops--i7-14700k-rtx-4090--cuda.json),+so the docs performance page renders it; the tables below are the B=1 N=20000 slice of those+files. Linux/WSL2 (kernel 6.18, x86_64), Intel i7-14700K + NVIDIA RTX 4090, Python 3.13,+torch 2.14.0+cu130, CUDA 13.0, kornia 0.9.0rc1, float32, image 256Γ256, patch size 32,+14 threads; LAF scales are stratified across all four pyramid levels that a 256Γ256 image at+PS=32 provides. Throughput in LAFs/s (higher is better); no cross-library column exists β no+other library exposes LAFs. Every op compiled on both devices on this stack, so there is no `-`+cell. Compare columns within one table, never numbers across machines.++`--device cpu --compile`, B=1 N=20000:++| op | kornia (eager) | kornia (compiled) |+| --- | --: | --: |+| laf_from_center_scale_ori | 39273029 | **99964263** |+| make_upright | 33959226 | **122176202** |+| ellipse_to_laf | 110509852 | **149762253** |+| laf_to_boundary_points | 3613236 | **9903714** |+| laf_is_inside_image | 6325084 | **11126178** |+| extract_patches_simple | **53309** | 27357 |+| extract_patches_from_pyramid | **37758** | 36983 |++`--device cuda --compile`, B=1 N=20000:++| op | kornia (eager) | kornia (compiled) |+| --- | --: | --: |+| laf_from_center_scale_ori | 147968107 | **254559803** |+| make_upright | 74905012 | **378282785** |+| ellipse_to_laf | 119929997 | **447807983** |+| laf_to_boundary_points | 14107628 | **17835708** |+| laf_is_inside_image | 28078872 | **56037949** |+| extract_patches_simple | 3499935 | **31880283** |+| extract_patches_from_pyramid | 2979848 | **25969422** |++Apple M1 (MacBook Air, 8 cores, 4 torch threads), macOS 26.5, Python 3.11, torch 2.9.1,+kornia 0.9.0rc1, same float32 / 256Γ256 / PS=32 / stratified-scale workload. Committed as+[`feature-laf-ops--apple-m1--cpu.json`](results/0.9.0rc1/feature-laf-ops--apple-m1--cpu.json)+and+[`feature-laf-ops--apple-m1--mps.json`](results/0.9.0rc1/feature-laf-ops--apple-m1--mps.json).+Every op compiled on both devices here too. This is a different CPU architecture, thread count+and torch version from the box above, so it answers "does the finding hold?", not "which box is+faster?".++`--device cpu --compile`, B=1 N=20000:++| op | kornia (eager) | kornia (compiled) |+| --- | --: | --: |+| laf_from_center_scale_ori | 25551758 | **84299262** |+| make_upright | 25171744 | **108229794** |+| ellipse_to_laf | 75817885 | **177777778** |+| laf_to_boundary_points | 838245 | **1078421** |+| laf_is_inside_image | 4880514 | **9227220** |+| extract_patches_simple | 40806 | **294408** |+| extract_patches_from_pyramid | 30084 | **200881** |++`--device mps --compile`, B=1 N=20000:++| op | kornia (eager) | kornia (compiled) |+| --- | --: | --: |+| laf_from_center_scale_ori | 13318018 | **22368750** |+| make_upright | 12793187 | **35554228** |+| ellipse_to_laf | 14233594 | **39990002** |+| laf_to_boundary_points | 1282786 | **1874608** |+| laf_is_inside_image | 2194321 | **4115015** |+| extract_patches_simple | 88430 | **476392** |+| extract_patches_from_pyramid | 73561 | **689227** |++Run-to-run spread on that laptop, from two independent full runs of each device: CPU cells move+by a median of 1.0% (worst 19%, on the cheapest op at the smallest config), MPS cells by a median+of 7.4% (worst 54%). Treat an MPS difference under ~2Γ on this class of machine as noise.++The honest reading:++- **Patch extraction still dominates, but only on CPU.** `extract_patches_from_pyramid` runs at+ ~38k LAFs/s eager on CPU β ~900Γ below `make_upright` on the same box, so a 20k-keypoint+ descriptor pass pays ~0.53 s in patch sampling before any descriptor math. On CUDA the same op+ is ~3.0M LAFs/s eager and ~26M compiled (0.77 ms for those 20k LAFs), only ~25Γ below the cheap+ ops. Batched GPU extraction is the regime to be in.+- **`torch.compile` loses on `extract_patches_simple` on *that* CPU, not on CPUs.** It is a+ consistent 1.9β2.1Γ loss in all three configs on the i7-14700K (torch 2.14, 14 threads) and a+ ~9.1Γ win for the same op on CUDA β but on the Apple M1 (torch 2.9.1, 4 threads) it is a+ **7.2Γ win** (40806 β 294408 LAFs/s), and 6.7Γ for the pyramid variant. So the regression is a+ property of that CPU inductor path, not of the op or of compiling for CPU, and a fix should+ start by bisecting stack against machine rather than reading the kernel. It is not the+ N-chunking added in #4128: at B=1 N=2000 the sampling grid is ~16 MiB against a 64 MiB budget,+ so that config takes the single-chunk fast path and still loses.+- **`laf_to_boundary_points` is the weakest compiled op on CUDA** β 17.8M LAFs/s, below both+ patch extractors, ~25Γ below `ellipse_to_laf`, and the least moved by `torch.compile` there+ (1.26Γ, against up to 9.1Γ elsewhere). It builds its `linspace`/`ones`/`tensor` basis without a+ `device=` argument and `.to()`s the result on every call (`kornia/feature/laf.py`), so each+ call pays a hostβdevice transfer. On CPU it is ~9Γ slower than the similar-sized+ `make_upright`. First optimization target in this file.+- **Small N on CUDA is launch-latency bound, not work bound:** at B=1 N=2000 the three cheapest+ ops all land within 8.2β14.2M LAFs/s regardless of what they compute, ~8.5β11Γ below their own+ B=1 N=20000 figures. Read the N=20000 rows for kernel cost and the N=2000 rows for per-call+ overhead.+- **Pyramid depth is currently free.** Stratifying the LAF scales across all four levels, instead+ of leaving every LAF on level 0, moved `extract_patches_from_pyramid` by ~3% β the packed-atlas+ implementation from #4128 pays for the whole atlas whatever the LAFs select. That is a property+ of today's code, not of the op: a change that skips unused levels would look free on an+ all-level-0 workload, which is why the generator stratifies.+- **`ellipse_to_laf` is now the fastest LAF op measured**, at 110.5M LAFs/s eager on CPU. This+ benchmark originally recorded it as a hot spot (a batched 2Γ2 `torch.inverse`, pathological on+ MPS); the closed-form inverse in #4122 fixed it, and the dedicated A/B lives in+ [`ellipse_to_laf.py`](feature/ellipse_to_laf.py).+- **On Apple silicon, MPS is the wrong device for the cheap LAF ops.** Every bookkeeping op is+ faster in M1 *CPU* eager than in MPS eager β `ellipse_to_laf` by 5.3Γ (75.8M vs 14.2M LAFs/s),+ `make_upright` and `laf_from_center_scale_ori` by ~2Γ β and the gap widens under+ `torch.compile` (4.4Γ and 3.8Γ). MPS only wins where there is real work per LAF: patch+ extraction, by 2.2β2.4Γ eager and up to 3.4Γ compiled. A pipeline that moves LAFs to the GPU+ for the frame math alone pays for the transfer twice.+- **`laf_to_boundary_points` is the worst op on every machine measured**, and its CPU numbers say+ why: on the M1 it is 30Γ below `make_upright` and `torch.compile` recovers only 1.29Γ, because+ the cost is not a kernel. It builds its 50-point basis with no `device=`, `.expand()`s it to+ `(B*N, n_pts, 3)` and only then calls `.to(device)`, so every call materializes β and on a GPU+ transfers β a tensor that scales with the LAF count: ~12 MiB per call at N=20000 for a basis+ with 50 distinct rows. Build it on the target device and broadcast in the matmul instead.+## Sample results β augmentation flagship (class API)Directional numbers only β reproduce on your own hardware for anything you cite. Measureddiff --git a/benchmarks/common.py b/benchmarks/common.pyindex d48e102c9..2d3703c10 100644--- a/benchmarks/common.py+++ b/benchmarks/common.py@@ -34,6 +34,7 @@ import platformimport reimport subprocessimport sys+from collections.abc import Sequencefrom datetime import UTC, datetimefrom pathlib import Pathfrom typing import Any, Callable, Optional@@ -60,11 +61,24 @@ def time_us(def git_commit() -> str:- """Short hash of HEAD, or 'unknown' outside a git checkout."""+ """Short hash of HEAD, ``-dirty`` when tracked files differ from it, or 'unknown' outside git.++ A run measured from a modified checkout is not reproducible from the hash alone. The LAF-ops+ result files were first committed with the hash of a commit that predated the harness edits+ they were measured with, so the recorded commit named a tree whose LAF generator differed+ from the one that actually ran. Untracked files are ignored: ``--contribute`` writes an+ untracked result file into the checkout, so counting those would mark every contributed run+ dirty and train readers to ignore the marker.+ """try:- return subprocess.check_output(["git", "rev-parse", "--short", "HEAD"], text=True).strip() # noqa: S607+ head = subprocess.check_output(["git", "rev-parse", "--short", "HEAD"], text=True).strip() # noqa: S607except Exception:return "unknown"+ try:+ modified = subprocess.check_output(["git", "status", "--porcelain", "-uno"], text=True).strip() # noqa: S607+ except Exception:+ return head+ return f"{head}-dirty" if modified else headdef _optional_version(module: str) -> Optional[str]:@@ -226,30 +240,46 @@ def contribute_result(version = str(metadata.get("kornia", "unknown"))out = Path(results_dir) / version / canonical_result_name(metadata, suite, slug_override)save_json(out, metadata, results)+ if str(metadata.get("git_commit", "")).endswith("-dirty"):+ print("# WARNING: measured from a modified checkout - the recorded commit does not describe this tree.")print(f"# contributed: {out}")print(f"# commit it with: git add {out}")return outdef run_batch_sweep(- batches: list[int],- build_ops: Callable[[int], tuple[dict[str, dict[str, Optional[Callable[[], object]]]], dict[str, str]]],+ batches: Sequence[Any],+ build_ops: Callable[[Any], tuple[dict[str, dict[str, Optional[Callable[[], object]]]], dict[str, str]]],backends: list[str],- row_fields: Callable[[int], dict[str, Any]],+ row_fields: Callable[[Any], dict[str, Any]],sync: Optional[Callable[[], None]] = None,torch_backends: tuple[str, ...] = ("kornia (", "torchvision"),+ label_fn: Optional[Callable[[Any], str]] = None,+ items_fn: Optional[Callable[[Any], float]] = None,+ units: str = "",label_width: int = 26,col_width: int = 14,min_run_time: float = 1.0,) -> list[dict[str, Any]]:- """Sweep batch sizes, print one throughput table per batch, and return JSON-ready rows.-- ``build_ops(batch)`` returns ``({op: {backend: zero-arg callable | None}}, {op: exc_name})``;- the second dict names ops whose ``torch.compile`` warmup failed, reported as a NOTE instead- of a silent skip cell. ``sync`` lands inside the timed region only for backends whose name- starts with one of ``torch_backends`` β uint8 CPU-loop baselines are timed without it (the- default prefix is ``"kornia ("`` so the CPU-only ``"kornia-rs"`` backend never matches).+ """Sweep configurations, print one throughput table per config, and return JSON-ready rows.++ ``build_ops(config)`` returns ``({op: {backend: zero-arg callable | None}}, {op: exc_name})``;+ the second dict names ops whose ``torch.compile`` warmup failed, reported as a NOTE and as a+ result row whose timings are ``null`` and whose ``error`` field names the exception, so a+ failure is visible in the exported JSON rather than only on the console. ``sync`` lands+ inside the timed region only for backends whose name starts with one of ``torch_backends``+ β uint8 CPU-loop baselines are timed without it (the default prefix is ``"kornia ("`` so+ the CPU-only ``"kornia-rs"`` backend never matches).++ A config is a batch size by default: it labels the row ``batch=<b>``, is written to the row's+ ``"batch"`` field, and is the per-call item count the throughput divides by. A suite whose+ config is not a single batch size (a ``(batch, n)`` pair, say) passes ``label_fn`` for the+ printed label, ``items_fn`` for the item count, and a ``"batch"`` key in ``row_fields`` β the+ committed-result schema requires that field to stay an ``int``. ``units`` names what the+ throughput counts in the printed header; the JSON never abbreviates it away."""+ label_of = label_fn if label_fn is not None else (lambda b: f"batch={b}")+ items_of = items_fn if items_fn is not None else (lambda b: b)results: list[dict[str, Any]] = []header = ""for b in batches:@@ -257,20 +287,37 @@ def run_batch_sweep(if compile_failures:exc_names = sorted(set(compile_failures.values()))print(f"# NOTE: torch.compile warmup failed ({', '.join(exc_names)}) for: {', '.join(compile_failures)}")- header = f"{'batch=' + str(b):<{label_width}}" + "".join(f"{n[:col_width]:>{col_width + 1}}" for n in backends)+ header = f"{label_of(b):<{label_width}}" + "".join(f"{n[:col_width]:>{col_width + 1}}" for n in backends)print("-" * len(header))- print(header)+ print(header + (f" ({units})" if units else ""))print("-" * len(header))+ items = items_of(b)for op_name, row in ops.items():cells = []for backend in backends:fn = row.get(backend)if fn is None:+ # Record the gap instead of dropping the row: a reader of the JSON otherwise+ # cannot tell "this backend was never requested" from "it failed", and the+ # exception type would survive only in the console NOTE above.+ reason = compile_failures.get(op_name) if "compiled" in backend else None+ results.append(+ {+ "op": op_name,+ "backend": backend,+ "batch": b,+ **row_fields(b),+ "median_us": None,+ "iqr_us": None,+ "throughput_per_s": None,+ "error": reason or "unavailable",+ }+ )cells.append(f"{'-':>{col_width + 1}}")continuebackend_sync = sync if backend.startswith(torch_backends) else Nonemedian, iqr = time_us(fn, min_run_time=min_run_time, sync=backend_sync)- thr = b / (median * 1e-6) if not math.isnan(median) else float("nan")+ thr = items / (median * 1e-6) if not math.isnan(median) else float("nan")results.append({"op": op_name,diff --git a/benchmarks/common_test.py b/benchmarks/common_test.pyindex dd8756f41..5b36b8f4c 100644--- a/benchmarks/common_test.py+++ b/benchmarks/common_test.py@@ -61,7 +61,31 @@ def test_run_metadata_records_environment():def test_git_commit_is_short_hash():- assert len(git_commit()) >= 7+ assert len(git_commit().removesuffix("-dirty")) >= 7+++def test_git_commit_marks_a_modified_checkout(monkeypatch):+ """A run from an edited tree is not reproducible from the hash, so the hash says so."""+ import common++ calls = []++ def fake(cmd, text=True):+ calls.append(cmd)+ return "abc1234\n" if "rev-parse" in cmd else " M kornia/feature/laf.py\n"++ monkeypatch.setattr(common.subprocess, "check_output", fake)+ assert common.git_commit() == "abc1234-dirty"+ assert "-uno" in calls[1] # untracked files (a contributed result file) must not count+++def test_git_commit_clean_checkout_is_bare_hash(monkeypatch):+ import common++ monkeypatch.setattr(+ common.subprocess, "check_output", lambda cmd, text=True: "abc1234\n" if "rev-parse" in cmd else "\n"+ )+ assert common.git_commit() == "abc1234"def test_save_json_round_trip_sanitizes_non_finite(tmp_path):@@ -89,14 +113,41 @@ def test_run_batch_sweep_rows_and_skip_cells(capsys):return {"opA": {"fast": lambda: None, "missing": None}}, {}rows = run_batch_sweep([1, 2], build, ["fast", "missing"], row_fields=lambda b: {"size": 8}, min_run_time=0.05)- assert [r["batch"] for r in rows] == [1, 2] # only 'fast' produces rows- assert rows[0]["op"] == "opA" and rows[0]["backend"] == "fast" and rows[0]["size"] == 8- assert rows[0]["median_us"] > 0 and rows[0]["throughput_per_s"] > 0+ measured = [r for r in rows if r.get("error") is None]+ assert [r["batch"] for r in measured] == [1, 2]+ assert measured[0]["op"] == "opA" and measured[0]["backend"] == "fast" and measured[0]["size"] == 8+ assert measured[0]["median_us"] > 0 and measured[0]["throughput_per_s"] > 0+ # the unavailable backend is recorded, not dropped, so the JSON shows the gap+ skipped = [r for r in rows if r["backend"] == "missing"]+ assert len(skipped) == 2+ assert all(r["median_us"] is None and r["throughput_per_s"] is None for r in skipped)+ assert all(r["error"] == "unavailable" for r in skipped)out = capsys.readouterr().outassert "batch=1" in out and "batch=2" in outassert "-" in out # the skip cell+def test_run_batch_sweep_accepts_non_batch_configs(capsys):+ def build(config):+ return {"opA": {"fast": lambda: None}}, {}++ rows = run_batch_sweep(+ [(2, 100)],+ build,+ ["fast"],+ row_fields=lambda c: {"batch": c[0], "n": c[1]},+ label_fn=lambda c: f"B={c[0]} N={c[1]}",+ items_fn=lambda c: c[0] * c[1],+ units="LAFs/s",+ min_run_time=0.05,+ )+ assert rows[0]["batch"] == 2 and rows[0]["n"] == 100 # row_fields overrides the config object+ per_call_s = rows[0]["median_us"] * 1e-6+ assert math.isclose(rows[0]["throughput_per_s"], 200 / per_call_s) # items_fn drives it, not the config+ out = capsys.readouterr().out+ assert "B=2 N=100" in out and "(LAFs/s)" in out++def test_versions_line_reports_stack_and_gaps():line = versions_line({"torch": "2.9.1", "kornia": "0.9.0", "torchvision": None})assert line.startswith("#")@@ -137,6 +188,18 @@ def test_run_batch_sweep_reports_warmup_failures(capsys): # 'compile' in a testassert "torch.compile warmup failed" in capsys.readouterr().out+def test_run_batch_sweep_records_warmup_failure_in_rows(): # 'compile' in a NAME gets deselected+ def build(b):+ return {"opA": {"kornia (eager)": lambda: None, "kornia (compiled)": None}}, {"opA": "InductorError"}++ rows = run_batch_sweep(+ [1], build, ["kornia (eager)", "kornia (compiled)"], row_fields=lambda b: {}, min_run_time=0.05+ )+ failed = next(r for r in rows if r["backend"] == "kornia (compiled)")+ assert failed["error"] == "InductorError" # the exception type reaches the JSON, not just stdout+ assert failed["median_us"] is None and failed["throughput_per_s"] is None++def test_collect_load_metrics_aggregate_only() -> None:from common import collect_load_metricsdiff --git a/benchmarks/feature/laf_ops.py b/benchmarks/feature/laf_ops.pynew file mode 100644index 000000000..4b35afe43--- /dev/null+++ b/benchmarks/feature/laf_ops.py@@ -0,0 +1,249 @@+# LICENSE HEADER MANAGED BY add-license-header+#+# Copyright 2018 Kornia Team+#+# Licensed under the Apache License, Version 2.0 (the "License");+# you may not use this file except in compliance with the License.+# You may obtain a copy of the License at+#+# http://www.apache.org/licenses/LICENSE-2.0+#+# Unless required by applicable law or agreed to in writing, software+# distributed under the License is distributed on an "AS IS" BASIS,+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+# See the License for the specific language governing permissions and+# limitations under the License.+#++"""Microbenchmarks for the LAF operations in ``kornia.feature``.++These ops are the shared substrate of every kornia local-feature pipeline: each detector call+converts, validates, and normalizes LAFs, and each descriptor call extracts patches from them.+There is no cross-library baseline -- no other library exposes LAFs -- so the columns are kornia+eager vs ``torch.compile``, and the baseline for a change is the same script run on another+kornia revision (see AGENTS.md, "Comparing a branch against another revision"). Running a file+under ``benchmarks/`` puts its own directory on ``sys.path[0]``, not the checkout root, so the+editable finder can resolve ``kornia`` to the primary checkout while ``git_commit()`` reports the+worktree HEAD -- an A/B that silently measures one revision twice. This script therefore puts its+own checkout root ahead of everything else on ``sys.path`` before importing kornia, prints the+resolved module path, records its checkout-relative form in the exported metadata as+``kornia_module``, and warns loudly if it still resolved outside this checkout. Read that line+before trusting a comparison.++Covered ops (all public ``kornia.feature`` API):++=============================== =============================================================+op why it is here+=============================== =============================================================+``laf_from_center_scale_ori`` LAF construction, runs once per detector forward+``make_upright`` orientation reset, per detector forward+``ellipse_to_laf`` Oxford-format import; :mod:`ellipse_to_laf` drills into it+``laf_to_boundary_points`` visualization export; builds its basis on CPU every call+``laf_is_inside_image`` border filtering, per detector forward+``extract_patches_simple`` patch sampling; Python loop over the batch dimension+``extract_patches_from_pyramid`` patch sampling; batch loop x full grid_sample per level+=============================== =============================================================++Throughput counts **LAFs per second** (``B*N`` per call) -- the README's "items" for LAF ops.+Patch extraction samples a ``(B, 1, size, size)`` float image; the pyramid variant's cost also+scales with ``min(size) // PS`` pyramid levels, so ``--size`` is part of the config, not noise.++Usage:+ python benchmarks/feature/laf_ops.py --device cpu+ python benchmarks/feature/laf_ops.py --device mps --compile+ python benchmarks/feature/laf_ops.py --device cuda --compile --json laf_ops_cuda.json+"""++from __future__ import annotations++import argparse+import sys+from pathlib import Path+from typing import Any, Callable, Optional++import torch++# Order matters: the checkout root ends up at sys.path[0], ahead of any editable install, so the+# kornia measured is the one this file lives in. `main` verifies that it actually won.+sys.path.insert(0, str(Path(__file__).resolve().parents[1]))+sys.path.insert(0, str(Path(__file__).resolve().parents[2]))+from common import (+ add_contribute_args,+ collect_load_metrics,+ contribute_result,+ print_preflight,+ run_batch_sweep,+ run_metadata,+ save_json,+ versions_line,+)++import kornia.feature as KF++Backend = Optional[Callable[[], object]]++REPO_ROOT = Path(__file__).resolve().parents[2]+PATCH_SIZE = 32+++def pyramid_levels(size: int, ps: int) -> int:+ """Levels ``extract_patches_from_pyramid`` builds for a square ``size`` image at patch ``ps``.++ Mirrors its halving loop: the pyramid stops at the last level that can still provide a full+ ``ps``-sized patch.+ """+ levels, side = 1, size+ while side // 2 >= ps and side > 2:+ side //= 2+ levels += 1+ return levels+++def make_lafs(b: int, n: int, size: int, device: torch.device, dtype: torch.dtype) -> torch.Tensor:+ """Random LAFs: centers inside the image, any orientation, scales stratified across levels.++ Scale matters here beyond realism. ``extract_patches_from_pyramid`` selects level+ ``floor(log2(2 * get_laf_scale(laf) / PS))``, and ``get_laf_scale`` of a frame built by+ ``laf_from_center_scale_ori(scale=s)`` is ``s``, so level ``l`` covers ``s`` in+ ``[PS/2 * 2**l, PS/2 * 2**(l + 1))``. A plain 4-24 px scale range therefore puts *every* LAF+ on level 0, and a future optimization that skips unused levels would look free on that+ workload. LAFs are assigned round-robin to the levels the extractor will actually build, so+ each level carries a share of the batch. Level 0 also absorbs the small-feature regime (from+ 4 px), which selects level 0 anyway; coarser levels sample uniformly inside their own octave.+ """+ xy = PATCH_SIZE + torch.rand(b, n, 2, device=device, dtype=dtype) * (size - 2 * PATCH_SIZE)+ level = torch.arange(n, device=device).remainder(pyramid_levels(size, PATCH_SIZE))+ lo = torch.where(level == 0, torch.full_like(level, 4), (PATCH_SIZE // 2) * 2**level).to(dtype)+ hi = (PATCH_SIZE * 2**level).to(dtype)+ frac = torch.rand(b, n, device=device, dtype=dtype)+ scale = (lo + (hi - lo) * frac).view(b, n, 1, 1)+ ori = 360.0 * torch.rand(b, n, 1, device=device, dtype=dtype) - 180.0+ return KF.laf_from_center_scale_ori(xy, scale, ori)+++def make_ellipses(b: int, n: int, size: int, device: torch.device, dtype: torch.dtype) -> torch.Tensor:+ """Random Oxford-format ellipses ``[x y a b c]`` with a positive-definite ``[a b; b c]``."""+ xy = PATCH_SIZE + torch.rand(b, n, 2, device=device, dtype=dtype) * (size - 2 * PATCH_SIZE)+ sx = 4.0 + 20.0 * torch.rand(b, n, device=device, dtype=dtype)+ sy = 4.0 + 20.0 * torch.rand(b, n, device=device, dtype=dtype)+ a = 1.0 / (sx * sx)+ c = 1.0 / (sy * sy)+ rho = torch.rand(b, n, device=device, dtype=dtype) - 0.5 # |b| < sqrt(a*c)/2 keeps it positive-definite+ bb = rho * (a * c).sqrt()+ return torch.cat([xy, torch.stack([a, bb, c], dim=-1)], dim=-1)+++def build_ops(+ config: tuple[int, int], size: int, device: torch.device, dtype: torch.dtype, do_compile: bool+) -> tuple[dict[str, dict[str, Backend]], dict[str, str]]:+ """Zero-arg callables per (op, backend) for one config, plus the compile-warmup failures."""+ b, n = config+ torch.manual_seed(0)+ lafs = make_lafs(b, n, size, device, dtype)+ ells = make_ellipses(b, n, size, device, dtype)+ img = torch.rand(b, 1, size, size, device=device, dtype=dtype)+ xy = PATCH_SIZE + torch.rand(b, n, 2, device=device, dtype=dtype) * (size - 2 * PATCH_SIZE)+ scale = 4.0 + 20.0 * torch.rand(b, n, 1, 1, device=device, dtype=dtype)+ ori = 360.0 * torch.rand(b, n, 1, device=device, dtype=dtype) - 180.0++ cases: list[tuple[str, Callable[..., object], tuple[object, ...]]] = [+ ("laf_from_center_scale_ori", KF.laf_from_center_scale_ori, (xy, scale, ori)),+ ("make_upright", KF.make_upright, (lafs,)),+ ("ellipse_to_laf", KF.ellipse_to_laf, (ells,)),+ ("laf_to_boundary_points", KF.laf_to_boundary_points, (lafs,)),+ ("laf_is_inside_image", KF.laf_is_inside_image, (lafs, img)),+ ("extract_patches_simple", KF.extract_patches_simple, (img, lafs, PATCH_SIZE)),+ ("extract_patches_from_pyramid", KF.extract_patches_from_pyramid, (img, lafs, PATCH_SIZE)),+ ]++ ops: dict[str, dict[str, Backend]] = {}+ compile_failures: dict[str, str] = {}+ if do_compile:+ # Reset dynamo once per config so every op compiles a fresh static-shape graph here;+ # without it the first config is timed on a static graph and later ones on the+ # automatic-dynamic recompile. Mirrors ellipse_to_laf.py. The reset belongs outside the+ # op loop: it invalidates every compiled callable, so resetting per op would push the+ # earlier ops' recompiles into the timed region instead of this warmup.+ torch._dynamo.reset()+ for name, fn, args in cases:+ row: dict[str, Backend] = {"kornia (eager)": (lambda fn=fn, args=args: fn(*args))}+ if do_compile:+ try:+ cfn = torch.compile(fn)+ cfn(*args) # warmup: compilation happens on the first call+ row["kornia (compiled)"] = lambda cfn=cfn, args=args: cfn(*args)+ except Exception as exc:+ compile_failures[name] = type(exc).__name__+ row["kornia (compiled)"] = None+ ops[name] = row+ return ops, compile_failures+++def main() -> None:+ parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)+ parser.add_argument("--device", default="cpu", help="cpu, cuda, or mps")+ parser.add_argument("--dtype", default="float32", choices=["float16", "bfloat16", "float32", "float64"])+ parser.add_argument("--configs", default="1x2000,1x20000,8x2000", help="comma-separated BxN pairs")+ parser.add_argument("--size", type=int, default=256, help="square image side for the patch-extraction ops")+ parser.add_argument("--compile", action="store_true", help="add a torch.compile column")+ parser.add_argument("--min-run-time", type=float, default=1.0, help="seconds of repeats per measurement")+ parser.add_argument("--json", type=str, default=None, help="write results to this path as JSON")+ add_contribute_args(parser)+ args = parser.parse_args()++ device = torch.device(args.device)+ dtype = getattr(torch, args.dtype)+ configs = [(int(b), int(n)) for b, n in (c.split("x") for c in args.configs.split(","))]+ sync = torch.mps.synchronize if device.type == "mps" else None # blocked_autorange syncs CUDA itself++ meta = run_metadata(device)+ meta["load"] = collect_load_metrics()+ kornia_file = sys.modules["kornia"].__file__+ resolved = Path(kornia_file).resolve() if kornia_file is not None else None+ inside = resolved is not None and REPO_ROOT in resolved.parents+ print_preflight(meta["load"])+ print(f"# laf_ops | commit {meta['git_commit']} | {meta['platform']} | {device} | {args.dtype}")+ print(f"# kornia module: {kornia_file}")+ if not inside:+ # git_commit() reports this checkout's HEAD, so a kornia from anywhere else means the+ # numbers and the commit label describe different code.+ print(f"# WARNING: kornia resolved outside {REPO_ROOT} - these numbers are NOT this checkout's.")+ print(versions_line(meta))++ backends = ["kornia (eager)"] + (["kornia (compiled)"] if args.compile else [])++ def row_fields(config: tuple[int, int]) -> dict[str, Any]:+ b, n = config+ return {"batch": b, "n_lafs": n, "size": args.size, "dtype": args.dtype}++ results = run_batch_sweep(+ configs,+ lambda config: build_ops(config, args.size, device, dtype, args.compile),+ backends,+ row_fields=row_fields,+ sync=sync,+ label_fn=lambda c: f"B={c[0]} N={c[1]}",+ items_fn=lambda c: c[0] * c[1],+ units="LAFs/s",+ label_width=30,+ col_width=16,+ min_run_time=args.min_run_time,+ )++ # The exported form is checkout-relative. The absolute path above answers "which tree?" on+ # the console, where it is needed; a contributed file is public, and README's privacy rule+ # keeps home directories and machine layout out of it. Relative or "outside-checkout" still+ # carries the only bit a reader of the file needs: did kornia resolve to the measured tree?+ module_field = resolved.relative_to(REPO_ROOT).as_posix() if inside else "outside-checkout"+ # The docs page and the llms digest label the throughput column from this key; without it a+ # committed run reads as "items/s", and the item here is a LAF, not an image.+ export_meta = {**meta, "kornia_module": module_field, "units": "LAFs/s"}+ if args.json:+ out = save_json(args.json, export_meta, results)+ print(f"# wrote {out}")+ if args.contribute:+ contribute_result(args.contribute, "feature-laf-ops", export_meta, results, args.machine_slug)+++if __name__ == "__main__":+ main()diff --git a/benchmarks/results/0.9.0rc1/feature-laf-ops--apple-m1--cpu.json b/benchmarks/results/0.9.0rc1/feature-laf-ops--apple-m1--cpu.jsonnew file mode 100644index 000000000..20a3d5c75--- /dev/null+++ b/benchmarks/results/0.9.0rc1/feature-laf-ops--apple-m1--cpu.json@@ -0,0 +1,493 @@+{+ "metadata": {+ "albumentations": null,+ "device": "cpu",+ "git_commit": "20519a32",+ "kornia": "0.9.0rc1",+ "kornia_module": "kornia/__init__.py",+ "kornia_rs": "0.1.10",+ "load": {+ "cpu_count": 8,+ "load_avg_15m": 2.02978515625,+ "load_avg_1m": 1.6611328125,+ "load_avg_5m": 1.88671875,+ "mem_available_bytes": 3279667200,+ "mem_total_bytes": 8589934592+ },+ "machine": "arm64",+ "numpy": "2.4.0",+ "opencv": "4.11.0",+ "pillow": "12.3.0",+ "platform": "macOS-26.5.1-arm64-arm-64bit",+ "python": "3.11.14",+ "timestamp_utc": "2026-09-03T19:04:13+00:00",+ "torch": "2.9.1",+ "torch_num_threads": 4,+ "torchvision": null,+ "units": "LAFs/s"+ },+ "results": [+ {+ "backend": "kornia (eager)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 0.35739599979934134,+ "median_us": 94.90083299988328,+ "n_lafs": 2000,+ "op": "laf_from_center_scale_ori",+ "size": 256,+ "throughput_per_s": 21074630.609432694+ },+ {+ "backend": "kornia (compiled)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 8.250249948105193,+ "median_us": 101.79200035054237,+ "n_lafs": 2000,+ "op": "laf_from_center_scale_ori",+ "size": 256,+ "throughput_per_s": 19647909.39477145+ },+ {+ "backend": "kornia (eager)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 0.6320900047285,+ "median_us": 124.19583000337299,+ "n_lafs": 2000,+ "op": "make_upright",+ "size": 256,+ "throughput_per_s": 16103600.257316874+ },+ {+ "backend": "kornia (compiled)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 6.91599962010514,+ "median_us": 106.6249997165869,+ "n_lafs": 2000,+ "op": "make_upright",+ "size": 256,+ "throughput_per_s": 18757327.130748626+ },+ {+ "backend": "kornia (eager)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 0.5905827490551062,+ "median_us": 46.53935399983311,+ "n_lafs": 2000,+ "op": "ellipse_to_laf",+ "size": 256,+ "throughput_per_s": 42974382.49802891+ },+ {+ "backend": "kornia (compiled)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 3.3750002330634743,+ "median_us": 61.45800034573767,+ "n_lafs": 2000,+ "op": "ellipse_to_laf",+ "size": 256,+ "throughput_per_s": 32542549.200247563+ },+ {+ "backend": "kornia (eager)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 56.997899991984184,+ "median_us": 2113.6207999916223,+ "n_lafs": 2000,+ "op": "laf_to_boundary_points",+ "size": 256,+ "throughput_per_s": 946243.5267517843+ },+ {+ "backend": "kornia (compiled)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 70.62500026222551,+ "median_us": 1872.1670003287727,+ "n_lafs": 2000,+ "op": "laf_to_boundary_points",+ "size": 256,+ "throughput_per_s": 1068280.7675003237+ },+ {+ "backend": "kornia (eager)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 8.534792493719557,+ "median_us": 429.07145999834023,+ "n_lafs": 2000,+ "op": "laf_is_inside_image",+ "size": 256,+ "throughput_per_s": 4661228.225265173+ },+ {+ "backend": "kornia (compiled)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 14.260250054576318,+ "median_us": 338.77099986057146,+ "n_lafs": 2000,+ "op": "laf_is_inside_image",+ "size": 256,+ "throughput_per_s": 5903693.057620467+ },+ {+ "backend": "kornia (eager)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 811.45900003321,+ "median_us": 49243.458999626455,+ "n_lafs": 2000,+ "op": "extract_patches_simple",+ "size": 256,+ "throughput_per_s": 40614.53116068007+ },+ {+ "backend": "kornia (compiled)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 75.00099945900729,+ "median_us": 6624.04200011224,+ "n_lafs": 2000,+ "op": "extract_patches_simple",+ "size": 256,+ "throughput_per_s": 301930.45273053995+ },+ {+ "backend": "kornia (eager)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 1685.6040001584915,+ "median_us": 68075.33300070645,+ "n_lafs": 2000,+ "op": "extract_patches_from_pyramid",+ "size": 256,+ "throughput_per_s": 29379.217285345414+ },+ {+ "backend": "kornia (compiled)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 406.989248631362,+ "median_us": 11247.583000113082,+ "n_lafs": 2000,+ "op": "extract_patches_from_pyramid",+ "size": 256,+ "throughput_per_s": 177815.98055154536+ },+ {+ "backend": "kornia (eager)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 9.44379999054943,+ "median_us": 782.7249999536434,+ "n_lafs": 20000,+ "op": "laf_from_center_scale_ori",+ "size": 256,+ "throughput_per_s": 25551758.28187996+ },+ {+ "backend": "kornia (compiled)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 45.14600004767999,+ "median_us": 237.25000028207432,+ "n_lafs": 20000,+ "op": "laf_from_center_scale_ori",+ "size": 256,+ "throughput_per_s": 84299262.28122799+ },+ {+ "backend": "kornia (eager)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 123.78750002426384,+ "median_us": 794.5416999973531,+ "n_lafs": 20000,+ "op": "make_upright",+ "size": 256,+ "throughput_per_s": 25171743.660611678+ },+ {+ "backend": "kornia (compiled)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 46.79100038629258,+ "median_us": 184.79199934517965,+ "n_lafs": 20000,+ "op": "make_upright",+ "size": 256,+ "throughput_per_s": 108229793.88107207+ },+ {+ "backend": "kornia (eager)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 14.950620002309703,+ "median_us": 263.7899999990623,+ "n_lafs": 20000,+ "op": "ellipse_to_laf",+ "size": 256,+ "throughput_per_s": 75817885.43944463+ },+ {+ "backend": "kornia (compiled)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 3.6250003176974133,+ "median_us": 112.49999988649506,+ "n_lafs": 20000,+ "op": "ellipse_to_laf",+ "size": 256,+ "throughput_per_s": 177777777.9571436+ },+ {+ "backend": "kornia (eager)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 594.3440000919509,+ "median_us": 23859.374499807018,+ "n_lafs": 20000,+ "op": "laf_to_boundary_points",+ "size": 256,+ "throughput_per_s": 838244.9422620768+ },+ {+ "backend": "kornia (compiled)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 357.4682496036985,+ "median_us": 18545.624999660504,+ "n_lafs": 20000,+ "op": "laf_to_boundary_points",+ "size": 256,+ "throughput_per_s": 1078421.4606068074+ },+ {+ "backend": "kornia (eager)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 180.14589995800617,+ "median_us": 4097.929100043984,+ "n_lafs": 20000,+ "op": "laf_is_inside_image",+ "size": 256,+ "throughput_per_s": 4880513.916110782+ },+ {+ "backend": "kornia (compiled)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 269.6660003493889,+ "median_us": 2167.4999998140265,+ "n_lafs": 20000,+ "op": "laf_is_inside_image",+ "size": 256,+ "throughput_per_s": 9227220.300676364+ },+ {+ "backend": "kornia (eager)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 4689.79200013564,+ "median_us": 490127.2079996488,+ "n_lafs": 20000,+ "op": "extract_patches_simple",+ "size": 256,+ "throughput_per_s": 40805.733029239076+ },+ {+ "backend": "kornia (compiled)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 1141.6664997341286,+ "median_us": 67932.95799980115,+ "n_lafs": 20000,+ "op": "extract_patches_simple",+ "size": 256,+ "throughput_per_s": 294407.90727909334+ },+ {+ "backend": "kornia (eager)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 1350.2914998753113,+ "median_us": 664804.958500099,+ "n_lafs": 20000,+ "op": "extract_patches_from_pyramid",+ "size": 256,+ "throughput_per_s": 30084.011474768537+ },+ {+ "backend": "kornia (compiled)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 1502.6039995973406,+ "median_us": 99561.25000007887,+ "n_lafs": 20000,+ "op": "extract_patches_from_pyramid",+ "size": 256,+ "throughput_per_s": 200881.3669975433+ },+ {+ "backend": "kornia (eager)",+ "batch": 8,+ "dtype": "float32",+ "iqr_us": 35.866599955625176,+ "median_us": 624.6416000067256,+ "n_lafs": 2000,+ "op": "laf_from_center_scale_ori",+ "size": 256,+ "throughput_per_s": 25614688.486690167+ },+ {+ "backend": "kornia (compiled)",+ "batch": 8,+ "dtype": "float32",+ "iqr_us": 25.020500288519543,+ "median_us": 204.79199974943185,+ "n_lafs": 2000,+ "op": "laf_from_center_scale_ori",+ "size": 256,+ "throughput_per_s": 78128051.97261807+ },+ {+ "backend": "kornia (eager)",+ "batch": 8,+ "dtype": "float32",+ "iqr_us": 58.83540002287195,+ "median_us": 617.2915999741235,+ "n_lafs": 2000,+ "op": "make_upright",+ "size": 256,+ "throughput_per_s": 25919678.804426808+ },+ {+ "backend": "kornia (compiled)",+ "batch": 8,+ "dtype": "float32",+ "iqr_us": 14.63624994357815,+ "median_us": 179.45900071936194,+ "n_lafs": 2000,+ "op": "make_upright",+ "size": 256,+ "throughput_per_s": 89156854.41167037+ },+ {+ "backend": "kornia (eager)",+ "batch": 8,+ "dtype": "float32",+ "iqr_us": 14.801875004195615,+ "median_us": 195.8341699992161,+ "n_lafs": 2000,+ "op": "ellipse_to_laf",+ "size": 256,+ "throughput_per_s": 81701778.60208996+ },+ {+ "backend": "kornia (compiled)",+ "batch": 8,+ "dtype": "float32",+ "iqr_us": 5.87499926041346,+ "median_us": 122.62500058568548,+ "n_lafs": 2000,+ "op": "ellipse_to_laf",+ "size": 256,+ "throughput_per_s": 130479102.33296868+ },+ {+ "backend": "kornia (eager)",+ "batch": 8,+ "dtype": "float32",+ "iqr_us": 477.29200014146045,+ "median_us": 18760.333000500395,+ "n_lafs": 2000,+ "op": "laf_to_boundary_points",+ "size": 256,+ "throughput_per_s": 852863.3260173596+ },+ {+ "backend": "kornia (compiled)",+ "batch": 8,+ "dtype": "float32",+ "iqr_us": 385.2289996757463,+ "median_us": 14957.166999920446,+ "n_lafs": 2000,+ "op": "laf_to_boundary_points",+ "size": 256,+ "throughput_per_s": 1069721.2914775305+ },+ {+ "backend": "kornia (eager)",+ "batch": 8,+ "dtype": "float32",+ "iqr_us": 264.1072999267635,+ "median_us": 3332.9728999888175,+ "n_lafs": 2000,+ "op": "laf_is_inside_image",+ "size": 256,+ "throughput_per_s": 4800519.0801442405+ },+ {+ "backend": "kornia (compiled)",+ "batch": 8,+ "dtype": "float32",+ "iqr_us": 245.88525002400274,+ "median_us": 1752.458500504872,+ "n_lafs": 2000,+ "op": "laf_is_inside_image",+ "size": 256,+ "throughput_per_s": 9130030.751307664+ },+ {+ "backend": "kornia (eager)",+ "batch": 8,+ "dtype": "float32",+ "iqr_us": 2077.458500480134,+ "median_us": 397048.9169996654,+ "n_lafs": 2000,+ "op": "extract_patches_simple",+ "size": 256,+ "throughput_per_s": 40297.30170505284+ },+ {+ "backend": "kornia (compiled)",+ "batch": 8,+ "dtype": "float32",+ "iqr_us": 20002.95849984468,+ "median_us": 160509.6670000421,+ "n_lafs": 2000,+ "op": "extract_patches_simple",+ "size": 256,+ "throughput_per_s": 99682.4695922882+ },+ {+ "backend": "kornia (eager)",+ "batch": 8,+ "dtype": "float32",+ "iqr_us": 4130.917000111367,+ "median_us": 551273.7919998472,+ "n_lafs": 2000,+ "op": "extract_patches_from_pyramid",+ "size": 256,+ "throughput_per_s": 29023.690645544848+ },+ {+ "backend": "kornia (compiled)",+ "batch": 8,+ "dtype": "float32",+ "iqr_us": 3377.2090000638855,+ "median_us": 205088.62499991665,+ "n_lafs": 2000,+ "op": "extract_patches_from_pyramid",+ "size": 256,+ "throughput_per_s": 78015.05324835301+ }+ ]+}diff --git a/benchmarks/results/0.9.0rc1/feature-laf-ops--apple-m1--mps.json b/benchmarks/results/0.9.0rc1/feature-laf-ops--apple-m1--mps.jsonnew file mode 100644index 000000000..a610a603e--- /dev/null+++ b/benchmarks/results/0.9.0rc1/feature-laf-ops--apple-m1--mps.json@@ -0,0 +1,493 @@+{+ "metadata": {+ "albumentations": null,+ "device": "mps",+ "git_commit": "20519a32",+ "kornia": "0.9.0rc1",+ "kornia_module": "kornia/__init__.py",+ "kornia_rs": "0.1.10",+ "load": {+ "cpu_count": 8,+ "load_avg_15m": 2.0888671875,+ "load_avg_1m": 2.65869140625,+ "load_avg_5m": 2.08203125,+ "mem_available_bytes": 3371581440,+ "mem_total_bytes": 8589934592+ },+ "machine": "arm64",+ "numpy": "2.4.0",+ "opencv": "4.11.0",+ "pillow": "12.3.0",+ "platform": "macOS-26.5.1-arm64-arm-64bit",+ "python": "3.11.14",+ "timestamp_utc": "2026-09-03T19:05:07+00:00",+ "torch": "2.9.1",+ "torch_num_threads": 4,+ "torchvision": null,+ "units": "LAFs/s"+ },+ "results": [+ {+ "backend": "kornia (eager)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 148.01665998675162,+ "median_us": 1165.856249999706,+ "n_lafs": 2000,+ "op": "laf_from_center_scale_ori",+ "size": 256,+ "throughput_per_s": 1715477.3583797351+ },+ {+ "backend": "kornia (compiled)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 151.37500031414675,+ "median_us": 776.7500001136796,+ "n_lafs": 2000,+ "op": "laf_from_center_scale_ori",+ "size": 256,+ "throughput_per_s": 2574831.0263370383+ },+ {+ "backend": "kornia (eager)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 299.0309999404417,+ "median_us": 1518.6875002655142,+ "n_lafs": 2000,+ "op": "make_upright",+ "size": 256,+ "throughput_per_s": 1316926.6222645128+ },+ {+ "backend": "kornia (compiled)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 95.58299916534452,+ "median_us": 460.20799982215976,+ "n_lafs": 2000,+ "op": "make_upright",+ "size": 256,+ "throughput_per_s": 4345861.003661104+ },+ {+ "backend": "kornia (eager)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 82.19374999498532,+ "median_us": 1175.735420001729,+ "n_lafs": 2000,+ "op": "ellipse_to_laf",+ "size": 256,+ "throughput_per_s": 1701062.9823477282+ },+ {+ "backend": "kornia (compiled)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 60.68750030863157,+ "median_us": 459.0829998960544,+ "n_lafs": 2000,+ "op": "ellipse_to_laf",+ "size": 256,+ "throughput_per_s": 4356510.697309288+ },+ {+ "backend": "kornia (eager)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 404.52049961459124,+ "median_us": 5040.5414999659115,+ "n_lafs": 2000,+ "op": "laf_to_boundary_points",+ "size": 256,+ "throughput_per_s": 396782.7662987252+ },+ {+ "backend": "kornia (compiled)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 787.8549995439244,+ "median_us": 4036.6465000261087,+ "n_lafs": 2000,+ "op": "laf_to_boundary_points",+ "size": 256,+ "throughput_per_s": 495460.77418150543+ },+ {+ "backend": "kornia (eager)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 386.7510004056385,+ "median_us": 2007.499999308493,+ "n_lafs": 2000,+ "op": "laf_is_inside_image",+ "size": 256,+ "throughput_per_s": 996264.0103058149+ },+ {+ "backend": "kornia (compiled)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 346.209249983076,+ "median_us": 1711.4994998337352,+ "n_lafs": 2000,+ "op": "laf_is_inside_image",+ "size": 256,+ "throughput_per_s": 1168565.9272435028+ },+ {+ "backend": "kornia (eager)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 1707.6670001188177,+ "median_us": 25825.499999882595,+ "n_lafs": 2000,+ "op": "extract_patches_simple",+ "size": 256,+ "throughput_per_s": 77442.83750591827+ },+ {+ "backend": "kornia (compiled)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 652.6570002733934,+ "median_us": 2368.020499488921,+ "n_lafs": 2000,+ "op": "extract_patches_simple",+ "size": 256,+ "throughput_per_s": 844587.2831048764+ },+ {+ "backend": "kornia (eager)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 1759.094249109694,+ "median_us": 34730.332999970415,+ "n_lafs": 2000,+ "op": "extract_patches_from_pyramid",+ "size": 256,+ "throughput_per_s": 57586.54833518883+ },+ {+ "backend": "kornia (compiled)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 3612.187000726408,+ "median_us": 3686.9165001007786,+ "n_lafs": 2000,+ "op": "extract_patches_from_pyramid",+ "size": 256,+ "throughput_per_s": 542458.7185376538+ },+ {+ "backend": "kornia (eager)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 299.3789549964275,+ "median_us": 1501.7249999982596,+ "n_lafs": 20000,+ "op": "laf_from_center_scale_ori",+ "size": 256,+ "throughput_per_s": 13318017.613093728+ },+ {+ "backend": "kornia (compiled)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 156.13574942108244,+ "median_us": 894.1044998209691,+ "n_lafs": 20000,+ "op": "laf_from_center_scale_ori",+ "size": 256,+ "throughput_per_s": 22368749.966032717+ },+ {+ "backend": "kornia (eager)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 118.9825000028578,+ "median_us": 1563.3320800043293,+ "n_lafs": 20000,+ "op": "make_upright",+ "size": 256,+ "throughput_per_s": 12793187.228617873+ },+ {+ "backend": "kornia (compiled)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 138.8229998156021,+ "median_us": 562.521000574634,+ "n_lafs": 20000,+ "op": "make_upright",+ "size": 256,+ "throughput_per_s": 35554228.16138301+ },+ {+ "backend": "kornia (eager)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 20.51708500175678,+ "median_us": 1405.1264549971163,+ "n_lafs": 20000,+ "op": "ellipse_to_laf",+ "size": 256,+ "throughput_per_s": 14233594.370722346+ },+ {+ "backend": "kornia (compiled)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 193.79200057301205,+ "median_us": 500.1250001441804,+ "n_lafs": 20000,+ "op": "ellipse_to_laf",+ "size": 256,+ "throughput_per_s": 39990002.48784649+ },+ {+ "backend": "kornia (eager)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 1066.843750550106,+ "median_us": 15591.062499879627,+ "n_lafs": 20000,+ "op": "laf_to_boundary_points",+ "size": 256,+ "throughput_per_s": 1282786.2116616115+ },+ {+ "backend": "kornia (compiled)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 1838.4797497219552,+ "median_us": 10668.895999970118,+ "n_lafs": 20000,+ "op": "laf_to_boundary_points",+ "size": 256,+ "throughput_per_s": 1874608.2068900114+ },+ {+ "backend": "kornia (eager)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 1470.811749868517,+ "median_us": 9114.43750055696,+ "n_lafs": 20000,+ "op": "laf_is_inside_image",+ "size": 256,+ "throughput_per_s": 2194320.8232847997+ },+ {+ "backend": "kornia (compiled)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 3023.3335000957595,+ "median_us": 4860.250000092492,+ "n_lafs": 20000,+ "op": "laf_is_inside_image",+ "size": 256,+ "throughput_per_s": 4115014.6596614155+ },+ {+ "backend": "kornia (eager)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 579.249999645981,+ "median_us": 226166.5420001009,+ "n_lafs": 20000,+ "op": "extract_patches_simple",+ "size": 256,+ "throughput_per_s": 88430.40983485116+ },+ {+ "backend": "kornia (compiled)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 1109.1245000898198,+ "median_us": 41982.20850003054,+ "n_lafs": 20000,+ "op": "extract_patches_simple",+ "size": 256,+ "throughput_per_s": 476392.27936246974+ },+ {+ "backend": "kornia (eager)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 1585.5832502893463,+ "median_us": 271881.45850050205,+ "n_lafs": 20000,+ "op": "extract_patches_from_pyramid",+ "size": 256,+ "throughput_per_s": 73561.47090833363+ },+ {+ "backend": "kornia (compiled)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 1207.7920000592712,+ "median_us": 29018.00000017829,+ "n_lafs": 20000,+ "op": "extract_patches_from_pyramid",+ "size": 256,+ "throughput_per_s": 689227.3761071444+ },+ {+ "backend": "kornia (eager)",+ "batch": 8,+ "dtype": "float32",+ "iqr_us": 265.8020500120983,+ "median_us": 1287.9187499947875,+ "n_lafs": 2000,+ "op": "laf_from_center_scale_ori",+ "size": 256,+ "throughput_per_s": 12423143.928966602+ },+ {+ "backend": "kornia (compiled)",+ "batch": 8,+ "dtype": "float32",+ "iqr_us": 134.15624971457873,+ "median_us": 918.2915005112591,+ "n_lafs": 2000,+ "op": "laf_from_center_scale_ori",+ "size": 256,+ "throughput_per_s": 17423661.21334238+ },+ {+ "backend": "kornia (eager)",+ "batch": 8,+ "dtype": "float32",+ "iqr_us": 472.7192504105915,+ "median_us": 1469.3330003865412,+ "n_lafs": 2000,+ "op": "make_upright",+ "size": 256,+ "throughput_per_s": 10889294.663490739+ },+ {+ "backend": "kornia (compiled)",+ "batch": 8,+ "dtype": "float32",+ "iqr_us": 124.66700036384282,+ "median_us": 499.75000001722947,+ "n_lafs": 2000,+ "op": "make_upright",+ "size": 256,+ "throughput_per_s": 32016008.002898213+ },+ {+ "backend": "kornia (eager)",+ "batch": 8,+ "dtype": "float32",+ "iqr_us": 320.540722500482,+ "median_us": 1284.6358300021166,+ "n_lafs": 2000,+ "op": "ellipse_to_laf",+ "size": 256,+ "throughput_per_s": 12454891.59365393+ },+ {+ "backend": "kornia (compiled)",+ "batch": 8,+ "dtype": "float32",+ "iqr_us": 123.24999943302828,+ "median_us": 503.2920007579378,+ "n_lafs": 2000,+ "op": "ellipse_to_laf",+ "size": 256,+ "throughput_per_s": 31790690.048529748+ },+ {+ "backend": "kornia (eager)",+ "batch": 8,+ "dtype": "float32",+ "iqr_us": 802.5420002013561,+ "median_us": 13163.00000053161,+ "n_lafs": 2000,+ "op": "laf_to_boundary_points",+ "size": 256,+ "throughput_per_s": 1215528.3749414124+ },+ {+ "backend": "kornia (compiled)",+ "batch": 8,+ "dtype": "float32",+ "iqr_us": 3281.624500232283,+ "median_us": 10186.250000515429,+ "n_lafs": 2000,+ "op": "laf_to_boundary_points",+ "size": 256,+ "throughput_per_s": 1570744.8765925039+ },+ {+ "backend": "kornia (eager)",+ "batch": 8,+ "dtype": "float32",+ "iqr_us": 926.510249655621,+ "median_us": 8516.395499555074,+ "n_lafs": 2000,+ "op": "laf_is_inside_image",+ "size": 256,+ "throughput_per_s": 1878729.0938796697+ },+ {+ "backend": "kornia (compiled)",+ "batch": 8,+ "dtype": "float32",+ "iqr_us": 2670.2697502969386,+ "median_us": 5147.708499862347,+ "n_lafs": 2000,+ "op": "laf_is_inside_image",+ "size": 256,+ "throughput_per_s": 3108179.1054073577+ },+ {+ "backend": "kornia (eager)",+ "batch": 8,+ "dtype": "float32",+ "iqr_us": 981.0315000322589,+ "median_us": 186438.77099975725,+ "n_lafs": 2000,+ "op": "extract_patches_simple",+ "size": 256,+ "throughput_per_s": 85819.05959904034+ },+ {+ "backend": "kornia (compiled)",+ "batch": 8,+ "dtype": "float32",+ "iqr_us": 976.457999968261,+ "median_us": 24546.749999899475,+ "n_lafs": 2000,+ "op": "extract_patches_simple",+ "size": 256,+ "throughput_per_s": 651817.4503779736+ },+ {+ "backend": "kornia (eager)",+ "batch": 8,+ "dtype": "float32",+ "iqr_us": 1661.3750012766104,+ "median_us": 230261.00000060978,+ "n_lafs": 2000,+ "op": "extract_patches_from_pyramid",+ "size": 256,+ "throughput_per_s": 69486.36547204098+ },+ {+ "backend": "kornia (compiled)",+ "batch": 8,+ "dtype": "float32",+ "iqr_us": 1640.4787497776852,+ "median_us": 21083.271500629053,+ "n_lafs": 2000,+ "op": "extract_patches_from_pyramid",+ "size": 256,+ "throughput_per_s": 758895.5063033085+ }+ ]+}diff --git a/benchmarks/results/0.9.0rc1/feature-laf-ops--i7-14700k-rtx-4090--cpu.json b/benchmarks/results/0.9.0rc1/feature-laf-ops--i7-14700k-rtx-4090--cpu.jsonnew file mode 100644index 000000000..70e2e7082--- /dev/null+++ b/benchmarks/results/0.9.0rc1/feature-laf-ops--i7-14700k-rtx-4090--cpu.json@@ -0,0 +1,493 @@+{+ "metadata": {+ "albumentations": "2.0.8",+ "device": "cpu",+ "git_commit": "9517c982",+ "kornia": "0.9.0rc1",+ "kornia_module": "kornia/__init__.py",+ "kornia_rs": "0.1.10",+ "load": {+ "cpu_count": 28,+ "load_avg_15m": 0.14697265625,+ "load_avg_1m": 0.44384765625,+ "load_avg_5m": 0.2265625,+ "mem_available_bytes": 30031736832,+ "mem_total_bytes": 33488023552+ },+ "machine": "x86_64",+ "numpy": "2.4.4",+ "opencv": "4.13.0",+ "pillow": "12.2.0",+ "platform": "Linux-6.18.33.2-microsoft-standard-WSL2-x86_64-with-glibc2.39",+ "python": "3.13.12",+ "timestamp_utc": "2026-09-03T18:26:21+00:00",+ "torch": "2.14.0+cu130",+ "torch_num_threads": 14,+ "torchvision": "0.29.0+cu130",+ "units": "LAFs/s"+ },+ "results": [+ {+ "backend": "kornia (eager)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 2.1095320003041778,+ "median_us": 65.76013699987016,+ "n_lafs": 2000,+ "op": "laf_from_center_scale_ori",+ "size": 256,+ "throughput_per_s": 30413561.942608926+ },+ {+ "backend": "kornia (compiled)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 1.7650004338065628,+ "median_us": 30.729999707546085,+ "n_lafs": 2000,+ "op": "laf_from_center_scale_ori",+ "size": 256,+ "throughput_per_s": 65082981.419907995+ },+ {+ "backend": "kornia (eager)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 2.778920499622468,+ "median_us": 99.84885399990162,+ "n_lafs": 2000,+ "op": "make_upright",+ "size": 256,+ "throughput_per_s": 20030274.959409855+ },+ {+ "backend": "kornia (compiled)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 1.8405003174848389,+ "median_us": 32.08799989806721,+ "n_lafs": 2000,+ "op": "make_upright",+ "size": 256,+ "throughput_per_s": 62328596.55800697+ },+ {+ "backend": "kornia (eager)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 1.0646905002431604,+ "median_us": 37.867752999773074,+ "n_lafs": 2000,+ "op": "ellipse_to_laf",+ "size": 256,+ "throughput_per_s": 52815386.22088259+ },+ {+ "backend": "kornia (compiled)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 1.6997496459225658,+ "median_us": 28.76999951695325,+ "n_lafs": 2000,+ "op": "ellipse_to_laf",+ "size": 256,+ "throughput_per_s": 69516859.00521004+ },+ {+ "backend": "kornia (eager)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 21.721069992963727,+ "median_us": 440.7207400072366,+ "n_lafs": 2000,+ "op": "laf_to_boundary_points",+ "size": 256,+ "throughput_per_s": 4538021.060608948+ },+ {+ "backend": "kornia (compiled)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 17.69699974829564,+ "median_us": 222.22500047064386,+ "n_lafs": 2000,+ "op": "laf_to_boundary_points",+ "size": 256,+ "throughput_per_s": 8999887.482345633+ },+ {+ "backend": "kornia (eager)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 15.117310003915915,+ "median_us": 349.8822600067797,+ "n_lafs": 2000,+ "op": "laf_is_inside_image",+ "size": 256,+ "throughput_per_s": 5716208.646763761+ },+ {+ "backend": "kornia (compiled)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 31.85399964422686,+ "median_us": 171.6009992378531,+ "n_lafs": 2000,+ "op": "laf_is_inside_image",+ "size": 256,+ "throughput_per_s": 11654943.787523262+ },+ {+ "backend": "kornia (eager)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 1036.5672499119682,+ "median_us": 25399.474000096234,+ "n_lafs": 2000,+ "op": "extract_patches_simple",+ "size": 256,+ "throughput_per_s": 78741.78811704613+ },+ {+ "backend": "kornia (compiled)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 2159.103500616766,+ "median_us": 53187.28799920791,+ "n_lafs": 2000,+ "op": "extract_patches_simple",+ "size": 256,+ "throughput_per_s": 37602.97009371459+ },+ {+ "backend": "kornia (eager)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 2376.1937500239583,+ "median_us": 39122.130000123434,+ "n_lafs": 2000,+ "op": "extract_patches_from_pyramid",+ "size": 256,+ "throughput_per_s": 51121.96089511716+ },+ {+ "backend": "kornia (compiled)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 798.769000084576,+ "median_us": 36634.17200004915,+ "n_lafs": 2000,+ "op": "extract_patches_from_pyramid",+ "size": 256,+ "throughput_per_s": 54593.836595987945+ },+ {+ "backend": "kornia (eager)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 8.295849995647613,+ "median_us": 509.2553499980567,+ "n_lafs": 20000,+ "op": "laf_from_center_scale_ori",+ "size": 256,+ "throughput_per_s": 39273028.746926896+ },+ {+ "backend": "kornia (compiled)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 18.603249827719992,+ "median_us": 200.07149987577577,+ "n_lafs": 20000,+ "op": "laf_from_center_scale_ori",+ "size": 256,+ "throughput_per_s": 99964262.83812529+ },+ {+ "backend": "kornia (eager)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 15.844990002733539,+ "median_us": 588.9415799993003,+ "n_lafs": 20000,+ "op": "make_upright",+ "size": 256,+ "throughput_per_s": 33959225.63325171+ },+ {+ "backend": "kornia (compiled)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 15.926000742183533,+ "median_us": 163.69800050597405,+ "n_lafs": 20000,+ "op": "make_upright",+ "size": 256,+ "throughput_per_s": 122176202.14163895+ },+ {+ "backend": "kornia (eager)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 8.085679992291277,+ "median_us": 180.9793400025228,+ "n_lafs": 20000,+ "op": "ellipse_to_laf",+ "size": 256,+ "throughput_per_s": 110509851.5649422+ },+ {+ "backend": "kornia (compiled)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 15.07500019215513,+ "median_us": 133.54499969864264,+ "n_lafs": 20000,+ "op": "ellipse_to_laf",+ "size": 256,+ "throughput_per_s": 149762252.76222965+ },+ {+ "backend": "kornia (eager)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 312.9550499579633,+ "median_us": 5535.203799990995,+ "n_lafs": 20000,+ "op": "laf_to_boundary_points",+ "size": 256,+ "throughput_per_s": 3613236.426820009+ },+ {+ "backend": "kornia (compiled)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 251.4115005851636,+ "median_us": 2019.4445000925043,+ "n_lafs": 20000,+ "op": "laf_to_boundary_points",+ "size": 256,+ "throughput_per_s": 9903713.619801814+ },+ {+ "backend": "kornia (eager)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 170.50312510491494,+ "median_us": 3162.013199971625,+ "n_lafs": 20000,+ "op": "laf_is_inside_image",+ "size": 256,+ "throughput_per_s": 6325084.284967398+ },+ {+ "backend": "kornia (compiled)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 50.52150027040625,+ "median_us": 1797.5625000872242,+ "n_lafs": 20000,+ "op": "laf_is_inside_image",+ "size": 256,+ "throughput_per_s": 11126177.809689248+ },+ {+ "backend": "kornia (eager)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 6859.937000172067,+ "median_us": 375174.2499998727,+ "n_lafs": 20000,+ "op": "extract_patches_simple",+ "size": 256,+ "throughput_per_s": 53308.56262125342+ },+ {+ "backend": "kornia (compiled)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 42662.78600016449,+ "median_us": 731061.0310000811,+ "n_lafs": 20000,+ "op": "extract_patches_simple",+ "size": 256,+ "throughput_per_s": 27357.497051429873+ },+ {+ "backend": "kornia (eager)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 7739.276999927824,+ "median_us": 529690.5800005334,+ "n_lafs": 20000,+ "op": "extract_patches_from_pyramid",+ "size": 256,+ "throughput_per_s": 37757.892541679445+ },+ {+ "backend": "kornia (compiled)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 879.9665001788526,+ "median_us": 540792.045499984,+ "n_lafs": 20000,+ "op": "extract_patches_from_pyramid",+ "size": 256,+ "throughput_per_s": 36982.792491907305+ },+ {+ "backend": "kornia (eager)",+ "batch": 8,+ "dtype": "float32",+ "iqr_us": 9.487702498063273,+ "median_us": 395.6915000026129,+ "n_lafs": 2000,+ "op": "laf_from_center_scale_ori",+ "size": 256,+ "throughput_per_s": 40435541.32422442+ },+ {+ "backend": "kornia (compiled)",+ "batch": 8,+ "dtype": "float32",+ "iqr_us": 14.694750461785588,+ "median_us": 153.87250005005626,+ "n_lafs": 2000,+ "op": "laf_from_center_scale_ori",+ "size": 256,+ "throughput_per_s": 103982193.01561384+ },+ {+ "backend": "kornia (eager)",+ "batch": 8,+ "dtype": "float32",+ "iqr_us": 12.932970003021161,+ "median_us": 487.7234000014141,+ "n_lafs": 2000,+ "op": "make_upright",+ "size": 256,+ "throughput_per_s": 32805479.499145642+ },+ {+ "backend": "kornia (compiled)",+ "batch": 8,+ "dtype": "float32",+ "iqr_us": 13.888249895899207,+ "median_us": 135.03399986802833,+ "n_lafs": 2000,+ "op": "make_upright",+ "size": 256,+ "throughput_per_s": 118488677.04161285+ },+ {+ "backend": "kornia (eager)",+ "batch": 8,+ "dtype": "float32",+ "iqr_us": 5.507320499873467,+ "median_us": 154.59282499978144,+ "n_lafs": 2000,+ "op": "ellipse_to_laf",+ "size": 256,+ "throughput_per_s": 103497688.2013937+ },+ {+ "backend": "kornia (compiled)",+ "batch": 8,+ "dtype": "float32",+ "iqr_us": 12.480999885156052,+ "median_us": 111.92099964318913,+ "n_lafs": 2000,+ "op": "ellipse_to_laf",+ "size": 256,+ "throughput_per_s": 142957979.74472138+ },+ {+ "backend": "kornia (eager)",+ "batch": 8,+ "dtype": "float32",+ "iqr_us": 359.3815999010982,+ "median_us": 4006.4931999950204,+ "n_lafs": 2000,+ "op": "laf_to_boundary_points",+ "size": 256,+ "throughput_per_s": 3993517.3233340033+ },+ {+ "backend": "kornia (compiled)",+ "batch": 8,+ "dtype": "float32",+ "iqr_us": 77.17149992458872,+ "median_us": 1587.8269996392191,+ "n_lafs": 2000,+ "op": "laf_to_boundary_points",+ "size": 256,+ "throughput_per_s": 10076664.525565738+ },+ {+ "backend": "kornia (eager)",+ "batch": 8,+ "dtype": "float32",+ "iqr_us": 185.89437502214423,+ "median_us": 2634.0866000282404,+ "n_lafs": 2000,+ "op": "laf_is_inside_image",+ "size": 256,+ "throughput_per_s": 6074211.834883661+ },+ {+ "backend": "kornia (compiled)",+ "batch": 8,+ "dtype": "float32",+ "iqr_us": 53.80950051403488,+ "median_us": 1609.2140003820532,+ "n_lafs": 2000,+ "op": "laf_is_inside_image",+ "size": 256,+ "throughput_per_s": 9942742.230804196+ },+ {+ "backend": "kornia (eager)",+ "batch": 8,+ "dtype": "float32",+ "iqr_us": 8353.97700006979,+ "median_us": 319677.0239997022,+ "n_lafs": 2000,+ "op": "extract_patches_simple",+ "size": 256,+ "throughput_per_s": 50050.51598583109+ },+ {+ "backend": "kornia (compiled)",+ "batch": 8,+ "dtype": "float32",+ "iqr_us": 6620.721500439686,+ "median_us": 589818.0154999864,+ "n_lafs": 2000,+ "op": "extract_patches_simple",+ "size": 256,+ "throughput_per_s": 27127.01134846969+ },+ {+ "backend": "kornia (eager)",+ "batch": 8,+ "dtype": "float32",+ "iqr_us": 6215.670500296255,+ "median_us": 456660.10700006154,+ "n_lafs": 2000,+ "op": "extract_patches_from_pyramid",+ "size": 256,+ "throughput_per_s": 35036.99963000675+ },+ {+ "backend": "kornia (compiled)",+ "batch": 8,+ "dtype": "float32",+ "iqr_us": 5917.25200001747,+ "median_us": 614538.6860002873,+ "n_lafs": 2000,+ "op": "extract_patches_from_pyramid",+ "size": 256,+ "throughput_per_s": 26035.7897142907+ }+ ]+}diff --git a/benchmarks/results/0.9.0rc1/feature-laf-ops--i7-14700k-rtx-4090--cuda.json b/benchmarks/results/0.9.0rc1/feature-laf-ops--i7-14700k-rtx-4090--cuda.jsonnew file mode 100644index 000000000..e3f99fa2b--- /dev/null+++ b/benchmarks/results/0.9.0rc1/feature-laf-ops--i7-14700k-rtx-4090--cuda.json@@ -0,0 +1,495 @@+{+ "metadata": {+ "albumentations": "2.0.8",+ "cuda_device": "NVIDIA GeForce RTX 4090",+ "cuda_version": "13.0",+ "device": "cuda",+ "git_commit": "9517c982",+ "kornia": "0.9.0rc1",+ "kornia_module": "kornia/__init__.py",+ "kornia_rs": "0.1.10",+ "load": {+ "cpu_count": 28,+ "load_avg_15m": 0.20361328125,+ "load_avg_1m": 0.7978515625,+ "load_avg_5m": 0.36962890625,+ "mem_available_bytes": 29990760448,+ "mem_total_bytes": 33488023552+ },+ "machine": "x86_64",+ "numpy": "2.4.4",+ "opencv": "4.13.0",+ "pillow": "12.2.0",+ "platform": "Linux-6.18.33.2-microsoft-standard-WSL2-x86_64-with-glibc2.39",+ "python": "3.13.12",+ "timestamp_utc": "2026-09-03T18:27:24+00:00",+ "torch": "2.14.0+cu130",+ "torch_num_threads": 14,+ "torchvision": "0.29.0+cu130",+ "units": "LAFs/s"+ },+ "results": [+ {+ "backend": "kornia (eager)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 29.168392499741437,+ "median_us": 150.45598199958476,+ "n_lafs": 2000,+ "op": "laf_from_center_scale_ori",+ "size": 256,+ "throughput_per_s": 13292924.43822885+ },+ {+ "backend": "kornia (compiled)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 47.10350003733765,+ "median_us": 67.27900017722277,+ "n_lafs": 2000,+ "op": "laf_from_center_scale_ori",+ "size": 256,+ "throughput_per_s": 29726957.81345897+ },+ {+ "backend": "kornia (eager)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 41.97457250029404,+ "median_us": 244.04734000199824,+ "n_lafs": 2000,+ "op": "make_upright",+ "size": 256,+ "throughput_per_s": 8195131.321585493+ },+ {+ "backend": "kornia (compiled)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 22.979499590292107,+ "median_us": 55.165500270959456,+ "n_lafs": 2000,+ "op": "make_upright",+ "size": 256,+ "throughput_per_s": 36254542.96936471+ },+ {+ "backend": "kornia (eager)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 28.24014999964675,+ "median_us": 141.03223300026002,+ "n_lafs": 2000,+ "op": "ellipse_to_laf",+ "size": 256,+ "throughput_per_s": 14181155.31076015+ },+ {+ "backend": "kornia (compiled)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 3.2879997888812795,+ "median_us": 39.63600011047674,+ "n_lafs": 2000,+ "op": "ellipse_to_laf",+ "size": 256,+ "throughput_per_s": 50459178.38392962+ },+ {+ "backend": "kornia (eager)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 67.4373400033801,+ "median_us": 599.7626300086267,+ "n_lafs": 2000,+ "op": "laf_to_boundary_points",+ "size": 256,+ "throughput_per_s": 3334652.5774225593+ },+ {+ "backend": "kornia (compiled)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 142.86424925558094,+ "median_us": 326.315999700455,+ "n_lafs": 2000,+ "op": "laf_to_boundary_points",+ "size": 256,+ "throughput_per_s": 6129028.30947891+ },+ {+ "backend": "kornia (eager)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 61.66145999486616,+ "median_us": 477.66871999556315,+ "n_lafs": 2000,+ "op": "laf_is_inside_image",+ "size": 256,+ "throughput_per_s": 4187002.2387452484+ },+ {+ "backend": "kornia (compiled)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 117.69125035243633,+ "median_us": 170.70949979824945,+ "n_lafs": 2000,+ "op": "laf_is_inside_image",+ "size": 256,+ "throughput_per_s": 11715809.620224247+ },+ {+ "backend": "kornia (eager)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 473.8889992950135,+ "median_us": 965.391000136151,+ "n_lafs": 2000,+ "op": "extract_patches_simple",+ "size": 256,+ "throughput_per_s": 2071699.4458389773+ },+ {+ "backend": "kornia (compiled)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 22.97800006090256,+ "median_us": 105.25699963181978,+ "n_lafs": 2000,+ "op": "extract_patches_simple",+ "size": 256,+ "throughput_per_s": 19001111.63149086+ },+ {+ "backend": "kornia (eager)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 569.3547495866369,+ "median_us": 1448.852000066836,+ "n_lafs": 2000,+ "op": "extract_patches_from_pyramid",+ "size": 256,+ "throughput_per_s": 1380403.2433317823+ },+ {+ "backend": "kornia (compiled)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 97.11725033412222,+ "median_us": 248.401499902684,+ "n_lafs": 2000,+ "op": "extract_patches_from_pyramid",+ "size": 256,+ "throughput_per_s": 8051481.173759168+ },+ {+ "backend": "kornia (eager)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 27.608298000131988,+ "median_us": 135.16426199976195,+ "n_lafs": 20000,+ "op": "laf_from_center_scale_ori",+ "size": 256,+ "throughput_per_s": 147968107.13201118+ },+ {+ "backend": "kornia (compiled)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 23.183750272437464,+ "median_us": 78.56699994590599,+ "n_lafs": 20000,+ "op": "laf_from_center_scale_ori",+ "size": 256,+ "throughput_per_s": 254559802.63685974+ },+ {+ "backend": "kornia (eager)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 28.917475005982837,+ "median_us": 267.0048299978589,+ "n_lafs": 20000,+ "op": "make_upright",+ "size": 256,+ "throughput_per_s": 74905012.01854806+ },+ {+ "backend": "kornia (compiled)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 22.105999960331246,+ "median_us": 52.870499985147035,+ "n_lafs": 20000,+ "op": "make_upright",+ "size": 256,+ "throughput_per_s": 378282785.4024195+ },+ {+ "backend": "kornia (eager)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 23.56798000164418,+ "median_us": 166.76395000104094,+ "n_lafs": 20000,+ "op": "ellipse_to_laf",+ "size": 256,+ "throughput_per_s": 119929996.86008373+ },+ {+ "backend": "kornia (compiled)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 2.7010005396732595,+ "median_us": 44.6619997092057,+ "n_lafs": 20000,+ "op": "ellipse_to_laf",+ "size": 256,+ "throughput_per_s": 447807982.85388047+ },+ {+ "backend": "kornia (eager)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 318.2444999765722,+ "median_us": 1417.6728000165895,+ "n_lafs": 20000,+ "op": "laf_to_boundary_points",+ "size": 256,+ "throughput_per_s": 14107627.655525282+ },+ {+ "backend": "kornia (compiled)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 88.96450026441016,+ "median_us": 1121.3459993086872,+ "n_lafs": 20000,+ "op": "laf_to_boundary_points",+ "size": 256,+ "throughput_per_s": 17835708.168870315+ },+ {+ "backend": "kornia (eager)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 88.30624250549585,+ "median_us": 712.2793200005617,+ "n_lafs": 20000,+ "op": "laf_is_inside_image",+ "size": 256,+ "throughput_per_s": 28078872.20421369+ },+ {+ "backend": "kornia (compiled)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 104.52899914525915,+ "median_us": 356.9010004866868,+ "n_lafs": 20000,+ "op": "laf_is_inside_image",+ "size": 256,+ "throughput_per_s": 56037948.822578445+ },+ {+ "backend": "kornia (eager)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 157.67450004204858,+ "median_us": 5714.391449964751,+ "n_lafs": 20000,+ "op": "extract_patches_simple",+ "size": 256,+ "throughput_per_s": 3499935.238094928+ },+ {+ "backend": "kornia (compiled)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 19.94099966395879,+ "median_us": 627.3469998632208,+ "n_lafs": 20000,+ "op": "extract_patches_simple",+ "size": 256,+ "throughput_per_s": 31880283.167625826+ },+ {+ "backend": "kornia (eager)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 427.7358500075932,+ "median_us": 6711.751100010588,+ "n_lafs": 20000,+ "op": "extract_patches_from_pyramid",+ "size": 256,+ "throughput_per_s": 2979848.2842977373+ },+ {+ "backend": "kornia (compiled)",+ "batch": 1,+ "dtype": "float32",+ "iqr_us": 192.65399987489218,+ "median_us": 770.1364997956262,+ "n_lafs": 20000,+ "op": "extract_patches_from_pyramid",+ "size": 256,+ "throughput_per_s": 25969422.310600094+ },+ {+ "backend": "kornia (eager)",+ "batch": 8,+ "dtype": "float32",+ "iqr_us": 32.0259700004044,+ "median_us": 127.35541299980468,+ "n_lafs": 2000,+ "op": "laf_from_center_scale_ori",+ "size": 256,+ "throughput_per_s": 125632665.49200024+ },+ {+ "backend": "kornia (compiled)",+ "batch": 8,+ "dtype": "float32",+ "iqr_us": 53.56800102163106,+ "median_us": 68.74000064271968,+ "n_lafs": 2000,+ "op": "laf_from_center_scale_ori",+ "size": 256,+ "throughput_per_s": 232761126.7151563+ },+ {+ "backend": "kornia (eager)",+ "batch": 8,+ "dtype": "float32",+ "iqr_us": 15.982208000423306,+ "median_us": 231.60480900060065,+ "n_lafs": 2000,+ "op": "make_upright",+ "size": 256,+ "throughput_per_s": 69083194.20931587+ },+ {+ "backend": "kornia (compiled)",+ "batch": 8,+ "dtype": "float32",+ "iqr_us": 29.701500807277625,+ "median_us": 49.285499699180946,+ "n_lafs": 2000,+ "op": "make_upright",+ "size": 256,+ "throughput_per_s": 324639094.6152038+ },+ {+ "backend": "kornia (eager)",+ "batch": 8,+ "dtype": "float32",+ "iqr_us": 25.283565000790993,+ "median_us": 157.23973500371358,+ "n_lafs": 2000,+ "op": "ellipse_to_laf",+ "size": 256,+ "throughput_per_s": 101755450.0433502+ },+ {+ "backend": "kornia (compiled)",+ "batch": 8,+ "dtype": "float32",+ "iqr_us": 28.29100048984401,+ "median_us": 42.23100040690042,+ "n_lafs": 2000,+ "op": "ellipse_to_laf",+ "size": 256,+ "throughput_per_s": 378868599.9819613+ },+ {+ "backend": "kornia (eager)",+ "batch": 8,+ "dtype": "float32",+ "iqr_us": 203.3266000125878,+ "median_us": 1254.9181999929715,+ "n_lafs": 2000,+ "op": "laf_to_boundary_points",+ "size": 256,+ "throughput_per_s": 12749835.009237744+ },+ {+ "backend": "kornia (compiled)",+ "batch": 8,+ "dtype": "float32",+ "iqr_us": 225.3259999633883,+ "median_us": 916.8090000457596,+ "n_lafs": 2000,+ "op": "laf_to_boundary_points",+ "size": 256,+ "throughput_per_s": 17451835.65955549+ },+ {+ "backend": "kornia (eager)",+ "batch": 8,+ "dtype": "float32",+ "iqr_us": 197.03943999957127,+ "median_us": 817.8678599961131,+ "n_lafs": 2000,+ "op": "laf_is_inside_image",+ "size": 256,+ "throughput_per_s": 19563062.424382392+ },+ {+ "backend": "kornia (compiled)",+ "batch": 8,+ "dtype": "float32",+ "iqr_us": 79.53600015753182,+ "median_us": 329.2219998911605,+ "n_lafs": 2000,+ "op": "laf_is_inside_image",+ "size": 256,+ "throughput_per_s": 48599425.327862464+ },+ {+ "backend": "kornia (eager)",+ "batch": 8,+ "dtype": "float32",+ "iqr_us": 100.36909989139583,+ "median_us": 4872.742900079174,+ "n_lafs": 2000,+ "op": "extract_patches_simple",+ "size": 256,+ "throughput_per_s": 3283571.5587908453+ },+ {+ "backend": "kornia (compiled)",+ "batch": 8,+ "dtype": "float32",+ "iqr_us": 22.81500019307714,+ "median_us": 481.7099998035701,+ "n_lafs": 2000,+ "op": "extract_patches_simple",+ "size": 256,+ "throughput_per_s": 33215004.89199813+ },+ {+ "backend": "kornia (eager)",+ "batch": 8,+ "dtype": "float32",+ "iqr_us": 316.7148749298578,+ "median_us": 6322.908549964267,+ "n_lafs": 2000,+ "op": "extract_patches_from_pyramid",+ "size": 256,+ "throughput_per_s": 2530481.0078409915+ },+ {+ "backend": "kornia (compiled)",+ "batch": 8,+ "dtype": "float32",+ "iqr_us": 204.8884996384004,+ "median_us": 772.3749999968277,+ "n_lafs": 2000,+ "op": "extract_patches_from_pyramid",+ "size": 256,+ "throughput_per_s": 20715326.104632743+ }+ ]+}diff --git a/benchmarks/results_schema.py b/benchmarks/results_schema.pyindex 3b7ab16b9..b2d00003c 100644--- a/benchmarks/results_schema.py+++ b/benchmarks/results_schema.py@@ -20,10 +20,16 @@from __future__ import annotationsimport json+import refrom pathlib import PathREQUIRED_METADATA = ("timestamp_utc", "git_commit", "platform", "python", "torch", "kornia", "device", "load")+#: An absolute path in a committed file discloses a home directory or machine layout. The README+#: promises contributors that only aggregate numbers are recorded, so enforce it for every string+#: metadata value rather than only for the keys that exist today.+_ABSOLUTE_PATH = re.compile(r"^(/|\\\\|[A-Za-z]:[\\/])")+def validate_result(path: Path) -> list[str]:"""Return a list of problems with a committed result file; empty list means valid."""@@ -43,6 +49,9 @@ def validate_result(path: Path) -> list[str]:load = meta.get("load", {})if not isinstance(load, dict) or not all(v is None or isinstance(v, (int, float)) for v in load.values()):errors.append("metadata.load must contain only numeric aggregates or null (privacy rule)")+ for key, value in meta.items():+ if isinstance(value, str) and _ABSOLUTE_PATH.match(value):+ errors.append(f"metadata.{key} must not be an absolute filesystem path (privacy rule)")if not isinstance(results, list) or not results:errors.append("results must be a non-empty list")else:diff --git a/benchmarks/results_schema_test.py b/benchmarks/results_schema_test.pyindex a40dff495..69a444135 100644--- a/benchmarks/results_schema_test.py+++ b/benchmarks/results_schema_test.py@@ -52,6 +52,26 @@ def test_valid_file_passes(tmp_path) -> None:assert results_schema.validate_result(p) == []+def test_absolute_path_in_metadata_flagged(tmp_path) -> None:+ """A committed file must not disclose a home directory or machine layout (README privacy rule)."""+ p = tmp_path / "0.9.0rc1" / "filters--test-box--cpu.json"+ p.parent.mkdir()+ for leaked in ("/home/someone/dev/kornia/kornia/__init__.py", "C:\\Users\\someone\\kornia", "\\\\host\\share"):+ payload = _valid_payload()+ payload["metadata"]["kornia_module"] = leaked+ p.write_text(json.dumps(payload))+ assert any("privacy" in e for e in results_schema.validate_result(p)), leaked+++def test_checkout_relative_module_path_passes(tmp_path) -> None:+ payload = _valid_payload()+ payload["metadata"]["kornia_module"] = "kornia/__init__.py"+ p = tmp_path / "0.9.0rc1" / "filters--test-box--cpu.json"+ p.parent.mkdir()+ p.write_text(json.dumps(payload))+ assert results_schema.validate_result(p) == []++def test_device_mismatch_flagged(tmp_path) -> None:p = tmp_path / "0.9.0rc1" / "filters--test-box--cuda.json"p.parent.mkdir()diff --git a/docs/generate_benchmarks.py b/docs/generate_benchmarks.pyindex c1bed71fe..651229622 100644--- a/docs/generate_benchmarks.py+++ b/docs/generate_benchmarks.py@@ -68,7 +68,9 @@ albumentations win the single-image uint8 CPU regime and we publish those lossesReproduce or contribute a machine with::- python benchmarks/<suite>/flagship.py --device <cpu|cuda|mps> --contribute benchmarks/results+ python benchmarks/<dir>/<script>.py --device <cpu|cuda|mps> --contribute benchmarks/results++Most suites are a ``flagship.py``; ``benchmarks/README.md`` maps each suite to its script."""@@ -91,16 +93,46 @@ def latest_version(versions: list[str]) -> str:return max(versions, key=_version_key)+#: Row fields that identify the measurement rather than the configuration it was taken at.+MEASUREMENT_FIELDS = frozenset({"op", "backend", "median_us", "iqr_us", "throughput_per_s", "error"})+++def _extra_config_fields(rows: list[dict]) -> list[str]:+ """Config fields besides ``batch`` that differ between rows of one result file.++ ``op`` plus ``batch`` identifies a row in a suite that sweeps batch size alone, which is what+ the flagship suites do; a suite sweeping a second axis (``feature-laf-ops`` varies ``n_lafs``+ at a fixed batch) would otherwise collapse two configs onto one row and render whichever came+ last. Fields that are constant across the file -- image size, dtype -- stay out of the label+ and are already disclosed in the metadata line above the table.+ """+ keys = [k for k in dict.fromkeys(k for r in rows for k in r) if k not in MEASUREMENT_FIELDS and k != "batch"]+ return [k for k in keys if len({repr(r.get(k)) for r in rows}) > 1]+++def _config_key(row: dict, extra: list[str]) -> tuple:+ return (row["op"], row["batch"], *(repr(row.get(k)) for k in extra))+++def _config_label(row: dict, extra: list[str]) -> str:+ label = f"{row['op']} @ {row['batch']}"+ if extra:+ label += " (" + ", ".join(f"{k}={row.get(k)}" for k in extra) + ")"+ return label++def _table(payload: dict) -> str:rows = payload["results"]backends = list(dict.fromkeys(r["backend"] for r in rows))+ extra = _extra_config_fields(rows)lines = [".. list-table::", " :header-rows: 1", "", " * - op @ batch"]lines += [f" - {b}" for b in backends]- cells = {(r["op"], r["batch"], r["backend"]): r.get("throughput_per_s") for r in rows}- for op, batch in dict.fromkeys((r["op"], r["batch"]) for r in rows):- lines.append(f" * - {op} @ {batch}")+ cells = {(_config_key(r, extra), r["backend"]): r.get("throughput_per_s") for r in rows}+ labels = {_config_key(r, extra): _config_label(r, extra) for r in rows}+ for key in dict.fromkeys(_config_key(r, extra) for r in rows):+ lines.append(f" * - {labels[key]}")for b in backends:- v = cells.get((op, batch, b))+ v = cells.get((key, b))lines.append(f" - {v:.0f}" if isinstance(v, (int, float)) else " - β")return "\n".join(lines) + "\n"@@ -117,7 +149,8 @@ def render_page(results_root: Path) -> str:parts.append(f"\n{suite} β {slug} ({device})\n{'^' * (len(suite) + len(slug) + len(device) + 6)}\n")parts.append(f"``{meta['platform']}`` β torch {meta['torch']}, kornia {meta['kornia']}, "- f"commit ``{meta['git_commit']}``, {meta['timestamp_utc'][:10]}, throughput in items/s\n\n"+ f"commit ``{meta['git_commit']}``, {meta['timestamp_utc'][:10]}, "+ f"throughput in {meta.get('units') or 'items/s'}\n\n")parts.append(_table(payload))older = sorted(set(data) - {version})@@ -219,7 +252,8 @@ def _digest(results_root: Path) -> str:return "- No committed benchmark results yet.\n"version = latest_version(list(data))lines = [f"- Result set: kornia {version}, committed in `benchmarks/results/{version}/` (per-machine"]- lines += [" snapshots; reproduce with `python benchmarks/<suite>/flagship.py --contribute benchmarks/results`)."]+ lines += [" snapshots; reproduce with `python benchmarks/<dir>/<script>.py --contribute benchmarks/results`,"]+ lines += [" the script each suite maps to in `benchmarks/README.md`)."]for fname, payload in sorted(data[version].items()):suite, slug, device = fname[:-5].split("--")meta = payload["metadata"]@@ -229,12 +263,19 @@ def _digest(results_root: Path) -> str:best = max(rows, key=lambda r: r["throughput_per_s"])kornia_rows = [r for r in rows if r["backend"].startswith("kornia")]worst = min(kornia_rows, key=lambda r: r["throughput_per_s"]) if kornia_rows else None+ extra = _extra_config_fields(rows)+ units = meta.get("units") or "items/s"++ def _at(row: dict, extra: list[str] = extra) -> str:+ tail = "".join(f",{k}={row.get(k)}" for k in extra)+ return f"{row['op']}@{row['batch']}{tail}"+line = (f"- {suite} on {slug}/{device} ({meta['timestamp_utc'][:10]}): fastest overall "- f"{best['backend']} {best['op']}@{best['batch']} at {best['throughput_per_s']:.0f} items/s"+ f"{best['backend']} {_at(best)} at {best['throughput_per_s']:.0f} {units}")if worst is not None:- line += f"; slowest kornia op {worst['op']}@{worst['batch']} at {worst['throughput_per_s']:.0f} items/s"+ line += f"; slowest kornia op {_at(worst)} at {worst['throughput_per_s']:.0f} {units}"lines.append(line + ".")return "\n".join(lines) + "\n"diff --git a/docs/source/_extra/llms-full.txt b/docs/source/_extra/llms-full.txtindex a3dd1474c..abd78cb9f 100644--- a/docs/source/_extra/llms-full.txt+++ b/docs/source/_extra/llms-full.txt@@ -170,11 +170,16 @@ Durable findings from earlier CUDA runs (2026-08-07, see benchmarks/README.md):<!-- BENCH:BEGIN -->- Result set: kornia 0.9.0rc1, committed in `benchmarks/results/0.9.0rc1/` (per-machine- snapshots; reproduce with `python benchmarks/<suite>/flagship.py --contribute benchmarks/results`).+ snapshots; reproduce with `python benchmarks/<dir>/<script>.py --contribute benchmarks/results`,+ the script each suite maps to in `benchmarks/README.md`).- augmentation on apple-m1/cpu (2026-08-08): fastest overall opencv RandomHorizontalFlip@1 at 180552 items/s; slowest kornia op ColorJiggle@32 at 157 items/s.- augmentation on apple-m1/mps (2026-08-08): fastest overall opencv RandomHorizontalFlip@8 at 182381 items/s; slowest kornia op ColorJiggle@1 at 91 items/s.- augmentation on apple-m4/cpu (2026-08-18): fastest overall opencv RandomHorizontalFlip@8 at 248255 items/s; slowest kornia op ColorJiggle@32 at 414 items/s.- augmentation on apple-m4/mps (2026-08-18): fastest overall opencv RandomHorizontalFlip@8 at 247523 items/s; slowest kornia op ColorJiggle@1 at 271 items/s.+- feature-laf-ops on apple-m1/cpu (2026-09-03): fastest overall kornia (compiled) ellipse_to_laf@1,n_lafs=20000 at 177777778 LAFs/s; slowest kornia op extract_patches_from_pyramid@8,n_lafs=2000 at 29024 LAFs/s.+- feature-laf-ops on apple-m1/mps (2026-09-03): fastest overall kornia (compiled) ellipse_to_laf@1,n_lafs=20000 at 39990002 LAFs/s; slowest kornia op extract_patches_from_pyramid@1,n_lafs=2000 at 57587 LAFs/s.+- feature-laf-ops on i7-14700k-rtx-4090/cpu (2026-09-03): fastest overall kornia (compiled) ellipse_to_laf@1,n_lafs=20000 at 149762253 LAFs/s; slowest kornia op extract_patches_from_pyramid@8,n_lafs=2000 at 26036 LAFs/s.+- feature-laf-ops on i7-14700k-rtx-4090/cuda (2026-09-03): fastest overall kornia (compiled) ellipse_to_laf@1,n_lafs=20000 at 447807983 LAFs/s; slowest kornia op extract_patches_from_pyramid@1,n_lafs=2000 at 1380403 LAFs/s.- filters on apple-m1/cpu (2026-08-08): fastest overall opencv box_blur@1 at 22422 items/s; slowest kornia op median_blur@32 at 11 items/s.- filters on apple-m1/mps (2026-08-08): fastest overall opencv box_blur@1 at 20137 items/s; slowest kornia op median_blur@32 at 1 items/s.- filters on apple-m4/cpu (2026-08-18): fastest overall opencv box_blur@1 at 31751 items/s; slowest kornia op median_blur@32 at 16 items/s.diff --git a/tests/models/test_object_detector.py b/tests/models/test_object_detector.pyindex 23ebb0566..9235a73e9 100644--- a/tests/models/test_object_detector.py+++ b/tests/models/test_object_detector.py@@ -22,7 +22,7 @@ import pytestimport torchimport kornia-from kornia.core._compat import torch_version_lt+from kornia.core._compat import torch_version_ge, torch_version_ltfrom kornia.models.rt_detr import RTDETR, DETRPostProcessor, RTDETRConfigfrom testing.base import BaseTester@@ -54,6 +54,18 @@ class TestObjectDetector(BaseTester):@pytest.mark.slow@pytest.mark.timeout(120)@pytest.mark.skipif(torch_version_lt(2, 0, 0), reason="Unsupported ONNX opset version: 16")+ @pytest.mark.xfail(+ torch_version_ge(2, 14) and torch_version_lt(2, 15, 0),+ reason=(+ "torch 2.14's dynamo ONNX exporter cannot translate aten.mul.Scalar for this graph: "+ "DispatchError 'No ONNX function found for aten.mul.Scalar'. Same exporter gap as "+ "test_sam_onnx.py::test_sam_encoder_to_onnx; not yet reported upstream"+ ),+ raises=torch.onnx.OnnxExporterError,+ # Strict, as in test_sam_onnx.py: an upstream fix inside 2.14.x must announce itself as+ # an XPASS rather than sit silent until the 2.15 bound expires. Both variants fail today.+ strict=True,+ )@pytest.mark.parametrize("variant", ("resnet50d", "hgnetv2_l"))def test_onnx(self, device, dtype, tmp_path: Path, variant: str):config = RTDETRConfig(variant, 1)diff --git a/tests/models/test_sam_onnx.py b/tests/models/test_sam_onnx.pyindex 810531720..9bb129a1e 100644--- a/tests/models/test_sam_onnx.py+++ b/tests/models/test_sam_onnx.py@@ -39,6 +39,18 @@ def test_sam_has_to_onnx():sys.platform == "darwin",reason="TorchScript tracing of the SAM encoder exceeds the 120s timeout on macOS CI runners",)+ torch_version_ge(2, 14) and torch_version_lt(2, 15, 0),+ reason=(+ "torch 2.14's dynamo ONNX exporter cannot translate aten.mul.Scalar for this graph: "+ "DispatchError 'No decompositions registered for the real-valued input'; not yet "+ "reported upstream"+ ),+ raises=torch.onnx.OnnxExporterError,+ # Strict: an upstream fix inside 2.14.x must announce itself as an XPASS failure rather+ # than sit silently until the 2.15 bound expires.+ strict=True,+)def test_sam_encoder_to_onnx(tmp_path):"""Sam.to_onnx() exports the image encoder subgraph with correct output name."""onnx = pytest.importorskip("onnx")diff --git a/tests/test_generate_benchmarks.py b/tests/test_generate_benchmarks.pyindex b1ca8ecbf..bd5bc7a1d 100644--- a/tests/test_generate_benchmarks.py+++ b/tests/test_generate_benchmarks.py@@ -59,6 +59,62 @@ def test_render_page_contains_table_and_metadata(tmp_path: Path) -> None:assert "close other applications" in rst # hygiene box present+def _seed_two_axis(tmp_path: Path) -> Path:+ """A suite that sweeps a second axis at a fixed batch, like ``feature-laf-ops``."""+ payload = {+ "metadata": {+ "timestamp_utc": "2026-09-03T12:00:00+00:00",+ "git_commit": "d415faa0",+ "platform": "Linux-6.18-x86_64",+ "python": "3.13.0",+ "torch": "2.14.0",+ "kornia": "0.9.0rc1",+ "device": "cpu",+ "load": {"load_avg_1m": 1.0},+ "units": "LAFs/s",+ },+ "results": [+ {"op": "make_upright", "backend": "kornia (eager)", "batch": 1, "n_lafs": 2000, "throughput_per_s": 20.0},+ {"op": "make_upright", "backend": "kornia (eager)", "batch": 1, "n_lafs": 20000, "throughput_per_s": 33.0},+ {"op": "make_upright", "backend": "kornia (eager)", "batch": 8, "n_lafs": 2000, "throughput_per_s": 31.0},+ ],+ }+ d = tmp_path / "0.9.0rc1"+ d.mkdir(exist_ok=True)+ (d / "feature-laf-ops--box--cpu.json").write_text(json.dumps(payload))+ return tmp_path+++def test_render_page_keeps_configs_that_share_a_batch(tmp_path: Path) -> None:+ rst = generate_benchmarks.render_page(_seed_two_axis(tmp_path))+ # One cell per config, in order. Keying rows on (op, batch) alone collapses the two B=1+ # configs and drops a value outright; a bare `"20" in rst` would not catch that, because the+ # 2026-09-03 timestamp above the table contains "20" whatever the table renders.+ assert [ln.strip()[2:] for ln in rst.splitlines() if ln.startswith(" - ")] == [+ "kornia (eager)",+ "20",+ "33",+ "31",+ ]+ assert "n_lafs=2000" in rst and "n_lafs=20000" in rst+ assert "throughput in LAFs/s" in rst # the item is a LAF, not an image+++def test_render_page_omits_constant_config_fields(tmp_path: Path) -> None:+ rst = generate_benchmarks.render_page(_seed(tmp_path))+ assert "ColorJiggle @ 32" in rst # batch-only suites keep the short label+ assert "throughput in items/s" in rst # no units key -> the existing default+++def test_digest_disambiguates_configs_that_share_a_batch(tmp_path: Path) -> None:+ llms = tmp_path / "llms-full.txt"+ llms.write_text("a\n<!-- BENCH:BEGIN -->\n<!-- BENCH:END -->\nb\n")+ generate_benchmarks.refresh_llms(llms, _seed_two_axis(tmp_path))+ line = next(ln for ln in llms.read_text().splitlines() if ln.startswith("- feature-laf-ops"))+ assert "make_upright@1,n_lafs=20000" in line # fastest row named by its full config+ assert "LAFs/s" in line++def test_latest_version_orders_rc_before_final() -> None:assert generate_benchmarks.latest_version(["0.9.0rc1", "0.9.0", "0.8.3"]) == "0.9.0"