JSON format for composable model graphs
Project description
Trama
Trama is a standalone Python library that defines a JSON schema, validator, and
export/import framework for hierarchical model graphs in Static Single
Assignment (SSA) style. It is framework-agnostic and is designed to be used by
domain-specific modeling libraries that inject their own op registries. Models
are serialized to self-contained .trama.json files capturing both topology and
parameter values, and can be reconstructed back into runtime modules via
registered factory functions.
Installation
# With pip:
pip install trama
# Or with uv:
uv add trama
Quick-start
import trama
# Export a module that implements ExportableOp + ImportableOp.
model = trama.export_model(module, inputs=["x"], outputs=["y"], registry=registry)
# Serialize to JSON and save.
trama.dump(model, "my_model.trama.json")
# Later: load and reconstruct the runtime module.
model = trama.load("my_model.trama.json")
instance = trama.import_model(model, registry=registry)
JSON Schema
Trama exposes a JSON Schema for .trama.json files. Generate it with the
tramaschema command:
tramaschema > trama.schema.json
The schema validates format structure: required fields, field types, and
identifier patterns. Registry conformance — whether op names resolve and
parameter types match — is not expressible in JSON Schema and is enforced at
load time in Python by trama.load() or trama.validate().
Design
For detailed description of the design of Trama please see the design document.
Compared to other model export formats
Trama operates at a fundamentally different abstraction level than ONNX,
torch.export, and similar formats. Those tools target deployment: they
decompose user-authored modules into low-level tensor operations (aten.matmul,
aten.conv2d, ONNX Gemm) so a runtime can execute them efficiently. The user's
Sequential(Encoder(), Decoder()) becomes a flat sequence of primitive ops with
the original module boundaries dissolved. Trama instead targets composition: it
preserves the user-authored module hierarchy as first-class structure, captures
only the wiring between the building blocks the consumer library defines, and
treats those blocks as opaque ops whose semantics live in the registry. This
makes trama files dramatically smaller and more readable than ONNX graphs of
equivalent models, diffable in code review, and meaningful to humans inspecting
"what does this model architecture actually look like" — at the cost of being
unsuitable for cross-framework deployment, since the ops are defined by the
consumer library rather than a standardized vocabulary. Trama is complementary
to ONNX, not a replacement: a natural pipeline is to author and review models in
trama, then lower to ONNX or torch.export when shipping to inference.
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 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
File details
Details for the file trama-0.1.0.tar.gz.
File metadata
- Download URL: trama-0.1.0.tar.gz
- Upload date:
- Size: 11.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"43","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9bd0a3f8fb74e52e979d879dd41e56831286bffa4b364dc64df336b2a5b61ad9
|
|
| MD5 |
8838b6341d88f9a3b13bcd03a2dcedf1
|
|
| BLAKE2b-256 |
3ed24b5e43b0915a8f0906c00c89b236486a1b2ecb51e0a3a47058963d6884e4
|
File details
Details for the file trama-0.1.0-py3-none-any.whl.
File metadata
- Download URL: trama-0.1.0-py3-none-any.whl
- Upload date:
- Size: 17.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"43","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7db9810311660765b11e1ec6173652e3e2153a39d7550edbb9d71cab183b85f6
|
|
| MD5 |
5e6b8daa35a37b48498b60f176181045
|
|
| BLAKE2b-256 |
951bf63d9eddca109f18ea6162e84d52e4e72da2ac5e728724e2fa316196e0dd
|