Minimalistic homemade PyTorch alternative, written in C99 and Python.
Explore the docs »
View Demo
|
Report Bug
|
Request Feature
Table of Contents
This project started as a learning experience and a way to understand the inner workings of PyTorch and other deep learning frameworks.
The goal is to create a minimalistic but still powerful deep learning framework that can be used for research and production.
The framework is written in C99 and Python and is designed to be easy to understand and modify.
- The project is still in its early stages and many features are missing.
- Developed by a single person in their free time.
- The project is not yet fully optimized for performance.
To get a local copy up and running follow these simple steps.
Magnetron itself has no Python dependencies except for CFFI to call the C library from Python.
Some examples use matplotlib and numpy for plotting and data generation, but these are not required to use the framework.
- Linux, MacOS or Windows
- A C99 compiler (gcc, clang, msvc)
- Python 3.6 or higher
A pip installable package will be provided, as soon as all core features are implemented.
- Clone the repo
cd magnetron/python
(VENV recommended).pip install -r requirements.txt
Install dependencies for examples.cd magnetron_framework && bash install_wheel_local.sh && cd ../
Install the Magnetron wheel locally, a pip installable package will be provided in the future.python examples/simple/xor.py
Run the XOR example.
See the Examples directory for examples on how to use the framework. For usage in C and C++ see the Unit Tests directory in the root of the project.
The goal is to implement training and inference for LLMs and other state of the art models, while providing a simple and small codebase that is easy to understand and modify.
- 6 Dimensional, Linearized Tensors
- Dynamic Computation Graph
- Static Computation Graph
- Modern Python API
- High level neural network building blocks
- CPU Compute and optimization
- SIMD Optimized operators (SSE4, AVX2, AVX512, ARM NEON)
- Compressed tensor file format
- Validation and friendly error messages
- Fast, custom memory allocators for CPU and GPU
- Modern PRNGs: Mersenne Twister and PCG
- Automatic differentiation
- Compute on GPU (Cuda)
- Other Datatypes (f16, bf16, int8)
- Multithreaded CPU Compute
- Distributed Training and Inference
- CPU and GPU kernel JIT compilation
- Better examples with real world models (LLMs and state of the art models)
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated. If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".
Distributed under the Apache 2 License. See LICENSE.txt
for more information.