chore: remove dead code — candle aliases, empty shim modules

Deleted:
- 7 dead _candle suffix functions in GpuTensor (zero callers)
- gradient_utils.rs (empty 12-line placeholder)
- gradient_accumulation.rs (empty 12-line placeholder)
- optimizers/adam.rs + optimizers/mod.rs (empty 12-line placeholders)
- Re-exports of above from ml crate

Total: 88 lines of dead code removed, 0 functionality lost.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
jgrusewski
2026-03-20 11:51:59 +01:00
parent 9bee8e9483
commit 2aedf7cb85
7 changed files with 1 additions and 98 deletions

View File

@@ -289,62 +289,7 @@ impl GpuTensor {
}
// -----------------------------------------------------------------------
// Legacy `_candle` suffix aliases for migration compatibility.
// These forward to the canonical methods above.
// -----------------------------------------------------------------------
/// Alias for `randn()` — legacy name from candle migration.
pub fn randn_candle(shape: &[usize], std_dev: f32, stream: &Arc<CudaStream>) -> Result<Self, MLError> {
Self::randn(shape, std_dev, stream)
}
/// Alias for `zeros()` — accepts various shape types for candle compat.
pub fn zeros_candle(shape: &[usize], stream: &Arc<CudaStream>) -> Result<Self, MLError> {
Self::zeros(shape, stream)
}
/// Alias for `scalar()` — accepts `(value, ignored)` for candle migration compat.
/// The second argument is ignored (was candle Device).
pub fn scalar_candle<V: ScalarValue, D>(_value: V, _device: D) -> Result<Self, MLError> {
// Without a stream we cannot allocate. Return a CPU-side error.
// Callers should migrate to scalar() with explicit stream.
Err(MLError::ModelError(
"scalar_candle: migrate to scalar() with explicit Arc<CudaStream>".to_string()
))
}
/// Alias for `eye()` — accepts `(n, ignored_dtype, ignored_device)` for candle compat.
pub fn eye_candle<D1, D2>(_n: usize, _dtype: D1, _device: D2) -> Result<Self, MLError> {
Err(MLError::ModelError(
"eye_candle: migrate to eye() with explicit Arc<CudaStream>".to_string()
))
}
/// Alias for `from_host()` — legacy name from candle migration.
pub fn from_vec_candle<S: Into<Vec<usize>>, D>(_data: Vec<f32>, _shape: S, _device: D) -> Result<Self, MLError> {
Err(MLError::ModelError(
"from_vec_candle: migrate to from_host() with explicit Arc<CudaStream>".to_string()
))
}
/// Alias for `from_host()` — legacy name from candle migration.
pub fn from_slice_candle<S: Into<Vec<usize>>>(data: &[f32], shape: S, stream: &Arc<CudaStream>) -> Result<Self, MLError> {
Self::from_host(data, shape.into(), stream)
}
/// Alias for `stack()` — legacy name from candle migration.
pub fn stack_candle(_tensors: &[Self], _dim: usize) -> Result<Self, MLError> {
Err(MLError::ModelError(
"stack_candle: use stack() with explicit stream instead".to_string()
))
}
/// Alias for `cat()` — legacy name from candle migration.
pub fn cat_candle(_tensors: &[&Self], _dim: usize) -> Result<Self, MLError> {
Err(MLError::ModelError(
"cat_candle: use cat() with explicit stream instead".to_string()
))
}
// _candle suffix aliases removed — migration complete, zero callers remain.
// -----------------------------------------------------------------------
// Tensor algebra: element-wise ops, reductions, slicing.

View File

@@ -1,12 +0,0 @@
//! Gradient accumulation utilities (legacy shim).
//!
//! The Candle-based gradient accumulation functions (which operated on
//! `candle_core::backprop::GradStore` and `candle_core::Var`) have been removed.
//!
//! GPU gradient accumulation is now handled by `cuda_autograd::GpuAdamW` via
//! `BTreeMap<String, GpuTensor>` gradient maps. For accumulation across
//! micro-batches, callers should accumulate `GpuTensor` gradients directly
//! using element-wise addition on GPU.
//!
//! This module is kept as an empty placeholder so that `pub mod gradient_accumulation`
//! in `lib.rs` compiles.

View File

@@ -1,12 +0,0 @@
//! Gradient utilities (legacy shim).
//!
//! The Candle-based gradient clipping and NaN detection functions have been
//! removed. GPU gradient operations are now handled by:
//!
//! - `cuda_autograd::GpuAdamW` — built-in gradient norm clipping per step.
//! - Loss functions in `cuda_autograd::LossKernels` — produce gradient tensors
//! directly, no separate `GradStore`.
//!
//! This module is kept as an empty placeholder so that `pub mod gradient_utils`
//! in `lib.rs` compiles. Downstream crates should migrate to the cuda_autograd
//! equivalents.

View File

@@ -128,9 +128,6 @@ pub mod model;
pub mod traits;
// ========== COMPUTE PRIMITIVES (moved from ml in task 5b) ==========
pub mod optimizers;
pub mod gradient_accumulation;
pub mod gradient_utils;
pub mod tensor_ops;
pub mod gpu;
pub mod safety;

View File

@@ -1,8 +0,0 @@
//! Adam optimizer (legacy shim).
//!
//! The Candle-based `Adam` wrapper has been removed. All GPU optimization
//! now uses `cuda_autograd::GpuAdamW` which runs entirely on GPU via CUDA
//! kernels. This module is kept as an empty placeholder so that
//! `pub mod adam` in `optimizers/mod.rs` does not fail.
//!
//! Downstream crates should migrate to `ml_core::cuda_autograd::GpuAdamW`.

View File

@@ -1,4 +0,0 @@
pub mod adam;
// Note: The Candle-based `Adam` struct has been removed.
// GPU optimization now uses `crate::cuda_autograd::GpuAdamW`.

View File

@@ -178,9 +178,6 @@ pub use ml_core::model;
pub use ml_core::traits;
// Compute primitives re-exported from ml-core (task 5b)
pub use ml_core::optimizers;
pub use ml_core::gradient_accumulation;
pub use ml_core::gradient_utils;
pub use ml_core::tensor_ops;
pub use ml_core::gpu;
pub use ml_core::safety;