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.0rc2 is a release candidate for a CPU-only stable API
foundation. It is eager-only, intentionally small, and not a replacement for
mature ML frameworks. The final 1.0.0 version should only be tagged after the
Windows, Linux, and macOS release checklist passes.
Install
From PyPI, once release-candidate wheels are published:
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 release candidate 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.0rc2, TensorStudio beat NumPy on 11
small activation/reduction benchmark cases and lost on 78 NumPy-comparable
cases. The strongest local wins were small sigmoid, sum, and mean cases;
medium elementwise operations and matrix multiplication remain slower than
NumPy. The C++ contiguous matmul fast path is much faster than the original
naive storage-access loop, but it is not a BLAS replacement. See
benchmarks/results.md for the full table, platform details, and exact timings.
Snapshot from that local run:
| operation | shape | TensorStudio median | NumPy median | speedup | result |
|---|---|---|---|---|---|
sigmoid |
(1,) |
0.0016 ms | 0.0036 ms | 2.2170x | win |
mean |
(1,) |
0.0014 ms | 0.0081 ms | 5.8562x | win |
mean |
(8,) |
0.0016 ms | 0.0079 ms | 5.0005x | win |
add |
(16384,) |
0.0100 ms | 0.0037 ms | 0.3682x | loss |
matmul |
(256, 256) |
4.1393 ms | 0.4222 ms | 0.1020x | loss |
Speedup is NumPy median / TensorStudio median, so values above 1.0x favor
TensorStudio. The matmul result is from the optimized C++ contiguous path; a
pre-optimization run was about 259 ms for the same (256, 256) case on this
machine.
Do not treat these results as universal. TensorStudio does not currently 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.0rc2.tar.gz.
File metadata
- Download URL: tensorstudio-1.0.0rc2.tar.gz
- Upload date:
- Size: 68.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ab659be85cc9ca8de29866bd49300a0f19b23126674de2fc3c2740b9e95db020
|
|
| MD5 |
f1e53be6d341db9c3e8d60737168694a
|
|
| BLAKE2b-256 |
f7ad984236d513852a008e8dee121459a6b4c82dd8557964d4e71e73023eb3ca
|
File details
Details for the file tensorstudio-1.0.0rc2-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: tensorstudio-1.0.0rc2-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 679.9 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 |
333165cd3079bc6a2fe3038a1dee0151383711cb3f148045e6acfd37daf8ecdd
|
|
| MD5 |
9ab19fd5540c6f64901f0d5d00f2aadc
|
|
| BLAKE2b-256 |
8172a7f04a162acb4268bf21ccc4f101c06f0a3decfd398bb29fb7f6f7fd9b91
|
File details
Details for the file tensorstudio-1.0.0rc2-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: tensorstudio-1.0.0rc2-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 873.0 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 |
de7dc52d15a9da2bb47ed716adc7df7d33cc49dfe2bfc1bcbb57a39c0168b9d9
|
|
| MD5 |
39409ffaf92815e4342fba7922cb1391
|
|
| BLAKE2b-256 |
0d94e47fa7ad1183235cbb08cedbf92fa6f3e8a12a9ea5331720fa85d3394cc0
|
File details
Details for the file tensorstudio-1.0.0rc2-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: tensorstudio-1.0.0rc2-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 917.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 |
c4f1de5e8b7315696005329b0067e7eb7ec9de094d2c1651117cbdfc4f4de987
|
|
| MD5 |
6179c99938ad121b51b8e9f347946c9b
|
|
| BLAKE2b-256 |
7795b1d46cb02ff9b7d510f1f376c60f9c14bbdbe0173ec766761e943425b3bf
|
File details
Details for the file tensorstudio-1.0.0rc2-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: tensorstudio-1.0.0rc2-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 679.8 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 |
bd3f68860969905a99b29184dad0bf3e24fa6cad8e154d426b1809565cf26b52
|
|
| MD5 |
dc4e480f103021b135304fc8118e255e
|
|
| BLAKE2b-256 |
6898f8fac2bf30bcd07f7ef41c16a901c8a2971a7cb9e0b8e307e0a1998ab176
|
File details
Details for the file tensorstudio-1.0.0rc2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: tensorstudio-1.0.0rc2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 873.0 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 |
b7faf965f3b12649844cf217be24fb59bf5bc849cd8991b820706d0d00748626
|
|
| MD5 |
584e46de495779eeefb9a69dcd2a6742
|
|
| BLAKE2b-256 |
ffda94eaf42627f86156ab0c0ea38fde644de23597a3666c71f9da71f695bd79
|
File details
Details for the file tensorstudio-1.0.0rc2-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: tensorstudio-1.0.0rc2-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 917.9 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 |
2b17abe72e3005fb76ef166c90ae8b4024df824cc62fd2a26367eccfbe67b720
|
|
| MD5 |
e6cb293212f135df676b554152c770fc
|
|
| BLAKE2b-256 |
a8b66361e6c634e3fafb03db79a62fd687a624f6a1e804b19b7b35e07b2f2eb9
|
File details
Details for the file tensorstudio-1.0.0rc2-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: tensorstudio-1.0.0rc2-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 675.7 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 |
13c36b5b231cdd56068cf203796f50ae258effc018e7a8718d0d9059c5b9066c
|
|
| MD5 |
88b3992cdf48420288eb95f7c703f4ec
|
|
| BLAKE2b-256 |
3ac2e2e33190f2ba059958205f7fe04a7930964882984af923bead6b77d1de14
|
File details
Details for the file tensorstudio-1.0.0rc2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: tensorstudio-1.0.0rc2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 865.9 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 |
5b6bd28dbd326cdbc4049458e29bcaf4ddb420ad6d0d7095782d3f25b4fdc226
|
|
| MD5 |
79ae23c20466a483f6534dfb8d1ec0a5
|
|
| BLAKE2b-256 |
d646607c32d792463795f0f626bd0022578b55993d701cba7b0b1f328c18272a
|
File details
Details for the file tensorstudio-1.0.0rc2-cp311-cp311-macosx_11_0_arm64.whl.
File metadata
- Download URL: tensorstudio-1.0.0rc2-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 915.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 |
229b769c866cc3c7c9dcbe6c37885d61b411b37fd566d098396b1d407f9eba62
|
|
| MD5 |
f115d4625ee25c854a45f788c86869ca
|
|
| BLAKE2b-256 |
ed4692ec4397bbca23ebe631aaddaaf0cf321b060eb9698199c1087bd443b134
|
File details
Details for the file tensorstudio-1.0.0rc2-cp310-cp310-win_amd64.whl.
File metadata
- Download URL: tensorstudio-1.0.0rc2-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 674.5 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 |
7fb737ab58c90aaf99212f50031667c97520fb2ed4c24585a3b632d62d634002
|
|
| MD5 |
ae79b7785fb799f9e45b1ca9803cd3c4
|
|
| BLAKE2b-256 |
78f78856f50b1f3b86bf9cc678ef9ffff5c1c7201526982933ee774441a04aa5
|
File details
Details for the file tensorstudio-1.0.0rc2-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: tensorstudio-1.0.0rc2-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 864.8 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 |
3142bd419f2e53951b3d98655929406ba0cf549b4167210cbcf2073816ee8e6b
|
|
| MD5 |
d7419354dd93d62701fc111bbbe69f55
|
|
| BLAKE2b-256 |
d611ead201f01aae680ec04aaf0244ed46755d364de1988ce62531af0e3a95f0
|
File details
Details for the file tensorstudio-1.0.0rc2-cp310-cp310-macosx_11_0_arm64.whl.
File metadata
- Download URL: tensorstudio-1.0.0rc2-cp310-cp310-macosx_11_0_arm64.whl
- Upload date:
- Size: 914.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 |
41ed73bf56d6df778a51545deea307801f16182364dc3c28400690bd048e2684
|
|
| MD5 |
491ae4a976c80b41b0a1159bb02a5200
|
|
| BLAKE2b-256 |
7a4fb11500bd61ffd0cda1d53f2aaeb2cd45e114059bb188f2892df13a93d691
|