Skip to content

armgit / ente

Public Imported from GitHub
0

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

Make Rust ML default for parity mobile runs

laurenspriemd6e15c63b92d
diff --git a/infra/ml/test/README.md b/infra/ml/test/README.md
index b6c2dff518..dc2d986d0c 100644
--- a/infra/ml/test/README.md
+++ b/infra/ml/test/README.md
@@ -35,6 +35,7 @@ Common flags:
- `--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:
diff --git a/infra/ml/test/run_ml_parity_tests.sh b/infra/ml/test/run_ml_parity_tests.sh
index b7b7718262..fc6f572825 100755
--- a/infra/ml/test/run_ml_parity_tests.sh
+++ b/infra/ml/test/run_ml_parity_tests.sh
@@ -24,7 +24,7 @@ RENDER_DETECTION_OVERLAYS=false
REUSE_MOBILE_APPLICATION_BINARY=false
PARALLEL_MOBILE_RUNNERS=true
INCLUDE_PAIRWISE=false
-INTERNAL_USER_ROUTE=false
+USE_LEGACY_MOBILE_ML=false
LOCAL_MIRROR_PORT=""
LOCAL_MIRROR_PID=""
@@ -47,7 +47,7 @@ Flags:
--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)
- --internal (default: disabled; mobile only, run internal-user Rust ML pipeline)
+ --legacy (default: disabled; mobile only, run legacy Dart/ONNX ML pipeline instead of Rust)
EOF
}
@@ -97,8 +97,8 @@ while (($# > 0)); do
INCLUDE_PAIRWISE=true
shift
;;
- --internal)
- INTERNAL_USER_ROUTE=true
+ --legacy)
+ USE_LEGACY_MOBILE_ML=true
shift
;;
-h|--help)
@@ -299,6 +299,11 @@ start_local_mirror_server() {
return 1
}
+MOBILE_ML_ROUTE="rust"
+if $USE_LEGACY_MOBILE_ML; then
+ MOBILE_ML_ROUTE="legacy-dart"
+fi
+
echo "Running ML parity suite"
print_kv "platforms:" "$PLATFORMS"
print_kv "output_dir:" "$OUTPUT_DIR"
@@ -313,7 +318,7 @@ 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 "internal_user_route:" "$INTERNAL_USER_ROUTE"
+print_kv "mobile_ml_route:" "$MOBILE_ML_ROUTE"
declare -a selected_platforms=()
case "$PLATFORMS" in
@@ -1017,7 +1022,7 @@ run_mobile_runner() {
--no-dds
--dart-define=ML_PARITY_MANIFEST_B64="$MANIFEST_B64"
--dart-define=ML_PARITY_CODE_REVISION="$CODE_REVISION"
- --dart-define=ML_PARITY_INTERNAL_USER="$INTERNAL_USER_ROUTE"
+ --dart-define=ML_PARITY_USE_LEGACY_MOBILE_ML="$USE_LEGACY_MOBILE_ML"
)
if [[ -z "$resolved_device_id" ]]; then
diff --git a/mobile/apps/photos/integration_test/ml_parity_shared.dart b/mobile/apps/photos/integration_test/ml_parity_shared.dart
index fc217b302c..61ba9691dd 100644
--- a/mobile/apps/photos/integration_test/ml_parity_shared.dart
+++ b/mobile/apps/photos/integration_test/ml_parity_shared.dart
@@ -26,10 +26,11 @@ const _codeRevision = String.fromEnvironment(
const _localMirrorBaseUrl = String.fromEnvironment(
"ML_PARITY_LOCAL_MIRROR_BASE_URL",
);
-const _internalUserRoute = bool.fromEnvironment(
- "ML_PARITY_INTERNAL_USER",
+const _useLegacyMobileMl = bool.fromEnvironment(
+ "ML_PARITY_USE_LEGACY_MOBILE_ML",
defaultValue: false,
);
+const _useRustMl = !_useLegacyMobileMl;
const _localModelMirrorRelativeDir = ".cache/local_model_mirror";
const _parityReportDataKey = "ml_parity_results_json";
@@ -89,12 +90,14 @@ void runMLParityIntegrationTest({required String expectedPlatform}) {
final modelSpecs = _modelSpecs();
final loadedModels = await _downloadAndLoadModels(
modelSpecs: modelSpecs,
- skipModelLoad: _internalUserRoute,
+ loadLegacySessions: _useLegacyMobileMl,
);
- final runtime = Platform.isAndroid
- ? "flutter-mobile-onnx-platform-plugin"
- : "flutter-mobile-onnx-ffi";
+ final runtime = _useRustMl
+ ? "rust-ml"
+ : (Platform.isAndroid
+ ? "flutter-mobile-onnx-platform-plugin"
+ : "flutter-mobile-onnx-ffi");
final results = <Map<String, dynamic>>[];
final errors = <Map<String, dynamic>>[];
@@ -220,7 +223,7 @@ class _LoadedModels {
Future<_LoadedModels> _downloadAndLoadModels({
required List<_ModelSpec> modelSpecs,
- required bool skipModelLoad,
+ required bool loadLegacySessions,
}) async {
await _ensureModelNetworkContext();
@@ -246,7 +249,7 @@ Future<_LoadedModels> _downloadAndLoadModels({
"${modelFile.uri.pathSegments.last}:$modelSHA256";
}
- if (skipModelLoad) {
+ if (!loadLegacySessions) {
return _LoadedModels(
modelNames: modelNames,
modelAddresses: const <int>[],
@@ -486,7 +489,7 @@ Future<MLResult> _analyzeImage({
required String filePath,
required _LoadedModels loadedModels,
}) async {
- const useRustMl = _internalUserRoute;
+ const useRustMl = _useRustMl;
final args = <String, dynamic>{
"enteFileID": fileID,
"filePath": filePath,