Repository navigation
Getting Started
TensorPlay is built to be read: every step from the Python API down to the C++ core is code you can trace, run, and modify. This page gets a working installation on your machine and runs the first examples.
pip install tensorplay --upgradeCUDA wheels are published to the TensorPlay wheel index and are picked per CUDA major version:
# CUDA 13.0
pip install tensorplay --index-url https://download.tensorplay.cn/whl/cu130/ --extra-index-url https://pypi.org/simplepip install --pre tensorplay --index-url https://download.tensorplay.cn/whl/nightly/cpu/ --extra-index-url https://pypi.org/simpleNightly versions follow X.Y.0.dev<UTC date> with a +cpu or +cuXXX local tag.
| Requirement | Version / Notes |
|---|---|
| Python | >= 3.10, < 3.14 |
| CMake | >= 3.18, < 4.0 |
| C++ compiler | C++20 capable (MSVC 2022, GCC, or Clang) |
| CUDA Toolkit | optional, auto-detected |
| ROCm | optional (7.2.x), mutually exclusive with CUDA |
| Ninja | required on Windows |
git clone https://github.com/lexing-2026/TensorPlay.git
cd TensorPlay
pip install -r requirements-build.txt
pip install . # full build
pip install -e . --no-build-isolation # editable install for kernel developmentThe version number comes from the single source of truth version.txt; development installs carry a +git<sha> suffix.
Options are passed as environment variables — no -D CMake flags needed:
| Variable | Effect |
|---|---|
USE_CUDA=OFF |
CPU-only build |
USE_ROCM=ON |
AMD/HIP backend (exclusive with CUDA) |
CMAKE_CUDA_ARCHITECTURES |
e.g. "70;75;86"
|
BUILD_TESTS=ON |
also build the C++ test suite |
MAX_JOBS |
cap compile parallelism |
DEBUG |
debug build |
import tensorplay as tp
x = tp.Tensor([[1.0, 2.0], [3.0, 4.0]], requires_grad=True)
y = tp.Tensor([[5.0, 6.0], [7.0, 8.0]], requires_grad=True)
z = x.matmul(y) + tp.ones_like(x)
loss = z.sum()
loss.backward()
print(x.grad) # [[6., 6.], [6., 6.]]Under the hood, TPX records each operation into an explicit DAG and replays the chain rule node by node — every edge of that graph is code you can step through. See Architecture.
import tensorplay as tp
from tensorplay.nn import Module, Linear, ReLU, Sigmoid
class MLP(Module):
def __init__(self, input_dim: int, hidden_dim: int, output_dim: int):
super().__init__()
self.fc1 = Linear(input_dim, hidden_dim)
self.relu = ReLU()
self.fc2 = Linear(hidden_dim, output_dim)
self.sigmoid = Sigmoid()
def forward(self, x: tp.Tensor) -> tp.Tensor:
x = self.relu(self.fc1(x))
return self.sigmoid(self.fc2(x))
model = MLP(10, 32, 1)
print(model) # auto-generated architecture visualizationfrom tensorplay.data import DataLoader, TensorDataset
train_data = TensorDataset(tp.randn(100, 10), tp.randn(100, 1))
train_loader = DataLoader(dataset=train_data, batch_size=8, shuffle=True)
for batch_x, batch_y in train_loader:
predictions = model(batch_x)
# ... compute loss, call loss.backward(), step the optimizer- Structured tutorials (linear regression from scratch, MNIST CNN, custom datasets,
.megaserialization): tensorplay.cn - Component deep dives: Architecture
- Common issues: FAQ
- Contribution workflow: CONTRIBUTING.md
A learner-friendly, DIY-ready deep learning framework.
Documentation · Getting Started · Issues · Discussions · Discord · Releases
© 2026 TensorPlay contributors · Licensed under Apache 2.0
Getting started
Project
Deep dives
Community
Core components
-
tensorplay— Python API -
p10— C++ core -
tpx— autograd -
stax— JIT compiler