Universal Hardware-Accelerated Tensor Engine with Sub-Bit Quantization for ASI Training
Project description
MecanTensor v2.0
Universal Hardware-Accelerated Tensor Engine with Sub-Bit Quantization
MecanTensor is a C++/Python tensor engine designed for training and inference at extreme efficiency. It provides hardware-accelerated math operations, sub-bit weight quantization (0.45-bit, 0.75-bit, 1-bit), automatic differentiation, and a complete vision pipeline — all through a unified Python API backed by a high-performance C++ core.
Features
| Subsystem | Description |
|---|---|
| HAL | Hardware Abstraction Layer — auto-detects CPU (AVX2/SSE), GPU (CUDA/OpenCL), and NPU backends |
| HLAS | Hardware Linear Algebra Subroutines — optimized matmul, GEMM dispatched per hardware |
| FluxBits | 0.45-bit Bloom Tensor Engine — hash-based weight compression via Bloom filters |
| QSBits | 1-bit Binary Engine — XNOR + POPCOUNT with per-group FP32 scales (1BF16) |
| MidBits | 0.75-bit Block-Palette LUT Engine — codebook-based sub-byte quantization |
| Ops | Core operations — matmul, conv2d, attention, pooling, normalization, upsampling |
| Autograd | Reverse-mode automatic differentiation with operation tracing |
| Vision | Detection, color analysis, motion tracking, object recognition, lighting estimation |
| IO | Paged .mt tensor serialization for efficient model checkpointing |
Installation
pip install mecantensor
From source:
git clone https://github.com/mathagens-ai/mecantensor.git
cd mecantensor
pip install -e .
Quick Start
import mecantensor as mt
# Hardware discovery
devices = mt.hal.discover()
print(f"Available backends: {devices}")
# Tensor creation and operations
a = mt.tensor.create([4, 256], dtype="float32")
b = mt.tensor.create([256, 128], dtype="float32")
c = mt.ops.matmul(a, b)
# 1-bit quantized forward pass (QSBits)
packed, scales = mt.qsbits.quantize(weight_matrix, group_size=128)
output = mt.qsbits.forward_scaled(input_packed, packed, scales,
input_scale=0.1, group_size=128)
# Save / Load tensors
mt.io.save(c, "output.mt")
loaded = mt.io.load("output.mt")
Building the C++ Engine
The native C++ backend provides AVX2-accelerated operations. To build from source:
Windows (MSVC):
build_dll.bat
CMake (cross-platform):
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build . --config Release
Architecture
┌────────────────────────────────────────────────────┐
│ Python API │
│ hal · hlas · ops · fluxbits · qsbits · midbits │
│ autograd · vision · io · tensor │
├────────────────────────────────────────────────────┤
│ C++ Native Engine │
│ src/ops/ src/nn/ src/autograd/ │
│ src/hal/ src/hlas/ src/runtime/ │
│ src/vision/ src/io/ src/fluxbits/ │
│ src/qsbits/ src/midbits/ src/distributed/ │
├────────────────────────────────────────────────────┤
│ Hardware Backends │
│ CPU (AVX2/SSE) · GPU (CUDA/OpenCL) · NPU │
└────────────────────────────────────────────────────┘
Running Tests
python test_package.py
python test_bench_qsbits.py
python test_qsbits_scaling.py
License
Apache License 2.0 — see LICENSE for details.
Copyright 2025-2026 Mathagens AI
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mecantensor-2.0.0.tar.gz.
File metadata
- Download URL: mecantensor-2.0.0.tar.gz
- Upload date:
- Size: 238.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fb496885f1639b2c3a7973121f6d01e9be9af708022cd0397ecbb3145bd37563
|
|
| MD5 |
d76317ed4a16d5132a3d372724eb2812
|
|
| BLAKE2b-256 |
e67a99eba7363226b11a852bc90c4a7927febe8069b9d1754a4d39b6fe105835
|
File details
Details for the file mecantensor-2.0.0-py3-none-any.whl.
File metadata
- Download URL: mecantensor-2.0.0-py3-none-any.whl
- Upload date:
- Size: 245.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2105c4a7687a709a4c4a8a893b604b79f313cb16678e7f377055c16439e62d4a
|
|
| MD5 |
16ad82f90fe0b0878633051e5cbace54
|
|
| BLAKE2b-256 |
54ebb3f846806486e74d6db44e4fab7440df0ab5e6798621b753320d70933b0a
|