Skip to main content

reframx

PyPI version Python 3.10+ License: MIT Typing: Typed

A modular, Python-first, code-first framework for neural network research.

Core philosophy: Researchers own their architectures, losses, data pipelines, and training algorithms. reframx provides contract-driven composition, validation, pluggable execution backends, model instrumentation, plugins, and portable .rfx experiment snapshots — without forcing a fixed model hierarchy or a single forward -> loss -> backward -> step loop.

Key Features

  • Zero-dependency core: Core contracts, validation, execution engine, instrumentation, plugins, and .rfx packaging rely only on the Python standard library.
  • Contract-driven composition: ComponentSpec, Requirement, RequirementGroup (all_of / any_of), Capability, IOContract, and validate_requirements() with concise str/dict shorthand.
  • Full research freedom + sensible defaults:
    • BaseMethod for arbitrary multi-forward / multi-backward / multi-optimizer algorithms.
    • SupervisedMethod and PyTorch built-ins (TorchClassificationMethod, TorchRegressionMethod, CrossEntropyObjective, BCEWithLogitsObjective, MSEObjective, TorchAccuracyEvaluator, TorchRegressionEvaluator) for rapid standard workflows.
  • Pluggable execution backends:
    • NativeBackend (default, zero dependencies, easy debugging, experiment.stop()).
    • MMEngineBackend (optional, lazy-imported: GPU/DDP/FSDP, OptimWrapper, ParamScheduler, CheckpointHook with save_best/save_last, Visualizer).
  • Non-invasive PyTorch GPU integration: TorchModelAdapter, TorchDatasetAdapter, and TorchStrategy (auto device placement, AMP fp16/bf16, GradScaler, max_grad_norm, gradient accumulation) — never overwrites your existing PyTorch/CUDA installation.
  • Model instrumentation: rf.probe() / rf.Probe (zero-overhead pass-through via contextvars), watch_module / watch_modules, automatic tensor detach, tensor_stats, and check_nan_inf.
  • Plugin system: ComponentRegistry and PluginManager supporting load_plugin, load_file, load_path (multi-file packages), load_directory, safe discover_entry_points / load_entry_points, and clean unload_plugin.
  • Portable .rfx archives: Atomic, unencrypted ZIP experiment snapshots (minimal, standard, portable, full profiles) with SHA-256 verification and safe state restoration.

Installation

pip install reframx

Optional integrations: torch and mmengine are intentionally not installed automatically so pip install reframx never overwrites your platform-specific CUDA/PyTorch build. Install PyTorch for your hardware from pytorch.org, and optionally pip install mmengine for MMEngineBackend.

Quick Start

import torch
from torch import nn
from torch.utils.data import TensorDataset
import reframx as rf
from reframx.integrations.mmengine import MMEngineBackend
from reframx.integrations.pytorch import (
    BCEWithLogitsObjective,
    TorchAccuracyEvaluator,
    TorchClassificationMethod,
    TorchDatasetAdapter,
    TorchModelAdapter,
    TorchStrategy,
)

# 1. Standard PyTorch model and dataset
raw_model = nn.Sequential(nn.Linear(16, 32), nn.ReLU(), nn.Linear(32, 1))
x_train, y_train = torch.randn(256, 16), torch.randint(0, 2, (256, 1)).float()
x_val, y_val = torch.randn(64, 16), torch.randint(0, 2, (64, 1)).float()
train_ds, val_ds = TensorDataset(x_train, y_train), TensorDataset(x_val, y_val)

# 2. Compose & run on GPU with MMEngine
experiment = rf.Experiment(
    name="QuickDemo",
    task=rf.ClassificationTask(num_classes=2),
    method=TorchClassificationMethod(),
    model=TorchModelAdapter(raw_model),
    dataset=TorchDatasetAdapter(
        datasets={"train": train_ds, "val": val_ds},
        dataloader_kwargs={"batch_size": 32},
    ),
    objectives=BCEWithLogitsObjective(),
    optimizers=torch.optim.AdamW(raw_model.parameters(), lr=1e-3),
    evaluator=TorchAccuracyEvaluator(),
    strategy=TorchStrategy(device="auto", precision="fp16", max_grad_norm=1.0),
    backend=MMEngineBackend(work_dir="./work_dirs/quick_demo"),
)

run = experiment.run(max_epochs=5, catch_interrupt=True)
experiment.export("./work_dirs/quick_demo.rfx", profile="standard")

Documentation

Examples

License

Released under the MIT License.

Metadata

Release files for reframx 0.2.1

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

Source distribution (sdist)

Source distribution for reframx 0.2.1
File Size Uploaded Provenance Actions
reframx-0.2.1.tar.gz 77.2 kB Without provenance Details for reframx-0.2.1.tar.gz

Built distribution (wheel)

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

Total release size: 181.7 kB

Release files / reframx-0.2.1.tar.gz

Download URL reframx-0.2.1.tar.gz
Size 77.2 kB
Tags Source
SHA-256 checksum
How to use checksums
ceeba92ff22ee2248a757f86fe548c06c87cd585eb72b1e9e731a1ce670fc3fd
BLAKE2b-256 checksum
How to use checksums
9e9144df2a74dcdae70dd5927f571caaf7c9e1361502ac5e155207f05b7a7e66
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Release files / reframx-0.2.1-py3-none-any.whl

Download URL reframx-0.2.1-py3-none-any.whl
Size 104.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
69d4b124c3f3e80a5ea76e7b0bae9e4db19eb93bcc4df5cfaf81a7f4cbb4b94b
BLAKE2b-256 checksum
How to use checksums
3e0d2fd7da6d349f48fd3e6d4afe902d6994ed5cec400ae3e035643f965dad0b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Security for reframx 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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