diff --git a/ml/src/diffusion/denoiser.rs b/ml/src/diffusion/denoiser.rs index 4678bc70b..6722f0e54 100644 --- a/ml/src/diffusion/denoiser.rs +++ b/ml/src/diffusion/denoiser.rs @@ -17,8 +17,14 @@ pub struct TimeEmbedding { embed_dim: usize, } +impl std::fmt::Debug for TimeEmbedding { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("TimeEmbedding").finish_non_exhaustive() + } +} + impl TimeEmbedding { - pub fn new(embed_dim: usize, hidden_dim: usize, vb: VarBuilder) -> Result { + pub fn new(embed_dim: usize, hidden_dim: usize, vb: VarBuilder<'_>) -> Result { let proj = linear(embed_dim, hidden_dim, vb.pp("time_proj")) .map_err(|e| MLError::ModelError(e.to_string()))?; Ok(Self { proj, embed_dim }) @@ -71,12 +77,18 @@ struct DenoiserBlock { has_residual: bool, } +impl std::fmt::Debug for DenoiserBlock { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("DenoiserBlock").finish_non_exhaustive() + } +} + impl DenoiserBlock { fn new( input_dim: usize, hidden_dim: usize, time_dim: usize, - vb: VarBuilder, + vb: VarBuilder<'_>, ) -> Result { let fc1 = linear(input_dim, hidden_dim, vb.pp("fc1")) .map_err(|e| MLError::ModelError(e.to_string()))?; @@ -133,13 +145,19 @@ pub struct Denoiser { device: Device, } +impl std::fmt::Debug for Denoiser { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("Denoiser").finish_non_exhaustive() + } +} + impl Denoiser { pub fn new( data_dim: usize, hidden_dim: usize, num_layers: usize, time_embed_dim: usize, - vb: VarBuilder, + vb: VarBuilder<'_>, device: &Device, ) -> Result { let time_embed = TimeEmbedding::new(time_embed_dim, hidden_dim, vb.pp("time_embed"))?; diff --git a/ml/src/diffusion/noise.rs b/ml/src/diffusion/noise.rs index 8381e1996..c6433ef91 100644 --- a/ml/src/diffusion/noise.rs +++ b/ml/src/diffusion/noise.rs @@ -4,7 +4,7 @@ //! forward process (add noise) operations. use crate::MLError; -use candle_core::{DType, Device, Tensor}; +use candle_core::{Device, Tensor}; use super::config::NoiseSchedule; @@ -19,6 +19,12 @@ pub struct NoiseScheduler { device: Device, } +impl std::fmt::Debug for NoiseScheduler { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("NoiseScheduler").finish_non_exhaustive() + } +} + impl NoiseScheduler { /// Create a new noise scheduler with precomputed schedule. pub fn new( @@ -139,6 +145,7 @@ impl NoiseScheduler { #[cfg(test)] mod tests { use super::*; + use candle_core::DType; #[test] fn test_linear_schedule_decreasing() { diff --git a/ml/src/diffusion/sampler.rs b/ml/src/diffusion/sampler.rs index 7b1dbe464..94ae0b1a8 100644 --- a/ml/src/diffusion/sampler.rs +++ b/ml/src/diffusion/sampler.rs @@ -4,7 +4,7 @@ //! using a small number of steps (e.g., 10) instead of the full T=1000. use crate::MLError; -use candle_core::{DType, Device, Tensor}; +use candle_core::{Device, Tensor}; use super::denoiser::Denoiser; use super::noise::NoiseScheduler; @@ -14,6 +14,7 @@ use super::noise::NoiseScheduler; /// Given a trained denoiser and noise scheduler, generates samples /// by iteratively denoising from pure noise using uniformly spaced /// timestep subsequence. +#[derive(Debug)] pub struct DDIMSampler { /// Number of DDIM steps (much less than training timesteps). num_steps: usize, @@ -142,6 +143,7 @@ impl DDIMSampler { mod tests { use super::*; use super::super::config::{DiffusionConfig, NoiseSchedule}; + use candle_core::DType; use candle_nn::{VarBuilder, VarMap}; fn make_test_components() -> (Denoiser, NoiseScheduler, DDIMSampler) { diff --git a/ml/src/diffusion/trainable.rs b/ml/src/diffusion/trainable.rs index ee5476f85..ad0503566 100644 --- a/ml/src/diffusion/trainable.rs +++ b/ml/src/diffusion/trainable.rs @@ -31,6 +31,12 @@ pub struct DiffusionTrainableAdapter { config: DiffusionConfig, } +impl std::fmt::Debug for DiffusionTrainableAdapter { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("DiffusionTrainableAdapter").finish_non_exhaustive() + } +} + impl DiffusionTrainableAdapter { pub fn new(config: DiffusionConfig, device: Device) -> Result { let var_map = VarMap::new(); diff --git a/ml/src/ensemble/coordinator.rs b/ml/src/ensemble/coordinator.rs index e9e042af5..0c7c545c4 100644 --- a/ml/src/ensemble/coordinator.rs +++ b/ml/src/ensemble/coordinator.rs @@ -10,7 +10,7 @@ use crate::ensemble::conviction_gates::{ use crate::ensemble::inference_adapter::{FeatureVector, ModelInferenceAdapter}; use crate::ensemble::{EnsembleDecision, ModelVote, ModelWeight, TradingAction}; use crate::{Features, MLError, MLResult, ModelPrediction}; -use chrono::{DateTime, TimeZone, Timelike, Utc}; +use chrono::{DateTime, Timelike, Utc}; use chrono_tz::America::New_York; use std::collections::HashMap; use std::sync::Arc; @@ -713,6 +713,7 @@ impl Default for SignalAggregator { #[cfg(test)] mod tests { use super::*; + use chrono::TimeZone; #[tokio::test] async fn test_ensemble_coordinator_creation() { diff --git a/ml/src/liquid/candle_cfc.rs b/ml/src/liquid/candle_cfc.rs index 516def039..7f76741d8 100644 --- a/ml/src/liquid/candle_cfc.rs +++ b/ml/src/liquid/candle_cfc.rs @@ -4,7 +4,7 @@ //! This is the training path; the existing FixedPoint implementation in cells.rs/network.rs //! remains the production inference path. -use candle_core::{DType, Device, Tensor}; +use candle_core::{DType, Tensor}; use candle_nn::{Linear, Module, VarBuilder}; use serde::{Deserialize, Serialize}; @@ -334,7 +334,7 @@ impl CandleCfCNetwork { #[cfg(test)] mod tests { use super::*; - use candle_core::DType; + use candle_core::{DType, Device}; use candle_nn::VarMap; #[test]