TensorStudio is a compact C++ tensor and autograd engine with a Python API for learning, experimentation, and lightweight ML workloads.
Project description
TensorStudio
TensorStudio is a compact C++ tensor and autograd engine with a Python API for learning, experimentation, and lightweight ML workloads.
TensorStudio 1.0.0 is a CPU-only stable API foundation. It is eager-only,
intentionally small, and not a replacement for mature ML frameworks.
Install
From PyPI:
python -m pip install tensorstudio
From a source checkout:
python -m pip install -U pip
python -m pip install -e ".[dev]"
Build source and wheel distributions:
python -m build
python -m twine check dist/*
End users should install wheels and should not need CMake. Source builds require a C++20 compiler because the native extension is implemented in C++.
Platform Setup
Windows is the primary release target. Use Python from python.org and install Microsoft C++ Build Tools or Visual Studio with the Desktop development with C++ workload before building from source:
python -m pip install -U pip
python -m pip install -e ".[dev]"
pytest -q
Linux source builds need GCC or Clang, CMake, and Python development headers:
python -m pip install -U pip
python -m pip install -e ".[dev]"
pytest -q
macOS source builds need Xcode Command Line Tools:
xcode-select --install
python -m pip install -U pip
python -m pip install -e ".[dev]"
pytest -q
Quickstart
import tensorstudio as ts
x = ts.tensor([[1.0, 2.0], [3.0, 4.0]])
y = ts.ones((2, 2))
print((x + y).tolist())
print((x @ y).numpy())
print(x.reshape((4,)).tolist())
Tensor API
TensorStudio supports CPU tensors with float32, float64, int32, int64,
and bool dtypes.
import tensorstudio as ts
ts.manual_seed(7)
a = ts.zeros((2, 3))
b = ts.rand((2, 3))
c = ts.eye(3)
d = ts.linspace(0.0, 1.0, 5)
print(a.shape, a.strides, a.device, a.is_contiguous)
print((b.clamp(0.2, 0.8) + 1).mean().item())
print(c.tolist(), d.tolist())
print(ts.zeros_like(b).shape, ts.randn_like(b, seed=11).dtype)
Autograd
import tensorstudio as ts
x = ts.tensor([1.0, 2.0, 3.0], requires_grad=True)
loss = (x * x).mean()
loss.backward()
print(x.grad.tolist())
Use no_grad() when you want eager computation without recording a graph:
with ts.no_grad():
y = x * 2
Neural Networks
import tensorstudio as ts
from tensorstudio import nn, optim
ts.manual_seed(0)
model = nn.Sequential(nn.Linear(1, 8), nn.Tanh(), nn.Linear(8, 1))
optimizer = optim.SGD(model.parameters(), lr=0.05, momentum=0.9)
scheduler = optim.StepLR(optimizer, step_size=50, gamma=0.5)
criterion = nn.MSELoss()
x = ts.tensor([[0.0], [1.0], [2.0], [3.0]])
y = ts.tensor([[1.0], [3.0], [5.0], [7.0]])
for _ in range(100):
optimizer.zero_grad()
loss = criterion(model(x), y)
loss.backward()
optim.clip_grad_norm_(model.parameters(), max_norm=10.0)
optimizer.step()
scheduler.step()
print(loss.item())
print(model.state_dict().keys())
print(model.parameter_count())
DataLoader
import tensorstudio as ts
from tensorstudio.data import DataLoader, TensorDataset
dataset = TensorDataset(ts.arange(6).reshape((6, 1)), ts.arange(6))
loader = DataLoader(dataset, batch_size=2, shuffle=True, seed=42)
for features, targets in loader:
print(features.shape, targets.shape)
The v1 DataLoader is intentionally single-process so it works cleanly on Windows without multiprocessing setup.
Performance
TensorStudio is optimized for small-to-medium CPU eager workloads, but
performance is still experimental. Benchmarks live in benchmarks/ and can be
run locally:
python benchmarks/benchmark_report.py
On one Windows CPython 3.10 run for 1.0.0, TensorStudio beat NumPy on 13
small activation/reduction benchmark cases and lost on 76 NumPy-comparable
cases. Against PyTorch CPU 2.12.1+cpu, TensorStudio won 68 local cases and
lost 26. The strongest local wins were small eager operations where framework
dispatch overhead dominates; larger matrix multiplication, larger transcendental
activations, and larger autograd workloads remain faster in PyTorch and NumPy.
See benchmarks/results.md for the full table, platform details, and exact
timings.
Snapshot from that local run:
| operation | shape | TensorStudio | NumPy | PyTorch CPU | TS vs NumPy | TS vs PyTorch |
|---|---|---|---|---|---|---|
sigmoid |
(32,) |
0.0018 ms | 0.0049 ms | 0.0638 ms | 2.7548x | 35.6408x |
mean |
(32,) |
0.0016 ms | 0.0071 ms | 0.0110 ms | 4.3608x | 6.7855x |
chain_relu |
(128,) |
0.0089 ms | 0.0039 ms | 0.0545 ms | 0.4410x | 6.1384x |
matmul |
(256, 256) |
3.0180 ms | 0.4115 ms | 0.1392 ms | 0.1363x | 0.0461x |
elementwise_backward |
(1024,) |
2.3844 ms | n/a | 0.1830 ms | n/a | 0.0767x |
Speedup is competitor median / TensorStudio median, so values above 1.0x
favor TensorStudio.
Do not treat these results as universal. TensorStudio does not claim to be faster than NumPy, TensorFlow, PyTorch, or JAX overall.
Save And Load
import tensorstudio as ts
from tensorstudio import nn
model = nn.Linear(2, 1)
ts.save({"model": model.state_dict()}, "checkpoint.tsmodel")
checkpoint = ts.load("checkpoint.tsmodel")
Serialization uses pickle. Loading pickle files from untrusted sources is unsafe because pickle can execute arbitrary code.
Development
python -m pip install -e ".[dev,docs]"
ruff check .
mypy python/tensorstudio
pytest -q
python -m build
python -m twine check dist/*
The native extension module is tensorstudio._C, built with CMake, pybind11,
scikit-build-core, and C++20.
Release Checklist
ruff check .passes.mypy python/tensorstudiopasses.pytest -qpasses on Windows, Linux, and macOS.python -m buildpasses.python -m twine check dist/*passes.- Benchmarks are generated and performance claims match the data.
- Clean wheel installs pass on Windows, Linux, and macOS.
- Clean sdist installs pass on Windows, Linux, and macOS.
- Examples run on all platforms.
- Docs match the implemented feature set.
- No PyPI tokens are committed or printed.
- TestPyPI is verified before a real PyPI release.
Publishing
GitHub Actions build wheels with cibuildwheel. The publish workflow is designed
for PyPI trusted publishing with id-token: write; it should not hardcode PyPI
tokens or print secrets.
Current Limitations
- CPU backend only.
- Eager execution only.
- No CUDA or Metal backend yet.
- No graph compiler or distributed runtime.
- No convolution layers yet.
- No sparse tensors or advanced indexing.
- Limited dtype casting.
- Experimental performance; benchmarks are local references only.
- Pickle serialization is for trusted TensorStudio objects only.
Roadmap
- CUDA backend
- Graph/JIT mode
- Convolution ops
- Dataset utilities
- Model zoo examples
- ONNX import/export
- Improved memory allocator
- SIMD kernels
- Multithreaded ops
License
TensorStudio is licensed under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tensorstudio-1.0.0.tar.gz.
File metadata
- Download URL: tensorstudio-1.0.0.tar.gz
- Upload date:
- Size: 73.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
158f770fe82dbd9d70c1799d424f2f73a7fedca7e49d51d540dbe71fbc972020
|
|
| MD5 |
b4776d72bad79e6ee8f491ea02c20855
|
|
| BLAKE2b-256 |
3574c2c3ba82df0eb1e8f63606953763a19caed174a607767a9d62f2b69f54bf
|
File details
Details for the file tensorstudio-1.0.0-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: tensorstudio-1.0.0-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 682.3 kB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d7eac5da66d818ff07ea67923be493a0447f83349201f95d863dddd33c6795ff
|
|
| MD5 |
75c4dac1fffe469e4c7b6ec0c8ed09c4
|
|
| BLAKE2b-256 |
3e2c4a4f8085d7c0bdae14a9c284c27da69b620a1aab3ba34a2ab009d9e07628
|
File details
Details for the file tensorstudio-1.0.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: tensorstudio-1.0.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 873.1 kB
- Tags: CPython 3.13, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
327b0300a6fe1cade48594ac4db3dc4e087621cdac68aa74c5eadccbb804cde9
|
|
| MD5 |
f034762d00043900de5aa1a146bac6ca
|
|
| BLAKE2b-256 |
1d722eff96782db4cab535e566ec009aad33cb5100996d5d8f4ba38f2592a7f1
|
File details
Details for the file tensorstudio-1.0.0-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: tensorstudio-1.0.0-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 846.9 kB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e9af10e2148cb5b78552ae246dde67bfb964274922c0644ef202e929696192a
|
|
| MD5 |
261c0ef74f8600298519bcccf7db1f88
|
|
| BLAKE2b-256 |
03cde16d1f6877621db231f731721b666d4cfe263a2fc77e3293700a5c93f969
|
File details
Details for the file tensorstudio-1.0.0-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: tensorstudio-1.0.0-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 682.4 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
913eec95284587278618941a9cbb872e20af3f262f99f5617d8471086bd43bd5
|
|
| MD5 |
82bcfcd1017a73037fad56c2371c8a74
|
|
| BLAKE2b-256 |
2870bcbffdccb41cea04ddd9a1c85aa04ddc15b36e3645e48fcc5cfa2e7bd0a8
|
File details
Details for the file tensorstudio-1.0.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: tensorstudio-1.0.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 873.1 kB
- Tags: CPython 3.12, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e2ad39a8d572677b900e291af8515eeb34b55baecbad48cf3dc0518fe8d7f959
|
|
| MD5 |
a4a28d80bad34fa737ac0a57f14d69de
|
|
| BLAKE2b-256 |
974ec48086b9dcbf1653f583b92b49bdd1ffb6d4ba47c428a0ba8c1d3fc87227
|
File details
Details for the file tensorstudio-1.0.0-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: tensorstudio-1.0.0-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 846.8 kB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aa2c9c40bd8e29c52812ac064df81fbf868604aad6c70947c836759a218ff54e
|
|
| MD5 |
3d22914a92b50983364a64eb5946c05d
|
|
| BLAKE2b-256 |
3a9ddae538f39ea5f276efb97840c59cf2f060a2e36413522374ef087c6478fc
|
File details
Details for the file tensorstudio-1.0.0-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: tensorstudio-1.0.0-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 677.9 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7458ac6dd444c39f7f666c7bb833a672b9d8a991ceef9e407eb7086b0f79def2
|
|
| MD5 |
0b5186c01b7f3ec367cf91bef5466f94
|
|
| BLAKE2b-256 |
d918039657332d662cd675c811e4334f5b3ca76e46bb7455fe0a8be0f0022778
|
File details
Details for the file tensorstudio-1.0.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: tensorstudio-1.0.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 868.6 kB
- Tags: CPython 3.11, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6652f54db09aaa3f9f5303a5c17e344aa380afe2b60d073b53f4c9546bdaac13
|
|
| MD5 |
fca615a1c1347b39d3739fe2f8a1883e
|
|
| BLAKE2b-256 |
cd2e2131e720eb149788235f97f7b697df63ecaa8e0bfb9378c9e75927d5a942
|
File details
Details for the file tensorstudio-1.0.0-cp311-cp311-macosx_11_0_arm64.whl.
File metadata
- Download URL: tensorstudio-1.0.0-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 843.7 kB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f2f867ae0be5935f159a6d1903b4e1d8a4c33eef3d9a64576d00391e95a447cb
|
|
| MD5 |
1a1cb5f0b1df5a5d3205ba85b8e428ea
|
|
| BLAKE2b-256 |
7e8ddbe98f844003501cee7b3c51c68ad5abe5df393e99ccc206f7b84cb81fe0
|
File details
Details for the file tensorstudio-1.0.0-cp310-cp310-win_amd64.whl.
File metadata
- Download URL: tensorstudio-1.0.0-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 676.6 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
66b1ee1780cda2af9fd86ed2d5f0227f693fcea91a13c823ea8452b52e508067
|
|
| MD5 |
4bb7bc1302760be036965aedba81a9c8
|
|
| BLAKE2b-256 |
58d2ce30986a3ff428800eb0cb38ba7ca1b0e3e8b8b2d469e61ca01bd244d567
|
File details
Details for the file tensorstudio-1.0.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: tensorstudio-1.0.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 867.5 kB
- Tags: CPython 3.10, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
85546c93c527ef60dfa00c77ba7e9c3c16e61d4889d10393b2ee0e84e497d8bf
|
|
| MD5 |
e23c1efe323194d284f9704b65cc8bc8
|
|
| BLAKE2b-256 |
9e4f52ec1fbb0729d4a65b5a83c221f31bb23c76542f43fda49093ce0a9a5141
|
File details
Details for the file tensorstudio-1.0.0-cp310-cp310-macosx_11_0_arm64.whl.
File metadata
- Download URL: tensorstudio-1.0.0-cp310-cp310-macosx_11_0_arm64.whl
- Upload date:
- Size: 841.6 kB
- Tags: CPython 3.10, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
db400da5e94258a2bd8f7becf1e90add36bdd1e0f79ec96c1eea4e4c0e09a63c
|
|
| MD5 |
df215c39f62ccbbf0a98c2d4dea7c7be
|
|
| BLAKE2b-256 |
239253e8bee56b29527721765ee8d63ef46cdcdafe4a5706ef86e2543f6031fd
|