From 6cdffda475a4310ee8aacfdc791a03cf66168273 Mon Sep 17 00:00:00 2001 From: jgrusewski Date: Sat, 21 Feb 2026 18:39:05 +0100 Subject: [PATCH] fix(ml): silence unsafe-code warnings on inference adapter Send/Sync impls MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add #[allow(unsafe_code)] on each unsafe impl Send/Sync for the four inference adapters (DQN, PPO, TFT, Mamba2). The SAFETY comments explain why these are sound — Mutex provides exclusive access. Co-Authored-By: Claude Opus 4.6 --- ml/src/ensemble/adapters/dqn.rs | 2 ++ ml/src/ensemble/adapters/mamba2.rs | 2 ++ ml/src/ensemble/adapters/ppo.rs | 2 ++ ml/src/ensemble/adapters/tft.rs | 2 ++ 4 files changed, 8 insertions(+) diff --git a/ml/src/ensemble/adapters/dqn.rs b/ml/src/ensemble/adapters/dqn.rs index 7653d85be..7bb50b112 100644 --- a/ml/src/ensemble/adapters/dqn.rs +++ b/ml/src/ensemble/adapters/dqn.rs @@ -26,7 +26,9 @@ pub struct DqnInferenceAdapter { // SAFETY: DQN internally uses candle tensors which are Send+Sync. // The Mutex provides exclusive access for inference calls. +#[allow(unsafe_code)] unsafe impl Send for DqnInferenceAdapter {} +#[allow(unsafe_code)] unsafe impl Sync for DqnInferenceAdapter {} impl DqnInferenceAdapter { diff --git a/ml/src/ensemble/adapters/mamba2.rs b/ml/src/ensemble/adapters/mamba2.rs index ba7deff71..7439b7402 100644 --- a/ml/src/ensemble/adapters/mamba2.rs +++ b/ml/src/ensemble/adapters/mamba2.rs @@ -37,7 +37,9 @@ pub struct Mamba2InferenceAdapter { // SAFETY: Mamba2SSM internally uses candle tensors which are Send+Sync. // The Mutex provides exclusive access for inference calls and buffer mutation. +#[allow(unsafe_code)] unsafe impl Send for Mamba2InferenceAdapter {} +#[allow(unsafe_code)] unsafe impl Sync for Mamba2InferenceAdapter {} impl Mamba2InferenceAdapter { diff --git a/ml/src/ensemble/adapters/ppo.rs b/ml/src/ensemble/adapters/ppo.rs index b6cbc8887..b84d67a80 100644 --- a/ml/src/ensemble/adapters/ppo.rs +++ b/ml/src/ensemble/adapters/ppo.rs @@ -28,7 +28,9 @@ pub struct PpoInferenceAdapter { // SAFETY: PPO internally uses candle tensors which are Send+Sync. // The Mutex provides exclusive access for inference calls. +#[allow(unsafe_code)] unsafe impl Send for PpoInferenceAdapter {} +#[allow(unsafe_code)] unsafe impl Sync for PpoInferenceAdapter {} impl PpoInferenceAdapter { diff --git a/ml/src/ensemble/adapters/tft.rs b/ml/src/ensemble/adapters/tft.rs index 5e6a51325..411a3a267 100644 --- a/ml/src/ensemble/adapters/tft.rs +++ b/ml/src/ensemble/adapters/tft.rs @@ -40,7 +40,9 @@ pub struct TftInferenceAdapter { // SAFETY: TemporalFusionTransformer internally uses candle tensors which // are Send+Sync. The Mutex provides exclusive access for inference calls. +#[allow(unsafe_code)] unsafe impl Send for TftInferenceAdapter {} +#[allow(unsafe_code)] unsafe impl Sync for TftInferenceAdapter {} impl TftInferenceAdapter {