https://github.com/MarioSieg/magnetron
(WIP) A small but powerful, homemade PyTorch from scratch.
https://github.com/MarioSieg/magnetron
artificial-intelligence cpp cuda high-performance-computing machine-learning neuronal-network python pytorch research-project tensorflow tiny
Last synced: 2 months ago
JSON representation
(WIP) A small but powerful, homemade PyTorch from scratch.
- Host: GitHub
- URL: https://github.com/MarioSieg/magnetron
- Owner: MarioSieg
- License: other
- Created: 2025-01-02T21:25:56.000Z (11 months ago)
- Default Branch: master
- Last Pushed: 2025-09-09T09:29:07.000Z (2 months ago)
- Last Synced: 2025-09-09T12:43:49.734Z (2 months ago)
- Topics: artificial-intelligence, cpp, cuda, high-performance-computing, machine-learning, neuronal-network, python, pytorch, research-project, tensorflow, tiny
- Language: C
- Homepage:
- Size: 26.6 MB
- Stars: 638
- Watchers: 8
- Forks: 30
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
- awesome-cuda-and-hpc - MarioSieg/magnetron
README
[![Stargazers][stars-shield]][stars-url]
[![Forks][forks-shield]][forks-url]
[![Issues][issues-shield]][issues-url]
![GitHub Actions Workflow Status][ci-shield]
magnetron
Super minimalistic machine-learning framework.
Explore the docs ยป
View GPT-2 Example
|
Report Bug
|
Request Feature
## ๐ About
Magnetron is a minimalistic, PyTorch-inspired machine-learning framework designed for IoT and other resource-limited environments.
The tiny C core - wrapped in a modern Python API - gives you dynamic graphs, automatic differentiation and network building blocks without the bloat.
A CUDA backend is also WIP.
### Key features
* **PyTorch-close** Python API
- Seamless switch for PyTorch users with familiar syntax and behavior
* **Automatic differentiation** on dynamic computation graphs
- Supports flexible model construction and training workflows
* High-level **neural-net building blocks**
- Includes `nn.Module`, `Linear`, `Sequential`, and more out of the box
* **Highly optimized CPU kernels**
- Runtime CPU detection, multithreading, and SIMD acceleration (SSE, AVX2, AVX512, NEON)
* Multiple **datatypes**: **float32**, **float16**, **int32**, and **boolean**
- Flexibility for both training and quantized inference
* Custom **compressed tensor file formats**
- Fast serialization & model loading
* Clear **validation** and **error messages**
- Easier debugging and better developer experience
* No external **C or Python dependencies** (except **CFFI** for the Python wrapper)
- Lightweight and portable - great for embedded or restricted environments
## ๐ฆ Installation
Make sure you are inside a **Python virtual environment** before installing.
**With pip**
```bash
pip install magnetron
```
**With uv**
```bash
uv pip install magnetron
```
> โ ๏ธ Currently, prebuilt wheels are available for **macOS (Apple Silicon)** and **Linux x86-64**.
> On other platforms, the package must be built from source.
## ๐งช Examples
### GPT-2 inference
### Training a simple feedforward network
## ๐ค Contributing
Contributions are welcome!
Please open issues for ideas, or submit pull requests for new **features**.
PRs that only fix typos or minor formatting will not be accepted.
## ๐ License
(c) 2025 Mario Sieg. mario.sieg.64@gmail.com
Distributed under the Apache 2 License.
See `LICENSE` for more information.
## ๐งฉ Similar Projects
* [GGML](https://github.com/ggerganov/ggml)
* [TINYGRAD](https://github.com/tinygrad/tinygrad)
* [MICROGRAD](https://github.com/karpathy/micrograd)
[contributors-shield]: https://img.shields.io/github/contributors/MarioSieg/magnetron.svg?style=for-the-badge
[contributors-url]: https://github.com/MarioSieg/magnetron/graphs/contributors
[forks-shield]: https://img.shields.io/github/forks/MarioSieg/magnetron.svg?style=for-the-badge
[forks-url]: https://github.com/MarioSieg/magnetron/network/members
[stars-shield]: https://img.shields.io/github/stars/MarioSieg/magnetron.svg?style=for-the-badge
[stars-url]: https://github.com/MarioSieg/magnetron/stargazers
[issues-shield]: https://img.shields.io/github/issues/MarioSieg/magnetron.svg?style=for-the-badge
[issues-url]: https://github.com/MarioSieg/magnetron/issues
[license-shield]: https://img.shields.io/github/license/MarioSieg/magnetron.svg?style=for-the-badge
[license-url]: https://github.com/MarioSieg/magnetron/blob/master/LICENSE.txt
[ci-shield]: https://img.shields.io/github/actions/workflow/status/MarioSieg/magnetron/cmake-python-multi-platform.yml?style=for-the-badge