fix(ml): resolve all 12 warnings in diffusion, liquid, ensemble modules
- Remove unused imports: DType (noise, sampler), Device (candle_cfc), TimeZone (coordinator) - Add Debug impls for diffusion structs (manual for candle types, derive for DDIMSampler) - Fix hidden lifetime params: VarBuilder → VarBuilder<'_> in denoiser.rs Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -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<Self, MLError> {
|
||||
pub fn new(embed_dim: usize, hidden_dim: usize, vb: VarBuilder<'_>) -> Result<Self, MLError> {
|
||||
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<Self, MLError> {
|
||||
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<Self, MLError> {
|
||||
let time_embed = TimeEmbedding::new(time_embed_dim, hidden_dim, vb.pp("time_embed"))?;
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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<Self, MLError> {
|
||||
let var_map = VarMap::new();
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user