diff --git a/crates/ml/src/ensemble/adapters/tft.rs b/crates/ml/src/ensemble/adapters/tft.rs index f6e9972b2..5f36005a9 100644 --- a/crates/ml/src/ensemble/adapters/tft.rs +++ b/crates/ml/src/ensemble/adapters/tft.rs @@ -453,32 +453,30 @@ mod tests { #[test] fn test_tft_adapter_deterministic() { let seq_len = 4; - // Create two adapters with identical configs - let adapter1 = TftInferenceAdapter::new(test_config(), seq_len) - .expect("adapter1 creation"); - let adapter2 = TftInferenceAdapter::new(test_config(), seq_len) - .expect("adapter2 creation"); + // Test: same model, same input → same output (GPU determinism) + let adapter = TftInferenceAdapter::new(test_config(), seq_len) + .expect("adapter creation"); - // Feed identical sequences + // Fill the buffer for i in 0..seq_len { let fv = make_fv(1_700_000_000 + i as i64); - let _ = adapter1.predict(&fv); - let _ = adapter2.predict(&fv); + let _ = adapter.predict(&fv); } - // The final prediction after filling the buffer should be identical + // Two predictions with the same input on the same model let fv = make_fv(1_700_000_000 + seq_len as i64); - let pred1 = adapter1.predict(&fv).expect("adapter1 predict"); - let pred2 = adapter2.predict(&fv).expect("adapter2 predict"); + let pred1 = adapter.predict(&fv).expect("predict 1"); + let pred2 = adapter.predict(&fv).expect("predict 2"); + // Same model + same input → must produce identical output assert!( - (pred1.direction - pred2.direction).abs() < 0.15, - "Deterministic predictions should be close: {} vs {}", + (pred1.direction - pred2.direction).abs() < 1e-6, + "Same-model predictions diverged: {} vs {}", pred1.direction, pred2.direction ); assert!( - (pred1.confidence - pred2.confidence).abs() < 0.15, - "Deterministic predictions should be close: {} vs {}", + (pred1.confidence - pred2.confidence).abs() < 1e-6, + "Same-model confidences diverged: {} vs {}", pred1.confidence, pred2.confidence ); }