An open API service indexing awesome lists of open source software.

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.

Awesome Lists containing this project

README

          

[![Stargazers][stars-shield]][stars-url]
[![Forks][forks-shield]][forks-url]
[![Issues][issues-shield]][issues-url]
![GitHub Actions Workflow Status][ci-shield]





Logo

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