Skip to main content

ModelStudio

ModelStudio is an early-stage AI tensor framework. Version 0.4.0 provides a CPU tensor/autograd MVP with neural-network modules, optimizers, serialization, basic data loading, 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 with axis and keepdims; max is value-only
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
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, RNG-backed randn, dropout, and init helpers
Interop asarray, from_numpy, to_numpy, and ms.numpy
Metrics accuracy and top-k accuracy
Compiler Placeholder IR and passes

Backend Status

Backend Status
CPU working MVP
CUDA scaffold only
ROCm scaffold only
oneAPI scaffold only

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)

MLP Example

import modelstudio as ms
from modelstudio import nn


class MLP(nn.Module):
    def __init__(self):
        super().__init__()
        self.fc1 = nn.Linear(784, 256)
        self.fc2 = nn.Linear(256, 10)

    def forward(self, x):
        return self.fc2(ms.gelu(self.fc1(x)))


model = MLP()
optimizer = ms.optim.AdamW(model.parameters(), lr=3e-4)
x = ms.randn((16, 784))
target = ms.randn((16, 10))
loss = ms.mse_loss(model(x), target)
optimizer.zero_grad()
loss.backward()
optimizer.step()

State Dict and Save/Load

model = nn.Linear(4, 2)
ms.save(model.state_dict(), "model.ms")
state = ms.load("model.ms")
model.load_state_dict(state)

DataLoader

from modelstudio import data

dataset = data.TensorDataset(ms.randn((8, 4)), ms.arange(8))
loader = data.DataLoader(dataset, batch_size=2, shuffle=False)
for xb, yb in loader:
    print(xb.shape, yb.shape)

Embedding

emb = nn.Embedding(num_embeddings=100, embedding_dim=32)
tokens = ms.tensor([[1, 2, 3]], dtype=ms.int64)
print(emb(tokens).shape)

Cross Entropy

logits = ms.randn((4, 10), requires_grad=True)
targets = ms.tensor([1, 2, 3, 4], dtype=ms.int64)
loss = ms.cross_entropy(logits, targets)
loss.backward()

TransformerBlock

block = nn.TransformerBlock(embed_dim=16, num_heads=4)
x = ms.randn((2, 8, 16), requires_grad=True)
y = block(x)
print(y.shape)

0.4.0 Training Utilities

ms.manual_seed(123)
model = nn.Linear(4, 2)
optimizer = ms.optim.AdamW(model.parameters(), lr=1e-3)
state = {"model": model.state_dict(), "optimizer": optimizer.state_dict()}
ms.save(state, "checkpoint.ms")

New CPU-only helpers include ms.concat, ms.stack, Tensor.flatten, Tensor.squeeze, Tensor.unsqueeze, nn.init, nn.Dropout, nn.BatchNorm1d, nn.Conv1d, nn.Conv2d, nn.AvgPool2d, nn.MaxPool2d, and nn.utils gradient clipping.

NumPy Interop

x = ms.asarray([[1, 2, 3], [4, 5, 6]], dtype=ms.float32)
arr = ms.to_numpy(x)
y = ms.from_numpy(arr)

CPU uses NumPy internally. Normal examples prefer ModelStudio APIs; ms.numpy is exposed for advanced users who explicitly want NumPy access.

Schedulers and Metrics

optimizer = ms.optim.AdamW(model.parameters(), lr=1e-3)
scheduler = ms.optim.lr_scheduler.StepLR(optimizer, step_size=1, gamma=0.5)
scheduler.step()

acc = ms.metrics.accuracy(logits, targets)

Checkpointing

ms.save_checkpoint("checkpoint.ms", model=model, optimizer=optimizer, scheduler=scheduler, extra={"epoch": 1})
checkpoint = ms.load_checkpoint("checkpoint.ms", model=model, optimizer=optimizer, scheduler=scheduler)

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 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

Documentation

Roadmap

  • Expand tensor and autograd coverage.
  • Wire native CPU kernels into Python bindings.
  • Add tested CUDA, ROCm, and oneAPI packages when hardware-backed CI exists.
  • Improve compiler graph capture and lowering.

Release files for modelstudio 0.4.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.4.0
File Size Uploaded
modelstudio-0.4.0.tar.gz 69.9 kB Details

Built distribution (wheel)

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

Total release size: 119.5 kB

Release files / modelstudio-0.4.0.tar.gz

Download URL modelstudio-0.4.0.tar.gz
Size 69.9 kB
Tags Source
SHA-256 checksum
How to use checksums
a3649a19284a78c1dd50b145e6d09bdd1cd06bf9f27f83bd65edd648ab88a9d3
BLAKE2b-256 checksum
How to use checksums
bf6f3c6a82c6797c52b96681c2593e5d1573a98b4b7d47566725e928fee482df
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.4.0-py3-none-any.whl

Download URL modelstudio-0.4.0-py3-none-any.whl
Size 49.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
97e6f9d00fe3c53a60d2927bc58f2a27f2cdd80ed922a55f850ea0953152f1de
BLAKE2b-256 checksum
How to use checksums
948c5ad1d61af3f1ecb45160dd95b17f3c9994ee3732cdd944c8c16d0c2beeec
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

0.5.0

2 release files

This release

0.4.0 This release

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