MarioSieg/magnetron
A zero-dependency ML framework in C with a modern Python API for full control over execution and memory.
What it solves
Magnetron is a compact machine learning runtime designed for developers who need full control over execution and memory without the bloat of large frameworks like PyTorch. It provides a transparent, hackable stack for running real models and experimenting with low-level ML systems, kernels, and hardware ports.
How it works
Built with a native C core and a Python API, Magnetron implements its own tensor system, operator set, and reverse-mode autograd engine. It uses a multi-dispatch CPU backend that automatically detects microarchitectures (Intel, AMD, ARM) to select optimized SIMD kernels (SSE, AVX, AVX-512, NEON). It also features a custom .mag serialization format for zero-copy, memory-mapped model loading.
Who it’s for
It is intended for researchers and systems engineers who want to understand the full ML stack, prototype new execution strategies, or port ML workloads to unusual hardware.
Highlights
- Practical Performance: Capable of running modern LLM inference, such as Qwen3 in BF16.
- Hardware-Aware: Uses CPUID-based detection for architecture-specific kernel optimization.
- Zero-Copy Loading: Memory-mapped weights enable fast startup for large models.
- Minimalist Design: A native extension with no required Python dependencies.
- Extensible Backend: Modular architecture simplifies adding new hardware targets, with a CUDA backend currently in progress.
Related
- Project
- Project
- Project
- Project
- Project