Modular transformer blocks built in PyTorch
Project description
StackFormer
StackFormer is a modular PyTorch framework for building, training, and experimenting with Transformer architectures.
Overview
StackFormer is designed for fast experimentation with reusable Transformer building blocks and model implementations. It supports both language and vision workflows in a single modular codebase. The framework is built for research, prototyping, and iterative model development with practical training infrastructure.
Key Features
- Modular transformer components
- GPT / LLaMA / Gemma-style model implementations
- Vision models (ViT, SegFormer)
- Trainer infrastructure with AMP mixed precision and DDP support
- Logging and metrics utilities
- Checkpointing and resume training
- CI-tested training infrastructure
Project Structure
Stackformer/
├── assets/
├── docs/
│ ├── user_docs/
│ └── developer_docs/
├── examples/
├── stackformer/
│ ├── __init__.py
│ ├── generate.py
│ ├── metrics.py
│ ├── py.typed
│ ├── amp/
│ │ └── scaler.py
│ ├── distributed/
│ │ └── ddp.py
│ ├── engine/
│ │ ├── checkpoint.py
│ │ ├── engine.py
│ │ ├── state.py
│ │ └── trainer.py
│ ├── logging/
│ │ ├── csv_logger.py
│ │ ├── logger.py
│ │ ├── metrics.py
│ │ ├── tensorboard_logger.py
│ │ ├── wandb_logger.py
│ │ └── wb_logger.py
│ ├── models/
│ │ ├── OpenAI.py
│ │ ├── Meta.py
│ │ ├── Google.py
│ │ └── Transformer.py
│ ├── modules/
│ │ ├── Attention.py
│ │ ├── Feed_forward.py
│ │ ├── Masking.py
│ │ ├── Normalization.py
│ │ ├── position_embedding.py
│ ├── optim/
│ │ ├── factories.py
│ │ └── loss_fn.py
│ ├── training/
│ │ └── loops.py
│ ├── utils/
│ │ ├── device.py
│ │ └── utils.py
│ └── vision/
│ ├── vit.py
│ └── segformer.py
├── tests/
│ ├── integration/
│ ├── models/
│ ├── modules/
│ ├── trainer/
│ ├── utils/
│ ├── conftest.py
│ ├── test_distributed.py
│ └── test_vision.py
├── LICENSE
├── pyproject.toml
└── README.md
Installation
Python >= 3.10
Install from PyPI
pip install stackformer
Install from source
git clone https://github.com/Gurumurthy30/Stackformer.git
cd Stackformer
pip install -e .
Quick Start
from stackformer.engine import Trainer
import torch.nn as nn
model = nn.Linear(10, 1)
trainer = Trainer(model=model)
trainer.fit(dataset)
Examples
More runnable examples are available in:
examples/
examples/simple_train.py
examples/simple_trainer_v2.py
examples/train_ddp.py
Documentation
- User documentation: docs/user_docs/installation.md
- Developer documentation: docs/developer_docs/architecture.md
Community
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 stackformer-0.1.9.tar.gz.
File metadata
- Download URL: stackformer-0.1.9.tar.gz
- Upload date:
- Size: 47.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f4f838ec315717d470994837ef1b2e5c61484d6790ccea9cabaafa014bef9007
|
|
| MD5 |
e37e8a9f0c3ee6de75e960c844c02b42
|
|
| BLAKE2b-256 |
7d168feba5a2eebab9dd160f33786c4aef8ad7a3732183a1838886c2dfc1ec75
|
File details
Details for the file stackformer-0.1.9-py3-none-any.whl.
File metadata
- Download URL: stackformer-0.1.9-py3-none-any.whl
- Upload date:
- Size: 59.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
51cdb4e4b34259d774fd56761ab7c00977e52063d173b9240dfaaa2e86dfe169
|
|
| MD5 |
28f05c7e17c0626636115ad33aed80b0
|
|
| BLAKE2b-256 |
a088bda6358e2b95bfdc1a64f770609e43400a9e22c598d7a737d4a1dd44fb88
|