Piro — open source model development framework, built on PyTorch
Project description
Piro
Open source model development framework, built on PyTorch.
Piro is to PyTorch what Next.js is to React — a framework that gives you structure, conventions, and a platform to deploy to.
Install
pip install trainpiro
Quick Start
Define a model
from piro import PiroModel
from piro.schema import ArchitectureGraph, GraphNode, GraphEdge
class MyModel(PiroModel):
name = "My Model"
slug = "my-model"
description = "A tiny model for sequence classification."
module = "my_model"
hyper_parameters = {"embed_dim": 8, "n_classes": 5}
@classmethod
def serialize_graph(cls) -> ArchitectureGraph | None:
return ArchitectureGraph(
nodes=[
GraphNode(id="input", type="io", label="Input"),
GraphNode(id="output", type="io", label="Output"),
],
edges=[GraphEdge(**{"from": "input", "to": "output"})],
)
def __init__(self, embed_dim=8, n_classes=5):
super().__init__()
self.linear = torch.nn.Linear(embed_dim, n_classes)
def forward(self, embeddings):
return self.linear(embeddings)
Train locally
from piro import Trainer, TrainerConfig
from piro.data.counter import generate_counter_dataset
train = generate_counter_dataset(n=1000, length=(2, 8), seed=0, split="train")
val = generate_counter_dataset(n=200, length=(2, 8), seed=1, split="val")
model = MyModel()
history = Trainer(model, TrainerConfig(epochs=20, lr=1e-3)).fit(train, val)
Deploy to the platform
# Save your API key
piro login
# Push your model class
piro classes push <class-id> --file model.py
# Launch a training run
piro train --model my-model --data counter-sequences --epochs 20
# Run benchmarks
piro eval length-generalization --model <model-id>
# Run inference
piro infer <model-id> --prompt "INC DEC INC INC DEC"
Package Layout
piro/
├── __init__.py # PiroModel, Trainer, TrainerConfig, schema types
├── base.py # PiroModel — base class for all models
├── schema.py # ModelManifest, ArchitectureGraph, GraphNode, GraphEdge
├── trainer.py # Trainer + TrainerConfig — training loop
├── client.py # PiroClient — platform API client
├── cli.py # piro CLI (train, deploy, eval, infer, ...)
├── input.py # PiroInput — base class for model inputs
├── layer.py # PiroLayer — base class for serializable layers
├── data/
│ ├── counter.py # Counter task data generation
│ └── sequences.py # Sorting task data generation
└── benchmarks/
├── base.py # Benchmark, BenchmarkResult
├── models.py # GPTBaseline, ModelProtocol
├── length_generalization.py
├── ood_generalization.py
└── adaptive_compute.py
License
MIT
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
trainpiro-0.1.0.tar.gz
(427.6 kB
view details)
Built Distribution
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
trainpiro-0.1.0-py3-none-any.whl
(33.5 kB
view details)
File details
Details for the file trainpiro-0.1.0.tar.gz.
File metadata
- Download URL: trainpiro-0.1.0.tar.gz
- Upload date:
- Size: 427.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.27 {"installer":{"name":"uv","version":"0.11.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a43bc956d2b0ad1d2afeb67a3303f47f183d46f5414d68777a49f5aacdbc7853
|
|
| MD5 |
4ee540c94cef1ca816e08fe44642a21e
|
|
| BLAKE2b-256 |
1e3be36ad1860bc53f8aad4f570e5593b9cf28a58df7c993cd6de1158a5a409e
|
File details
Details for the file trainpiro-0.1.0-py3-none-any.whl.
File metadata
- Download URL: trainpiro-0.1.0-py3-none-any.whl
- Upload date:
- Size: 33.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.27 {"installer":{"name":"uv","version":"0.11.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
182bd612f7695db2ec069943afce729ff91ff63ac2706775e8e2746b7f49fdd1
|
|
| MD5 |
02171041e03bd5e36b2ea7214e7dc0a2
|
|
| BLAKE2b-256 |
ce657b5bfe8ae3c4db0580c30fe87b3cc8ea797d039f812283853acc385fbe2b
|