autograd: tape engine + grad accumulation
Var = Rc<RefCell<VarNode>> on a define-by-run tape: value + optional grad + parents + backward closure. backward() seeds a scalar loss, walks reverse topo order, and pushes grads to parents. push_grad always SUMs into the grad slot — the fan-out accumulation path T3 lacked. Per-crate build.rs emits the no_cuda cfg (does not propagate); engine gated, grad_check stays host-only. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -13,3 +13,14 @@
|
||||
pub mod finite_diff;
|
||||
|
||||
pub use finite_diff::{GradCheckConfig, GradCheckResult, ParamFn, grad_check};
|
||||
|
||||
// Tape-based autograd engine + differentiable ops (Phase T4). These call GPU
|
||||
// kernels via xtrain-tensor, so they are gated behind `not(no_cuda)` (the
|
||||
// per-crate convention); the grad_check harness above stays host-only.
|
||||
#[cfg(not(no_cuda))]
|
||||
pub mod ops;
|
||||
#[cfg(not(no_cuda))]
|
||||
pub mod tape;
|
||||
|
||||
#[cfg(not(no_cuda))]
|
||||
pub use tape::Var;
|
||||
|
||||
Reference in New Issue
Block a user