Skip to content

armgit / ente

Public Imported from GitHub
0

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

Remove deprecated Rust ML logging bridge

laurenspriem8fa200134b35
diff --git a/desktop/src/main/services/ml-worker.ts b/desktop/src/main/services/ml-worker.ts
index 3ced2e58c2..b439e62cfd 100644
--- a/desktop/src/main/services/ml-worker.ts
+++ b/desktop/src/main/services/ml-worker.ts
@@ -125,15 +125,6 @@ const assetStore = () => {
);
};
-const logMLRuntimeEvents = (native: MLNative) => {
- for (const { severity, message } of native.takeMlRuntimeEvents()) {
- const s = `[ml-rt] ${message}`;
- if (severity == "severe") log.error(s);
- else if (severity == "warning") log.warn(s);
- else log.info(s);
- }
-};
-
const _indexingModelPaths = new Map<
number,
Promise<MLNativeModule.ModelPaths>
@@ -175,7 +166,6 @@ export const releaseMLRuntime = () => {
if (!_native) return;
_native.releaseMlRuntime();
_preparedRuntimeKey = undefined;
- logMLRuntimeEvents(_native);
};
export interface MLWorkerAnalyzeImageRequest {
@@ -200,11 +190,7 @@ export const analyzeImage = async (
const analyzeImageOrThrow = async (req: MLWorkerAnalyzeImageRequest) => {
const native = mlNative();
- try {
- return await analyzeImageOnce(native, req);
- } finally {
- logMLRuntimeEvents(native);
- }
+ return analyzeImageOnce(native, req);
};
// A corrupt on-disk model will fail every retry, so report an init failure that
@@ -281,8 +267,6 @@ const warmUpClipTextEncoder = async (native: MLNative) => {
});
} catch (e) {
log.warn("Failed to warm up the CLIP text encoder", e);
- } finally {
- logMLRuntimeEvents(native);
}
};
@@ -304,14 +288,10 @@ export const computeCLIPTextEmbeddingIfAvailable = async (text: string) => {
}
const { modelPath, vocabPath } = pathsOrSkip;
- try {
- const { embedding } = await native.runClipText({
- text,
- modelPath,
- vocabPath,
- });
- return embedding;
- } finally {
- logMLRuntimeEvents(native);
- }
+ const { embedding } = await native.runClipText({
+ text,
+ modelPath,
+ vocabPath,
+ });
+ return embedding;
};
diff --git a/infra/ml/test/tools/desktop_parity_runner.js b/infra/ml/test/tools/desktop_parity_runner.js
index b4a13b3c34..28b4b207fd 100755
--- a/infra/ml/test/tools/desktop_parity_runner.js
+++ b/infra/ml/test/tools/desktop_parity_runner.js
@@ -162,6 +162,9 @@ const main = async () => {
const args = parseCLIArgs();
const native = loadMLAddon();
+ native.initLogging((level, target, message) =>
+ console.log(`[${level}][${target}] ${message}`),
+ );
native.initOrt(await onnxRuntimeLibraryPath());
// Match the app's configuration (see ml-worker.ts); a no-op on macOS.
native.setMlExecutionConfig(true);
@@ -211,8 +214,6 @@ const main = async () => {
}
} finally {
native.releaseMlRuntime();
- for (const { severity, message } of native.takeMlRuntimeEvents())
- console.log(`[ml-rt] ${severity}: ${message}`);
}
await fsp.mkdir(path.dirname(args.output), { recursive: true });
diff --git a/mobile/apps/photos/lib/utils/isolate/isolate_operations.dart b/mobile/apps/photos/lib/utils/isolate/isolate_operations.dart
index b8dad1741a..de99d5dff5 100644
--- a/mobile/apps/photos/lib/utils/isolate/isolate_operations.dart
+++ b/mobile/apps/photos/lib/utils/isolate/isolate_operations.dart
@@ -3,7 +3,6 @@ import 'dart:typed_data' show Float32List, Uint8List;
import "package:flutter_rust_bridge/flutter_rust_bridge.dart" show Uint64List;
import "package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart"
show Int64List;
-import "package:logging/logging.dart";
import "package:ml_linalg/linalg.dart";
import "package:photos/db/ml/clip_vector_db.dart";
import "package:photos/models/ml/face/box.dart";
@@ -22,7 +21,6 @@ import "package:photos/utils/ml_util.dart";
final Map<String, dynamic> _isolateCache = {};
const _rustLibLoadedCacheKey = "rustLibLoaded";
const _rustMlModelPathsCacheKey = "rustMlModelPaths";
-final _rustMlRuntimeLogger = Logger("RustMLRuntime");
class RustCorruptModelException implements Exception {
const RustCorruptModelException(this.modelPath);
@@ -129,11 +127,7 @@ Future<dynamic> isolateFunction(
/// MLIndexingIsolate
case IsolateOperation.releaseRustMlRuntime:
- try {
- await _releaseRustRuntime();
- } finally {
- await _logRustMlRuntimeEvents();
- }
+ await _releaseRustRuntime();
return true;
/// Cases for MLIndexingIsolate stop here
@@ -183,30 +177,26 @@ Future<dynamic> isolateFunction(
);
}
+ // Configure execution behavior before the CLIP text session is
+ // created; the session is process-global and cannot be reconfigured
+ // once built.
+ await rust_ml.setMlExecutionConfig(
+ enableWebgpu: (args["enableWebGpu"] as bool?) ?? false,
+ );
+
+ final rust_ml.RunClipTextResult result;
try {
- // Configure execution behavior before the CLIP text session is
- // created; the session is process-global and cannot be reconfigured
- // once built.
- await rust_ml.setMlExecutionConfig(
- enableWebgpu: (args["enableWebGpu"] as bool?) ?? false,
+ result = await rust_ml.runClipTextRust(
+ req: rust_ml.RunClipTextRequest(
+ text: text,
+ modelPath: clipTextModelPath,
+ vocabPath: clipTextVocabPath,
+ ),
);
-
- final rust_ml.RunClipTextResult result;
- try {
- result = await rust_ml.runClipTextRust(
- req: rust_ml.RunClipTextRequest(
- text: text,
- modelPath: clipTextModelPath,
- vocabPath: clipTextVocabPath,
- ),
- );
- } on rust_ml.RustMlError_CorruptModel catch (e) {
- return RustCorruptModelException(e.field0);
- }
- return List<double>.from(result.embedding, growable: false);
- } finally {
- await _logRustMlRuntimeEvents();
+ } on rust_ml.RustMlError_CorruptModel catch (e) {
+ return RustCorruptModelException(e.field0);
}
+ return List<double>.from(result.embedding, growable: false);
/// MLComputer
case IsolateOperation.computeBulkSimilarities:
@@ -447,25 +437,6 @@ Future<void> _releaseRustRuntime() async {
_isolateCache.remove(_rustMlModelPathsCacheKey);
}
-Future<void> _logRustMlRuntimeEvents() async {
- try {
- final events = await rust_ml.takeMlRuntimeEvents();
- for (final event in events) {
- final message = "Rust ML runtime: ${event.message}";
- switch (event.severity) {
- case "severe":
- _rustMlRuntimeLogger.severe(message);
- case "warning":
- _rustMlRuntimeLogger.warning(message);
- default:
- _rustMlRuntimeLogger.info(message);
- }
- }
- } catch (e, s) {
- _rustMlRuntimeLogger.warning("Failed to take Rust ML runtime events", e, s);
- }
-}
-
String _modelPathsCacheKey(rust_ml.RustModelPaths modelPaths) {
return [
modelPaths.faceDetection,
diff --git a/rust/Cargo.lock b/rust/Cargo.lock
index 674f21742a..6e09e3ae47 100644
--- a/rust/Cargo.lock
+++ b/rust/Cargo.lock
@@ -2502,6 +2502,7 @@ dependencies = [
"html-escape",
"image",
"imageproc",
+ "log",
"nalgebra 0.33.3",
"once_cell",
"ort",
diff --git a/rust/bindings/frb/photos/src/api/ml_indexing_api.rs b/rust/bindings/frb/photos/src/api/ml_indexing_api.rs
index af74b63b47..90bc725948 100644
--- a/rust/bindings/frb/photos/src/api/ml_indexing_api.rs
+++ b/rust/bindings/frb/photos/src/api/ml_indexing_api.rs
@@ -182,26 +182,6 @@ pub fn tokenize_clip_text_rust(text: String, vocab_path: String) -> Result<Vec<i
indexing::tokenize_clip_text(&text, &vocab_path).map_err(|e| e.to_string())
}
-// Execution-provider fallbacks and golden self-test failures are buffered for
-// app-side logging. Severity is "info", "warning", or "severe".
-#[derive(Clone, Debug)]
-pub struct RustMlRuntimeEvent {
- pub severity: String,
- pub message: String,
-}
-
-// Drain after ML operations and log each event at its severity. The buffer is
-// process-wide.
-pub fn take_ml_runtime_events() -> Vec<RustMlRuntimeEvent> {
- ente_photos::ml::events::take_events()
- .into_iter()
- .map(|event| RustMlRuntimeEvent {
- severity: event.severity.as_str().to_string(),
- message: event.message,
- })
- .collect()
-}
-
fn to_model_paths(paths: &RustModelPaths) -> ModelPaths {
ModelPaths {
face_detection: paths.face_detection.clone(),
diff --git a/rust/bindings/napi/photos/src/lib.rs b/rust/bindings/napi/photos/src/lib.rs
index 9e93d9bb5a..e0eab8d5f9 100644
--- a/rust/bindings/napi/photos/src/lib.rs
+++ b/rust/bindings/napi/photos/src/lib.rs
@@ -288,23 +288,6 @@ pub fn tokenize_clip_text(text: String, vocab_path: String) -> Result<Vec<i32>>
shared_indexing::tokenize_clip_text(&text, &vocab_path).map_err(ml_error_to_napi)
}
-#[napi(object)]
-pub struct MlRuntimeEvent {
- pub severity: String,
- pub message: String,
-}
-
-#[napi]
-pub fn take_ml_runtime_events() -> Vec<MlRuntimeEvent> {
- ente_photos::ml::events::take_events()
- .into_iter()
- .map(|event| MlRuntimeEvent {
- severity: event.severity.as_str().to_string(),
- message: event.message,
- })
- .collect()
-}
-
// Error kind prefixes survive Comlink's MessagePort serialization.
fn ml_error_to_napi(error: MlError) -> Error {
let kind = match &error {
diff --git a/rust/crates/photos/Cargo.toml b/rust/crates/photos/Cargo.toml
index 2def533ec8..95c1e71ef2 100644
--- a/rust/crates/photos/Cargo.toml
+++ b/rust/crates/photos/Cargo.toml
@@ -14,6 +14,7 @@ half = "2.1"
html-escape = "0.2.13"
image = { version = "0.25.5", default-features = true }
imageproc = "0.25.0"
+log.workspace = true
nalgebra = "0.33.2"
once_cell = "1.20.2"
plsfix = "0.1.8"
diff --git a/rust/crates/photos/src/ml/events.rs b/rust/crates/photos/src/ml/events.rs
deleted file mode 100644
index 7ebdabc866..0000000000
--- a/rust/crates/photos/src/ml/events.rs
+++ /dev/null
@@ -1,88 +0,0 @@
-// Report ML fallbacks and quarantines even when the calling operation succeeds.
-
-use std::sync::Mutex;
-
-const MAX_BUFFERED_EVENTS: usize = 64;
-
-#[derive(Clone, Debug, PartialEq, Eq)]
-pub enum Severity {
- Info,
- Warning,
- Severe,
-}
-
-impl Severity {
- pub fn as_str(&self) -> &'static str {
- match self {
- Self::Info => "info",
- Self::Warning => "warning",
- Self::Severe => "severe",
- }
- }
-}
-
-#[derive(Clone, Debug)]
-pub struct MlRuntimeEvent {
- pub severity: Severity,
- pub message: String,
-}
-
-static EVENTS: Mutex<Vec<MlRuntimeEvent>> = Mutex::new(Vec::new());
-
-pub(crate) fn record(severity: Severity, message: String) {
- crate::ml::runtime::rt_log(&format!("[{}] {message}", severity.as_str()));
- let mut events = EVENTS
- .lock()
- .unwrap_or_else(|poisoned| poisoned.into_inner());
- if events
- .iter()
- .any(|event| event.severity == severity && event.message == message)
- {
- return;
- }
- if events.len() >= MAX_BUFFERED_EVENTS {
- events.remove(0);
- }
- events.push(MlRuntimeEvent { severity, message });
-}
-
-pub fn take_events() -> Vec<MlRuntimeEvent> {
- let mut events = EVENTS
- .lock()
- .unwrap_or_else(|poisoned| poisoned.into_inner());
- std::mem::take(&mut *events)
-}
-
-#[cfg(test)]
-mod tests {
- use super::{MAX_BUFFERED_EVENTS, Severity, record, take_events};
-
- // Keep this in one test because the process-global buffer is shared across
- // tests.
- #[test]
- fn records_in_order_drains_on_take_and_drops_oldest_when_full() {
- take_events();
- record(Severity::Info, "first".to_string());
- record(Severity::Severe, "second".to_string());
-
- let events = take_events();
- assert_eq!(events.len(), 2);
- assert_eq!(events[0].severity, Severity::Info);
- assert_eq!(events[0].message, "first");
- assert_eq!(events[1].severity, Severity::Severe);
- assert!(take_events().is_empty());
-
- record(Severity::Warning, "duplicate".to_string());
- record(Severity::Warning, "duplicate".to_string());
- let events = take_events();
- assert_eq!(events.len(), 1);
- assert_eq!(events[0].message, "duplicate");
-
- for index in 0..(MAX_BUFFERED_EVENTS + 3) {
- record(Severity::Info, format!("event {index}"));
- }
- let events = take_events();
- assert_eq!(events.len(), MAX_BUFFERED_EVENTS);
- assert_eq!(events[0].message, "event 3");
- }
-}
diff --git a/rust/crates/photos/src/ml/indexing.rs b/rust/crates/photos/src/ml/indexing.rs
index 3b916ec866..b58405c564 100644
--- a/rust/crates/photos/src/ml/indexing.rs
+++ b/rust/crates/photos/src/ml/indexing.rs
@@ -1,7 +1,6 @@
use crate::ml::{
clip::{run_clip_image, run_clip_text_query, tokenize_clip_text as tokenize_clip_text_impl},
error::{MlError, MlResult},
- events,
face::{
run_face_alignment, run_face_detection, run_face_embedding,
thumbnail::{FaceBox, generate_face_thumbnails},
@@ -129,13 +128,7 @@ pub fn analyze_image(req: AnalyzeImageRequest) -> MlResult<AnalyzeImageResult> {
match generate_face_thumbnails(&decoded, std::slice::from_ref(&face_box)) {
Ok(mut crops) => crops.pop(),
Err(error) => {
- events::record(
- events::Severity::Warning,
- format!(
- "skipping face crop for face {}: {error}",
- face.face_id
- ),
- );
+ log::warn!("skipping face crop for face {}: {error}", face.face_id);
None
}
}
diff --git a/rust/crates/photos/src/ml/mod.rs b/rust/crates/photos/src/ml/mod.rs
index c5e72de245..140e019846 100644
--- a/rust/crates/photos/src/ml/mod.rs
+++ b/rust/crates/photos/src/ml/mod.rs
@@ -1,7 +1,6 @@
pub mod assets;
mod clip;
pub mod error;
-pub mod events;
pub mod face;
pub mod golden;
mod golden_data;
diff --git a/rust/crates/photos/src/ml/onnx.rs b/rust/crates/photos/src/ml/onnx.rs
index 3f0d071557..014659f1f0 100644
--- a/rust/crates/photos/src/ml/onnx.rs
+++ b/rust/crates/photos/src/ml/onnx.rs
@@ -26,16 +26,7 @@ use ort::ep::{
use std::num::NonZeroUsize;
use crate::ml::error::{MlError, MlResult};
-use crate::ml::events;
use crate::ml::golden;
-#[cfg(any(
- target_os = "android",
- target_os = "ios",
- target_os = "linux",
- target_os = "macos",
- target_os = "windows"
-))]
-use crate::ml::runtime::rt_log;
#[cfg(any(target_os = "android", target_os = "linux", target_os = "windows"))]
use crate::ml::webgpu;
@@ -173,12 +164,9 @@ pub(crate) fn build_session(
if let Some(cache_dir) = coreml_cache_dir
&& let Err(cleanup_error) = invalidate_coreml_cache(&cache_dir)
{
- events::record(
- events::Severity::Warning,
- format!(
- "failed to invalidate CoreML cache for '{}' after session construction failed: {cleanup_error}",
- model_file_label(model_path)
- ),
+ log::warn!(
+ "failed to invalidate CoreML cache for '{}' after session construction failed: {cleanup_error}",
+ model_file_label(model_path)
);
}
errors.push(format!("{error}"));
@@ -314,7 +302,7 @@ fn record_provider_attempt_failure(
error: &MlError,
) {
if let Some(message) = provider_attempt_failure_message(provider, model_path, stage, error) {
- events::record(events::Severity::Warning, message);
+ log::warn!("{message}");
}
}
@@ -375,31 +363,23 @@ fn run_session_self_test(
let zero_output = match run_golden_tensor(session, entry.input_shape, &zero_input) {
Ok(output) => output,
Err(error) => {
- events::record(
- events::Severity::Warning,
- format!(
- "{provider_label} zero-input warm-up inference failed for '{model_file}': \
- {error}; falling back to the next execution provider"
- ),
+ log::warn!(
+ "{provider_label} zero-input warm-up inference failed for '{model_file}': \
+ {error}; falling back to the next execution provider"
);
return Err(error);
}
};
if let Err(reason) = golden::validate_output(entry, &zero_output) {
- events::record(
- events::Severity::Severe,
- format!(
- "{provider_label} zero-input warm-up failed for '{model_file}': {reason}; \
- falling back to the next execution provider"
- ),
+ log::error!(
+ "{provider_label} zero-input warm-up failed for '{model_file}': {reason}; \
+ falling back to the next execution provider"
);
return Err(MlError::Ort(format!(
"zero-input warm-up failed for '{model_file}': {reason}"
)));
}
- rt_log(&format!(
- "{provider_label} zero-input warm-up for '{model_file}' passed"
- ));
+ log::info!("{provider_label} zero-input warm-up for '{model_file}' passed");
let golden_output = match run_golden_tensor(session, entry.input_shape, &golden_input) {
Ok(output) => output,
@@ -407,32 +387,26 @@ fn run_session_self_test(
// Surface inference failures too: without this, a provider that
// cannot execute the golden input would fall back invisibly (the
// session-build error is swallowed once the next attempt succeeds).
- events::record(
- events::Severity::Warning,
- format!(
- "{provider_label} golden self-test inference failed for '{model_file}': \
- {error}; falling back to the next execution provider"
- ),
+ log::warn!(
+ "{provider_label} golden self-test inference failed for '{model_file}': \
+ {error}; falling back to the next execution provider"
);
return Err(error);
}
};
match golden::compare_output(entry, &golden_output) {
Ok(distance) => {
- rt_log(&format!(
+ log::info!(
"{provider_label} golden self-test for '{model_file}' passed \
({} {distance:.2e})",
entry.metric.label()
- ));
+ );
Ok(())
}
Err(reason) => {
- events::record(
- events::Severity::Severe,
- format!(
- "{provider_label} golden self-test failed for '{model_file}': {reason}; \
- falling back to the next execution provider"
- ),
+ log::error!(
+ "{provider_label} golden self-test failed for '{model_file}': {reason}; \
+ falling back to the next execution provider"
);
Err(MlError::Ort(format!(
"golden self-test failed for '{model_file}': {reason}"
@@ -573,12 +547,9 @@ fn coreml_provider(
prepared_cache_dir = Some(cache_dir);
}
Err(error) => {
- events::record(
- events::Severity::Warning,
- format!(
- "failed to prepare persistent CoreML cache for '{}'; continuing without it: {error}",
- model_file_label(model_path)
- ),
+ log::warn!(
+ "failed to prepare persistent CoreML cache for '{}'; continuing without it: {error}",
+ model_file_label(model_path)
);
}
}
@@ -599,15 +570,9 @@ fn remove_persistent_coreml_cache(model_path: &str) {
return;
};
match std::fs::remove_dir_all(&coreml_root) {
- Ok(()) => events::record(
- events::Severity::Info,
- "removed persistent CoreML cache (feature disabled)".to_string(),
- ),
+ Ok(()) => log::info!("removed persistent CoreML cache (feature disabled)"),
Err(error) if error.kind() == std::io::ErrorKind::NotFound => {}
- Err(error) => events::record(
- events::Severity::Warning,
- format!("failed to remove disabled persistent CoreML cache: {error}"),
- ),
+ Err(error) => log::warn!("failed to remove disabled persistent CoreML cache: {error}"),
}
}
@@ -672,12 +637,9 @@ fn golden_entry_required(model_path: &str, provider_label: &str) -> bool {
if golden::lookup(model_path).is_some() {
return true;
}
- events::record(
- events::Severity::Severe,
- format!(
- "no golden self-test entry for '{}'; {provider_label} disabled for this model",
- model_file_label(model_path)
- ),
+ log::error!(
+ "no golden self-test entry for '{}'; {provider_label} disabled for this model",
+ model_file_label(model_path)
);
false
}
@@ -718,16 +680,10 @@ fn prepare_coreml_cache_directory(
match prune_stale_coreml_schema_directories(coreml_root, COREML_CACHE_SCHEMA) {
Ok(removed) => {
for schema in removed {
- events::record(
- events::Severity::Info,
- format!("removed stale CoreML cache schema '{schema}'"),
- );
+ log::info!("removed stale CoreML cache schema '{schema}'");
}
}
- Err(error) => events::record(
- events::Severity::Warning,
- format!("failed to prune stale CoreML cache schemas: {error}"),
- ),
+ Err(error) => log::warn!("failed to prune stale CoreML cache schemas: {error}"),
}
}
@@ -756,30 +712,21 @@ fn prepare_coreml_cache_entry(cache_dir: &Path) -> std::io::Result<()> {
fn finalize_coreml_cache(cache_dir: &Path, model_path: &str) {
match trim_coreml_cache_weights(cache_dir) {
Ok(0) => {}
- Ok(reclaimed) => events::record(
- events::Severity::Info,
- format!(
- "primed CoreML cache for '{}': trimmed {} MiB of generated package weights",
- model_file_label(model_path),
- reclaimed / (1024 * 1024)
- ),
+ Ok(reclaimed) => log::info!(
+ "primed CoreML cache for '{}': trimmed {} MiB of generated package weights",
+ model_file_label(model_path),
+ reclaimed / (1024 * 1024)
),
- Err(error) => events::record(
- events::Severity::Warning,
- format!(
- "failed to trim CoreML cache weights for '{}': {error}",
- model_file_label(model_path)
- ),
+ Err(error) => log::warn!(
+ "failed to trim CoreML cache weights for '{}': {error}",
+ model_file_label(model_path)
),
}
if let Err(error) = mark_coreml_cache_complete(cache_dir) {
- events::record(
- events::Severity::Warning,
- format!(
- "failed to mark CoreML cache complete for '{}': {error}",
- model_file_label(model_path)
- ),
+ log::warn!(
+ "failed to mark CoreML cache complete for '{}': {error}",
+ model_file_label(model_path)
);
}
}
diff --git a/rust/crates/photos/src/ml/runtime.rs b/rust/crates/photos/src/ml/runtime.rs
index 2ad45a88a8..681e0e840e 100644
--- a/rust/crates/photos/src/ml/runtime.rs
+++ b/rust/crates/photos/src/ml/runtime.rs
@@ -11,29 +11,6 @@ use crate::ml::{
onnx,
};
-pub(crate) fn rt_log(msg: &str) {
- #[cfg(target_os = "android")]
- {
- unsafe extern "C" {
- unsafe fn __android_log_write(
- prio: std::ffi::c_int,
- tag: *const std::ffi::c_char,
- text: *const std::ffi::c_char,
- ) -> std::ffi::c_int;
- }
- use std::ffi::CString;
- let tag = CString::new("ml_rt").unwrap();
- let cmsg = CString::new(msg).unwrap_or_else(|_| CString::new("(invalid)").unwrap());
- unsafe {
- __android_log_write(4, tag.as_ptr(), cmsg.as_ptr());
- }
- }
- #[cfg(not(target_os = "android"))]
- {
- eprintln!("[ml][rt] {msg}");
- }
-}
-
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct ModelPaths {
pub face_detection: String,
@@ -206,12 +183,8 @@ impl ModelSlot {
return false;
}
- crate::ml::events::record(
- crate::ml::events::Severity::Warning,
- format!(
- "execution provider failed, retrying model with the next provider fallback: \
- {error}"
- ),
+ log::warn!(
+ "execution provider failed, retrying model with the next provider fallback: {error}"
);
true
}
@@ -254,13 +227,11 @@ impl ModelSlot {
let execution_mode = self.effective_execution_mode(state);
let model_name = state.path.rsplit('/').next().unwrap_or(&state.path);
- rt_log(&format!(
- "loading {model_name} with {execution_mode:?} execution"
- ));
+ log::info!("loading {model_name} with {execution_mode:?} execution");
let t = std::time::Instant::now();
let (session, execution_provider) =
onnx::build_session(&state.path, execution_mode, self.coreml_cache_namespace)?;
- rt_log(&format!("loaded {model_name} in {:?}", t.elapsed()));
+ log::info!("loaded {model_name} in {:?}", t.elapsed());
state.execution_provider = Some(execution_provider);
state.session = Some(session);
Ok(())
diff --git a/rust/crates/photos/src/ml/webgpu.rs b/rust/crates/photos/src/ml/webgpu.rs
index 93fac9ae94..70593346cb 100644
--- a/rust/crates/photos/src/ml/webgpu.rs
+++ b/rust/crates/photos/src/ml/webgpu.rs
@@ -93,9 +93,9 @@ pub(crate) fn check_adapter() -> AdapterCheck {
*VERDICT.get_or_init(|| match probe_vulkan_vendor_ids() {
Ok(vendor_ids) => {
let allowed = vendors_allowlisted(&vendor_ids);
- crate::ml::runtime::rt_log(&format!(
+ log::info!(
"Vulkan adapter vendor IDs {vendor_ids:#06x?}; WebGPU allowlisted: {allowed}"
- ));
+ );
if allowed {
AdapterCheck::Allowed
} else {
@@ -103,7 +103,7 @@ pub(crate) fn check_adapter() -> AdapterCheck {
}
}
Err(error) => {
- crate::ml::runtime::rt_log(&format!("Vulkan adapter probe failed: {error}"));
+ log::warn!("Vulkan adapter probe failed: {error}");
AdapterCheck::Failed
}
})
@@ -174,10 +174,10 @@ pub(crate) fn arm_canary(model_path: &str, model_namespace: &str) -> io::Result<
impl ArmedCanary {
pub(crate) fn disarm(self) {
if let Err(error) = remove_file_durably(&self.path) {
- crate::ml::runtime::rt_log(&format!(
+ log::warn!(
"failed to disarm WebGPU crash canary at '{}': {error}",
self.path.display()
- ));
+ );
}
}
}