Skip to main content

ModelStudio

ModelStudio is an early-stage AI tensor framework. Version 0.5.0 provides a CPU tensor/autograd MVP with neural-network modules, optimizers, serialization, data loading, graph tracing metadata, backend status inspection, and small LLM-oriented building blocks.

It is not a PyTorch or TensorFlow replacement. CPU is the only working backend. CUDA, ROCm, and oneAPI remain explicit scaffolds until real kernels are built and tested.

Installation

From PyPI:

python -m pip install modelstudio

For development:

python -m pip install -e ".[dev]"

Feature Table

Area Status
CPU tensors Working MVP
Autograd Reverse-mode for core CPU ops
Reductions sum, mean, max, all, and any; max is value-only
Comparisons Elementwise comparisons, equal, isclose, and allclose
Activations ReLU, GELU, LeakyReLU, ELU, Softplus, exp, log, tanh, sigmoid, SiLU, softmax, log-softmax
Losses MSE and cross entropy with none, mean, and sum reductions
Functional API modelstudio.nn.functional wrappers for common NN operations
Modules Parameters, buffers, child traversal, state dicts, save/load
Layers Linear, Embedding, LayerNorm, RMSNorm, BatchNorm1d, Dropout, Conv1d, Conv2d, pooling, TransformerBlock
Optimizers SGD and AdamW with state serialization, parameter groups, and LR schedulers
Data Dataset, TensorDataset, random_split, DataLoader with deterministic seeded shuffle
Randomness manual_seed, ms.random, RNG-backed creation, dropout, and init helpers
Linalg ms.linalg.matmul, norm, vector_norm, and transpose
Interop asarray, from_numpy, to_numpy, and ms.numpy
Metrics accuracy and top-k accuracy
Compiler Metadata-only tracing plus placeholder IR and passes

Backend Status

import modelstudio as ms

print(ms.backends.status())
print(ms.backends.native_cpu_available())

Expected shape:

{
    "cpu": {"available": True, "native": False},
    "cuda": {"available": False, "reason": "..."},
    "rocm": {"available": False, "reason": "..."},
    "oneapi": {"available": False, "reason": "..."},
}

The production CPU path is the NumPy backend. ms.backends.use_native_cpu(True) raises ModelStudioBackendUnavailable unless a future optional native extension is actually installed. Unsupported accelerator devices fail with ModelStudioBackendUnavailable.

Tensor Example

import modelstudio as ms

x = ms.randn((32, 784), requires_grad=True)
w = ms.randn((784, 10), requires_grad=True)
loss = (x @ w).mean()
loss.backward()
print(w.grad)

Functional API

import modelstudio as ms
from modelstudio import nn
from modelstudio.nn import functional as F

model = nn.Linear(4, 2)
x = ms.random.randn((8, 4))
target = ms.random.randn((8, 2))
loss = F.mse_loss(F.relu(F.linear(x, model.weight, model.bias)), target)

Tracing

import modelstudio as ms
from modelstudio.nn import functional as F

x = ms.random.randn((4, 3))
w = ms.random.randn((3, 2))
graph = ms.trace(lambda a, b: F.relu(a @ b), x, w)
print(graph)

Tracing captures operation names and tensor metadata. It does not optimize or execute graphs yet. ms.compile(fn) remains a documented no-op that returns the original callable.

Random And Linalg

ms.random.seed(123)
x = ms.random.normal((4, 3), mean=0.0, std=1.0)
w = ms.random.uniform((3, 2), low=-0.1, high=0.1)
y = ms.linalg.matmul(x, w)
print(ms.linalg.norm(y).item())

Comparisons

x = ms.tensor([1.0, 2.0, 3.0])
y = ms.tensor([1.0, 2.1, 3.0])
print(ms.isclose(x, y, atol=0.05))
print(ms.allclose(x, y, atol=0.05))
print((x > 1.5).any().item())

Comparison and logical outputs are bool tensors and do not track gradients.

Checkpointing

model = nn.Linear(4, 2)
optimizer = ms.optim.AdamW(model.parameters(), lr=1e-3)
ms.save_checkpoint("checkpoint.ms", model=model, optimizer=optimizer, extra={"epoch": 1})
checkpoint = ms.load_checkpoint("checkpoint.ms", model=model, optimizer=optimizer, map_location="cpu")

Checkpoint loading validates structure and model state. CPU is the only accepted map_location in the current release.

Commands

python -m pytest
python scripts/smoke_test.py
python examples/train_mlp.py
python examples/train_classifier.py
python examples/tiny_transformer.py
python examples/save_load.py
python examples/train_cnn_toy.py
python examples/dropout_batchnorm.py
python examples/checkpoint_training.py
python examples/numpy_interop.py
python examples/scheduler_training.py
python examples/checkpoint_resume.py
python examples/metrics_demo.py
python examples/backend_status.py
python examples/tracing_demo.py
python examples/functional_training.py
python examples/random_linalg_demo.py
python benchmarks/bench_matmul.py
python benchmarks/bench_mlp.py
python benchmarks/bench_attention.py
python benchmarks/bench_dataloader.py
python benchmarks/bench_conv.py
python benchmarks/bench_dropout.py
python benchmarks/bench_creation.py
python benchmarks/bench_manipulation.py
python benchmarks/bench_elementwise.py
python benchmarks/bench_trace.py

Documentation

Roadmap

  • Expand tensor and autograd coverage.
  • Wire optional native CPU kernels only after a safe Python extension exists.
  • Add tested CUDA, ROCm, and oneAPI packages when hardware-backed CI exists.
  • Improve compiler graph capture, analysis passes, and lowering.

Release files for modelstudio 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for modelstudio 0.5.0
File Size Uploaded
modelstudio-0.5.0.tar.gz 81.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for modelstudio 0.5.0
File Interpreter ABI Platform
modelstudio-0.5.0-py3-none-any.whl Python 3 none any Details

Total release size: 137.9 kB

Release files / modelstudio-0.5.0.tar.gz

Download URL modelstudio-0.5.0.tar.gz
Size 81.7 kB
Tags Source
SHA-256 checksum
How to use checksums
83ff1992e17b08446d53104a0f8bbbfe4fba6c85eba8e225827adfba6c8187d0
BLAKE2b-256 checksum
How to use checksums
f2c07e7bb7b25afd8467b03c3caf75fae01bcf1496571075ce496852064acbc0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.14

Release files / modelstudio-0.5.0-py3-none-any.whl

Download URL modelstudio-0.5.0-py3-none-any.whl
Size 56.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0b1d685aa7b8f792550526ac0aa003b0f7ccf9b89714e8dc8dc234c65ca067bd
BLAKE2b-256 checksum
How to use checksums
9cb3e28df7f8db3dbebf4e14948ea8f5d0c5d21824900c2161dfc87da237ae26
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.14

Release history Release notifications | RSS feed

0.7.0

2 release files

0.6.1

2 release files

0.6.0

2 release files

This release

0.5.0 This release

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page