attorch  by BobMcDear

PyTorch nn module subset, implemented in Python using Triton

Created 2 years ago
576 stars

Top 56.2% on SourcePulse

GitHubView on GitHub
Project Summary

attorch provides a curated subset of PyTorch's neural network modules implemented in Python using OpenAI's Triton. It targets developers seeking a more hackable, efficient, and readable alternative to pure PyTorch for custom deep learning operations, particularly those who find writing raw CUDA kernels challenging. The library supports both forward and backward passes, enabling its use during model training.

How It Works

attorch leverages OpenAI's Triton, a language and compiler for writing high-performance kernels that bridge the gap between Python and CUDA. By implementing core neural network operations (like convolutions, attention, and various activation functions) in Triton, attorch aims to achieve performance improvements over standard PyTorch while maintaining a Pythonic interface. This approach allows for easier customization and potential for operation fusion, which can further boost efficiency.

Quick Start & Requirements

Highlighted Details

  • Implements a broad range of layers including Conv1d/2d, MultiheadAttention, various activations, BatchNorm, LayerNorm, and common loss functions.
  • Supports Automatic Mixed Precision (AMP).
  • Includes a PyTorch fallback mechanism for layers not yet implemented in attorch.
  • Provides a attorch.math module for custom kernel development and operation fusion.

Maintenance & Community

  • The project is maintained by BobMcDear.
  • Further community engagement details (e.g., Discord, Slack) are not specified in the README.

Licensing & Compatibility

  • The README does not explicitly state a license. This requires clarification for commercial use or closed-source linking.

Limitations & Caveats

  • The implementation is a subset of PyTorch's modules; some layers may not be available and will fall back to PyTorch.
  • Performance for inference may not match dedicated inference engines.
  • Some tests against PyTorch counterparts might fail due to numerical precision differences.
Health Check
Last Commit

1 month ago

Responsiveness

1 day

Pull Requests (30d)
0
Issues (30d)
0
Star History
9 stars in the last 30 days

Explore Similar Projects

Starred by Yineng Zhang Yineng Zhang(Inference Lead at SGLang; Research Scientist at Together AI), Lewis Tunstall Lewis Tunstall(Research Engineer at Hugging Face), and
15 more.

torchtune by pytorch

0.2%
5k
PyTorch library for LLM post-training and experimentation
Created 1 year ago
Updated 1 day ago
Feedback? Help us improve.