Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Remove ML parity pairwise comparisons

laurenspriem555fe722a10b
diff --git a/infra/ml/test/README.md b/infra/ml/test/README.md
index 1f4140d53c..135b216869 100644
--- a/infra/ml/test/README.md
+++ b/infra/ml/test/README.md
@@ -33,7 +33,6 @@ Common flags:
- `--render-detection-overlays` (generate annotated detection images under `out/parity/detections/<platform>/`; includes selected platforms plus `python` ground truth)
- `--reuse-mobile-application-binary` (reuse an existing built mobile binary when available; useful for repeated local parity runs without code changes)
- `--no-parallel-mobile-runners` (force sequential android/ios runner execution)
-- `--include-pairwise` (also compare non-ground-truth platform pairs such as `android -> ios`)
- `--legacy` (mobile only; run the legacy Dart/ONNX ML pipeline instead of the default Rust ML pipeline)
Outputs go to `infra/ml/test/out/parity/` by default, including:
@@ -41,7 +40,7 @@ Outputs go to `infra/ml/test/out/parity/` by default, including:
- `comparison_report.json` (machine-readable comparison output)
- `parity_report.html` (readable HTML report with per-file metrics for both pass and fail files)
-`run_ml_parity_tests.sh` compares each available platform against Python ground truth (`python -> <platform>`); non-ground-truth pairwise comparisons are excluded by default.
+`run_ml_parity_tests.sh` compares each available platform against Python ground truth (`python -> <platform>`).
Optional mobile reuse env vars:
diff --git a/infra/ml/test/comparator/compare.py b/infra/ml/test/comparator/compare.py
index e88aa826b4..d897a95183 100644
--- a/infra/ml/test/comparator/compare.py
+++ b/infra/ml/test/comparator/compare.py
@@ -1,7 +1,6 @@
from __future__ import annotations
from dataclasses import dataclass
-import itertools
import math
from typing import Any, Mapping, Sequence
@@ -102,9 +101,7 @@ def _percentile(values: Sequence[float], percentile: float) -> float:
@dataclass(frozen=True)
class ThresholdConfig:
clip_cosine_distance: float = 0.015
- cross_platform_clip_cosine_distance: float = 0.015
clip_warning_cosine_distance: float = 0.035
- cross_platform_clip_warning_cosine_distance: float = 0.035
face_embedding_cosine_distance: float = 0.015
face_embedding_warning_cosine_distance: float = 0.035
box_iou_threshold: float = 0.80
@@ -119,14 +116,6 @@ class ThresholdConfig:
raise ValueError(
"clip_warning_cosine_distance must be >= clip_cosine_distance"
)
- if (
- self.cross_platform_clip_warning_cosine_distance
- < self.cross_platform_clip_cosine_distance
- ):
- raise ValueError(
- "cross_platform_clip_warning_cosine_distance must be >= "
- "cross_platform_clip_cosine_distance"
- )
if self.face_embedding_warning_cosine_distance < self.face_embedding_cosine_distance:
raise ValueError(
"face_embedding_warning_cosine_distance must be >= face_embedding_cosine_distance"
@@ -135,11 +124,7 @@ class ThresholdConfig:
def to_dict(self) -> dict[str, float]:
return {
"clip_cosine_distance": self.clip_cosine_distance,
- "cross_platform_clip_cosine_distance": self.cross_platform_clip_cosine_distance,
"clip_warning_cosine_distance": self.clip_warning_cosine_distance,
- "cross_platform_clip_warning_cosine_distance": (
- self.cross_platform_clip_warning_cosine_distance
- ),
"face_embedding_cosine_distance": self.face_embedding_cosine_distance,
"face_embedding_warning_cosine_distance": self.face_embedding_warning_cosine_distance,
"box_iou_threshold": self.box_iou_threshold,
@@ -1121,7 +1106,6 @@ def compare_platform_matrix(
platform_results: Mapping[str, Sequence[ParityResult]],
*,
ground_truth_platform: str = "python",
- include_pairwise: bool = True,
thresholds: ThresholdConfig | None = None,
) -> tuple[ComparisonReport, ...]:
thresholds = thresholds or ThresholdConfig()
@@ -1151,22 +1135,4 @@ def compare_platform_matrix(
),
)
- if include_pairwise:
- for left_platform, right_platform in itertools.combinations(
- sorted(non_ground_truth_platforms), 2
- ):
- reports.append(
- compare_result_sets(
- reference_platform=left_platform,
- candidate_platform=right_platform,
- reference_results=by_platform[left_platform],
- candidate_results=by_platform[right_platform],
- thresholds=thresholds,
- clip_threshold=thresholds.cross_platform_clip_cosine_distance,
- clip_warning_threshold=(
- thresholds.cross_platform_clip_warning_cosine_distance
- ),
- ),
- )
-
return tuple(reports)
diff --git a/infra/ml/test/run_ml_parity_tests.sh b/infra/ml/test/run_ml_parity_tests.sh
index dd078fd61a..757686e3d7 100755
--- a/infra/ml/test/run_ml_parity_tests.sh
+++ b/infra/ml/test/run_ml_parity_tests.sh
@@ -23,7 +23,6 @@ VERBOSE=false
RENDER_DETECTION_OVERLAYS=false
REUSE_MOBILE_APPLICATION_BINARY=false
PARALLEL_MOBILE_RUNNERS=true
-INCLUDE_PAIRWISE=false
USE_LEGACY_MOBILE_ML=false
LOCAL_MIRROR_PORT=""
@@ -46,7 +45,6 @@ Flags:
--render-detection-overlays (default: disabled; render annotated face detection images to out/parity/detections/<platform>/)
--reuse-mobile-application-binary (default: disabled; reuse an existing built mobile binary when available)
--no-parallel-mobile-runners (default: disabled; run android/ios runners sequentially)
- --include-pairwise (default: disabled; include non-ground-truth pairwise platform comparisons)
--legacy (default: disabled; mobile only, run legacy Dart/ONNX ML pipeline instead of Rust)
EOF
}
@@ -93,10 +91,6 @@ while (($# > 0)); do
PARALLEL_MOBILE_RUNNERS=false
shift
;;
- --include-pairwise)
- INCLUDE_PAIRWISE=true
- shift
- ;;
--legacy)
USE_LEGACY_MOBILE_ML=true
shift
@@ -317,7 +311,6 @@ print_kv "render_detection_overlays:" "$RENDER_DETECTION_OVERLAYS"
print_kv "android_build_mode:" "${ML_PARITY_ANDROID_BUILD_MODE:-profile}"
print_kv "reuse_mobile_application_binary:" "$REUSE_MOBILE_APPLICATION_BINARY"
print_kv "parallel_mobile_runners:" "$PARALLEL_MOBILE_RUNNERS"
-print_kv "include_pairwise:" "$INCLUDE_PAIRWISE"
print_kv "mobile_ml_route:" "$MOBILE_ML_ROUTE"
declare -a selected_platforms=()
@@ -1371,9 +1364,6 @@ compare_cmd=(
--ground-truth "$PYTHON_OUTPUT_DIR/results.json"
--output "$compare_output"
)
-if ! $INCLUDE_PAIRWISE; then
- compare_cmd+=(--no-pairwise)
-fi
if ((${#compare_args[@]} > 0)); then
compare_cmd+=("${compare_args[@]}")
fi
diff --git a/infra/ml/test/tools/compare_parity_outputs.py b/infra/ml/test/tools/compare_parity_outputs.py
index 22e70a4c5b..2442677785 100755
--- a/infra/ml/test/tools/compare_parity_outputs.py
+++ b/infra/ml/test/tools/compare_parity_outputs.py
@@ -52,11 +52,6 @@ def main() -> int:
"--output",
help="Optional path to write machine-readable comparison JSON.",
)
- parser.add_argument(
- "--no-pairwise",
- action="store_true",
- help="Skip non-ground-truth pairwise comparisons.",
- )
parser.add_argument(
"--fail-on-any-file-failure",
action="store_true",
@@ -86,7 +81,6 @@ def main() -> int:
reports = compare_platform_matrix(
platform_results,
ground_truth_platform=ground_truth_platform,
- include_pairwise=not args.no_pairwise,
thresholds=thresholds,
)
diff --git a/infra/ml/test/tools/render_parity_html_report.py b/infra/ml/test/tools/render_parity_html_report.py
index 4ce63830f8..cf2cfd75e8 100755
--- a/infra/ml/test/tools/render_parity_html_report.py
+++ b/infra/ml/test/tools/render_parity_html_report.py
@@ -210,7 +210,6 @@ def render_report(
*,
report_path: Path,
output_path: Path,
- include_pairwise: bool,
) -> None:
payload = json.loads(report_path.read_text())
ground_truth_platform = str(payload.get("ground_truth_platform", "python"))
@@ -219,14 +218,6 @@ def render_report(
if not isinstance(comparisons, list):
comparisons = []
- if not include_pairwise:
- comparisons = [
- comparison
- for comparison in comparisons
- if isinstance(comparison, dict)
- and str(comparison.get("reference_platform", "")) == ground_truth_platform
- ]
-
report_dir = report_path.parent
stats = platform_stats(report_dir)
generated_at = format_generated_timestamp(payload.get("generated_at"))
@@ -331,11 +322,6 @@ def main() -> int:
"--output",
help="Output HTML path (default: <report_dir>/parity_report.html)",
)
- parser.add_argument(
- "--include-pairwise",
- action="store_true",
- help="Include non-ground-truth pairwise comparisons in the report.",
- )
args = parser.parse_args()
report_path = Path(args.report)
@@ -347,7 +333,6 @@ def main() -> int:
render_report(
report_path=report_path,
output_path=output_path,
- include_pairwise=args.include_pairwise,
)
print(output_path)
return 0