COOLJAPAN
← All posts

ToRSh 0.2.0 Released — Real Autograd Gradients, a Single Pure-Rust CUDA Stack, and No More Fabricated Success

ToRSh 0.2.0 completes autograd backward coverage, consolidates GPU compute onto the pure-Rust oxicuda stack, ships full NumPy/pandas/SciPy interop and PyTorch-compatible LR schedulers, and replaces fabricated success paths with honest errors. 10,638 tests passing. The sovereign deep-learning layer for COOLJAPAN.

release torsh deep-learning pytorch python rust pure-rust autograd cuda gpu security

A GPU buffer copy that silently reports success without moving a byte is worse than a crash — a crash tells you something is wrong.

Today we released ToRSh 0.2.0 — the production-hardening release. Two threads converge here: a Python-bindings push that makes ToRSh’s rstorch package genuinely PyTorch-compatible, and a 13-agent audit that went crate by crate looking for exactly the class of bug the opening line describes — code that looks like it succeeded and didn’t.

ToRSh — “Tensor Operations in Rust with Sharding” — is a PyTorch-compatible deep-learning framework built entirely in pure Rust. No C. No C++. No Fortran. No Python runtime required to run inference. Where PyTorch depends on libtorch/ATen, a full CUDA toolchain, and a Python interpreter, ToRSh compiles to a single static binary you can ship to bare metal, a container, or WASM with nothing else installed. As of 0.2.0, the CUDA story is also unified: the legacy CUDA C-FFI backend — and its cust, cuda-sys, and cudnn-sys dependencies — is gone. Every GPU path now runs through the pure-Rust OxiCUDA stack.

Why ToRSh 0.2.0 is a game changer

Machine-learning frameworks tend to fail in one particular way: silently. A gradient that’s quietly zero instead of computed. A buffer copy that reports success without moving any data. A distributed barrier that’s secretly a no-op because a handle was dropped too early. A state_dict() that hands back an empty placeholder instead of your optimizer’s real momentum buffers. None of these crash. Your training run finishes, the loss curve looks plausible, and the bug ships.

ToRSh 0.2.0 goes after exactly that class of bug:

Technical Deep Dive: hardening the stack

The autograd layer. torsh-autograd fills in the backward passes that were silently short-circuiting: mul/div/matmul/cat/stack/narrow/log_softmax all get real gradient implementations. HyperparameterOptimizer now computes real first-order gradients via central finite differences instead of unconditionally returning zero, so gradient-based hyperparameter search can actually move a hyperparameter toward its optimum.

The GPU layer. With the legacy CUDA C-FFI backend removed, torsh-tensor’s runtime-loaded GpuDispatch is the only path to the GPU, backed by the OxiCUDA stack (oxicuda-backend/driver/launch/ptx, bumped to 0.5.4). torsh-backend’s cuda feature is now an honest pure-Rust fallback: unsupported ops return a clear error or route to CPU, rather than silently degrading.

The Python bindings layer. torsh-python migrates to pyo3 0.29 (numpy 0.29, scirs2-numpy 0.6.0), which exposed — and let us fix — a signature-annotation gap where 31 tensor-creation and reduction methods required every optional argument to be passed explicitly. On top of that: real Tensor operator overloads (__add__, __sub__, __mul__, __truediv__, __matmul__, __neg__), a rstorch.optim.lr_scheduler submodule with 6 PyTorch-compatible schedulers, and a full NumPy/pandas/SciPy interop bridge in torsh-ffi — tensor↔ndarray conversion, DataFrame↔tensor plus merge/pivot/time-series helpers, and SciPy solve/eig/svd/minimize/fft bindings that were previously all placeholder stubs returning “not implemented.”

The security layer. Archive extraction in torsh-hub / torsh-package is now hardened against path-traversal (tar-slip / zip-slip) — entry paths are validated and rejected if they’d escape the destination directory. Downloaded and unpacked artifacts get integrity checks against tampering or truncation. Package signing runs through pure-Rust ed25519-dalek — no C/asm crypto anywhere in the path.

Getting Started

cargo add torsh

# Enable the GPU backend (runtime CUDA driver load via OxiCUDA — no SDK required at build time)
cargo add torsh --features cuda
use torsh::prelude::*;

fn main() -> Result<()> {
    let x = tensor![[1.0, 2.0], [3.0, 4.0]].requires_grad();
    let y = x.matmul(&x)?;   // matmul now has a real backward gradient
    let loss = y.sum()?;
    loss.backward()?;
    println!("grad: {:?}", x.grad());
    Ok(())
}

From Python, the bindings now feel like PyTorch:

import rstorch
from rstorch.optim.lr_scheduler import CosineAnnealingLR

x = rstorch.randn(4, 4, requires_grad=True)
y = x @ x                       # __matmul__ operator overload
loss = y.sum()
loss.backward()

opt = rstorch.optim.Adam([x], lr=0.01)
scheduler = CosineAnnealingLR(opt, T_max=100)
opt.step()
scheduler.step()

checkpoint = opt.state_dict()   # real momentum / exp_avg buffers, not a placeholder

What’s New in 0.2.0

Added

Changed

Fixed

Security

Removed

Tips

This is the foundation

ToRSh 0.2.0 is powered by — and in turn powers — the wider COOLJAPAN ecosystem:

Repository: https://github.com/cool-japan/torsh

Star the repo if a deep-learning framework that would rather return an honest Err than a fabricated success is something you want more of.

The era of ML frameworks that fail silently is over. Pure Rust deep learning is here — fast, safe, and sovereign.

KitaSan at COOLJAPAN OÜ
August 14, 2026

↑ Back to all posts