Skip to main content

PyTorch TrainEngine

A flexible and modular PyTorch training engine with interface-based design.

Features

  • Interface-based Architecture: Define trainable models through the ITrainable interface contract
  • Automatic Hardware Detection: Automatically detects and uses CUDA if available
  • Lazy Optimizer Initialization: Optimizers are initialized only when training starts
  • Standard Training Pipeline: Implements the canonical PyTorch training loop
  • Easy Integration: Simple integration with custom models and datasets

Installation

pip install pytorch-TrainEngine

Quick Start

import torch
from pytorch_trainengine import ITrainable, TrainingEngine

# Define your model
class MyModel(ITrainable):
    def __init__(self):
        super().__init__()
        self.linear = torch.nn.Linear(10, 1)
    
    def forward_pass(self, x):
        return self.linear(x)
    
    def parameters(self):
        return self.linear.parameters()

# Create training engine
criterion = torch.nn.MSELoss()
engine = TrainingEngine(criterion=criterion, lr=0.01)

# Train your model
model = MyModel()
x = torch.randn(32, 10)
y = torch.randn(32, 1)

loss = engine.train_step(model, x, y)
print(f"Loss: {loss}")

API Reference

ITrainable

Abstract base class for trainable models.

Methods:

  • forward_pass(x): Forward pass logic
  • parameters(): Return model parameters for optimizer

TrainingEngine

Main training engine class.

Parameters:

  • criterion: Loss function
  • optimizer_cls: Optimizer class (default: torch.optim.SGD)
  • lr: Learning rate (default: 0.01)
  • device: Computation device (auto-detected if None)

Methods:

  • setup_optimizer(model): Initialize optimizer (called automatically)
  • train_step(model, x, y): Single training step
  • train_epoch(model, dataloader): Train one epoch

Requirements

  • Python >= 3.8
  • torch >= 1.9.0

License

MIT

Author

15330613622@163.com

Metadata

Release files for pytorch-TrainEngine 0.1.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 pytorch-TrainEngine 0.1.0
File Size Uploaded Provenance Actions
pytorch_trainengine-0.1.0.tar.gz 4.1 kB Without provenance Details for pytorch_trainengine-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pytorch-TrainEngine 0.1.0
File Interpreter ABI Platform Actions
pytorch_trainengine-0.1.0-py3-none-any.whl Python 3 none any Details for pytorch_trainengine-0.1.0-py3-none-any.whl

Total release size: 8.6 kB

Release files / pytorch_trainengine-0.1.0.tar.gz

Download URL pytorch_trainengine-0.1.0.tar.gz
Size 4.1 kB
Tags Source
SHA-256 checksum
How to use checksums
67f73f876e54751c4c955d9a0e708abd4ca0b6bd6136319b8223d36d9e973ca1
BLAKE2b-256 checksum
How to use checksums
20d2db899aa42c133e52c0b9f599a53a0e00a7e64bd276620972cf9dbc43828a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.7

Release files / pytorch_trainengine-0.1.0-py3-none-any.whl

Download URL pytorch_trainengine-0.1.0-py3-none-any.whl
Size 4.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b76f41d30690772eedd83e6734c12c8b3823a4ca9f0511e698301a4f0ffbd19b
BLAKE2b-256 checksum
How to use checksums
1caff24b701c442c3b08424598b1df0b66880d33aa65a3cc42af8f15af8c8f47
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.7

Security for pytorch-TrainEngine 0.1.0

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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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