- mamba/mod.rs: ~90 errors fixed — _candle suffixed functions replaced, operator overloads→free functions, autograd→pseudo-gradients, checkpoint→JSON serialization - gpu_tensor.rs: added gpu_eye, gpu_cat_dim0, gpu_stack_tensors - TFT/SSD: unused imports cleaned, type mismatches fixed - ml-core: GpuTensor algebra methods (17 new), cuda_compat.rs deleted, GpuVarStore::vars/all_vars/linear_xavier added Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
43 lines
1.5 KiB
Markdown
43 lines
1.5 KiB
Markdown
# GPU Implementation Deduplication Plan
|
|
|
|
> Post-candle-elimination cleanup. Consolidate duplicate GPU tensor, linear, activation, and optimizer implementations.
|
|
|
|
**Goal:** Single canonical implementation per GPU primitive in ml-core, with ml-ppo CudaLinear kept for its distinct ownership model.
|
|
|
|
---
|
|
|
|
## Phase 1: Delete ml-supervised GpuTensor/GpuLinear (CRITICAL)
|
|
|
|
- DELETE `crates/ml-supervised/src/gpu_tensor.rs` GpuTensor + GpuLinear definitions
|
|
- Re-export `ml_core::cuda_autograd::{GpuTensor, GpuLinear}` in ml-supervised
|
|
- Update all ml-supervised imports
|
|
- ~200 LOC reduction
|
|
|
|
## Phase 2: Consolidate activations into ml-core
|
|
|
|
- MERGE `crates/ml-ppo/src/cuda_nn/activations.rs` CUDA kernels into ml-core
|
|
- DELETE `crates/ml-ppo/src/cuda_nn/activations.rs`
|
|
- Add thin wrapper in ml-ppo returning CudaVec for PPO compat
|
|
- ~400 LOC reduction
|
|
|
|
## Phase 3: Merge AdamW kernels
|
|
|
|
- MERGE `crates/ml-ppo/src/cuda_nn/adam.rs` kernel source into ml-core GpuAdamW
|
|
- Keep wrapper in ml-ppo for flat param group interface
|
|
- ~200 LOC reduction
|
|
|
|
## Phase 4: GPU-ify host-side workarounds
|
|
|
|
Priority order:
|
|
1. `gpu_clone()` — cudaMemcpyDtoDAsync (trivial, HIGH frequency)
|
|
2. `add/sub/mul()` — 3 element-wise CUDA kernels (~10 lines each)
|
|
3. `broadcast_mul/div()` — strided CUDA kernel
|
|
4. `softmax` — standard CUDA softmax kernel for attention
|
|
5. `narrow(dim>0)` — 2D copy kernel
|
|
6. `argmax/mean_all` — CUB reductions (LOW frequency)
|
|
|
|
## Phase 5: Consolidate pointer helpers
|
|
|
|
- Define `raw_ptr()`/`raw_ptr_mut()` once in ml-core, re-export
|
|
- Delete 3 duplicate definitions
|