NNEngine
A high-performance, fully native C++ Neural Network engine exposed to Python via pybind11.
Designed for rapid experimentation without the Python Global Interpreter Lock (GIL) overhead, nn-engine-core executes the entire deep learning training loop (forward pass, validation, loss calculation, backpropagation, and weight updates) strictly in native C++ using Eigen. It utilizes a zero-allocation flat-memory Autograd graph, AVX SIMD vectorization, and dynamically compiled OpenBLAS to achieve massive speedups over mainstream Python frameworks.
Highlights
- Dual Execution Modes: Train dynamic graphs using the
@nne.eagerdecorator for zero-allocation step-by-step execution, or compile static graphs withJITCompilerfor maximum throughput on heavy workloads. - Dynamic Hardware Dispatch: The engine ships as a "fat wheel," automatically detecting your CPU at runtime to dispatch highly optimized AVX2 or AVX-512 instructions.
- Native Loop Hoisting: The
JITCompiler::fitloop executes entirely in C++, eliminating the Python GIL overhead across epochs and batches. - CNN & Modern Layer Support: Built-in support for
Conv2dLayer(via parallelizedim2col),BatchNorm1dLayer,DropoutLayer, and Leaky ReLUs. - Zero-Allocation Autograd: Uses arena allocation (
Tape) and flat contiguous memory structs to dynamically build computational graphs without heap allocations.
Installation
Install the released wheel from PyPI (macOS, Linux, and Windows supported):
pip install nn-engine-core
Or install in editable/development mode from the repository (requires CMake 3.18+ and a C++17 compiler):
pip install -e .
Quick Start: Building a CNN
import numpy as np
import nnengine as nne
X_train = np.random.rand(100, 1, 64, 64).astype(np.float32)
y_train = np.eye(40, dtype=np.float32)[np.random.choice(40, 100)]
class NNEngineDeepCNN(nne.Module):
def __init__(self, in_h, in_w, num_classes):
super().__init__()
self.conv1 = nne.Conv2dLayer(1, 16, in_h, in_w, kernel_size=5, stride=2, pad=2)
self.act1 = nne.LeakyReLULayer(0.01)
out_h1, out_w1 = in_h // 2, in_w // 2
self.conv2 = nne.Conv2dLayer(16, 32, out_h1, out_w1, kernel_size=3, stride=2, pad=1)
self.act2 = nne.LeakyReLULayer(0.01)
out_h2, out_w2 = out_h1 // 2, out_w1 // 2
self.fc = nne.DenseLayer(32 * out_h2 * out_w2, num_classes)
def forward(self, x):
x = self.act1(self.conv1(x))
x = self.act2(self.conv2(x))
return self.fc(x)
model = NNEngineDeepCNN(64, 64, 40)
optimizer = nne.Adam(learning_rate=0.001)
loss_fn = nne.SoftmaxCrossEntropyLoss()
trainer = nne.JITCompiler(model, optimizer, loss_fn)
dataloader = nne.DataLoader(X_train, y_train, batch_size=32, shuffle=True, drop_last=True)
trainer.fit(dataloader, epochs=40, verbose=False)
trainer.save_checkpoint("faces_model")
Quick Start: Eager Mode Training
If you prefer PyTorch-style step-by-step execution or need dynamic control flow (like if statements inside your forward pass), use the @nne.eager decorator. It manages the C++ Autograd tape and GIL releases automatically:
import nnengine as nne
model = nne.DenseLayer(10, 1)
optimizer = nne.AdamW(learning_rate=0.01, weight_decay=1e-4)
optimizer.set_parameters(model.parameters())
loss_fn = nne.MSELoss()
@nne.eager(optimizer=optimizer, loss_fn=loss_fn)
def train_step(mod, x):
# Standard Python control flow works perfectly here!
return mod(x)
# Training loop
for epoch in range(10):
dataloader.reset()
while dataloader.has_next():
dataloader.next_batch(X_batch, y_batch)
loss = train_step(model, X_batch, y_batch)
Defining Custom Autograd Operations in Python
import numpy as np
import nnengine as nne
class MulOp(nne.Op):
def __init__(self, a, b):
super().__init__()
self.a = a
self.b = b
def forward(self):
self.out_data = self.a.data * self.b.data
def backward(self):
if self.a.requires_grad:
self.a.grad += self.out.grad * self.b.data
if self.b.requires_grad:
self.b.grad += self.out.grad * self.a.data
Testing & Validation Suite
Execute the full Scikit-Learn dataset validation and benchmark suite via:
python examples/script.py
To benchmark raw FLOPs and OpenMP scaling without network I/O overhead, execute the massive synthetic stress test:
python examples/stress_test.py
Latest Benchmark Results
NNEngine's native C++ execution eliminates the Python GIL, consistently outperforming PyTorch's ATen backend on the CPU in both JIT and Eager modes.
| Benchmark Task | Scikit-Learn | PyTorch (ATen) | NNEngine (Eager) | NNEngine (C++ JIT) | Max Speedup (vs PyTorch) |
|---|---|---|---|---|---|
| Deep Regression (Housing) | MSE: 0.2811 Time: 8.59s |
MSE: 0.2720 Time: 18.18s |
MSE: 0.2662 Time: 3.19s |
MSE: 0.2669 Time: 5.10s |
5.69x |
| Deep CNN (Faces) | N/A | Acc: 97.50% Time: 5.97s |
Acc: 97.50% Time: 5.02s |
Acc: 97.50% Time: 4.41s |
1.35x |
| Massive Wide MLP (Stress) | N/A | Time: 46.09s | Time: 38.98s | Time: 38.09s | 1.21x |
| Deep Spatial CNN (Stress) | N/A | Time: 39.96s | Time: 36.76s | Time: 35.70s | 1.12x |
Metadata
Release files for nn-engine-core 0.1.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| nn_engine_core-0.1.9.tar.gz | 51.6 kB | With provenance | Details |
Built distributions (wheels)
Total release size: 57.4 MB
Release files / nn_engine_core-0.1.9.tar.gz
| Download URL | nn_engine_core-0.1.9.tar.gz |
|---|---|
| Size | 51.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ab3b33b81dbcd0c104232d5e8fef603fa5294f2dd45a90c4b7e22c8434e2f3f0
|
|
BLAKE2b-256 checksum How to use checksums |
15e2badd0de043dc728684e2a8442e22466c2bf68449e8ad029cad4f18d61d57
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 30, 2026.
Transparency logRelease files / nn_engine_core-0.1.9-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | nn_engine_core-0.1.9-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 13.2 MB |
| Tags | CPython 3.14 CPython 3.14 free-threading Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
761a8d3eaa13a38bff29ca6fdd2bef8bb2a9e7843bbbef005051579c95eba9b5
|
|
BLAKE2b-256 checksum How to use checksums |
5209ced2c4fefde1f750c78073b611e1e6d5cf3ac0fc1191b9028bd78964c744
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 30, 2026.
Transparency logRelease files / nn_engine_core-0.1.9-cp314-cp314t-macosx_26_0_arm64.whl
| Download URL | nn_engine_core-0.1.9-cp314-cp314t-macosx_26_0_arm64.whl |
|---|---|
| Size | 530.2 kB |
| Tags | CPython 3.14 CPython 3.14 free-threading macOS 26.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
94ca9ad65d3525f900bcb3d60dbf6c33d8923b00805361f46b46fa070c2620a8
|
|
BLAKE2b-256 checksum How to use checksums |
f284c4000649fcb0e33c386fa9e16f2b7ebd90e7b5c860de0fd4d30d9300d37c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 30, 2026.
Transparency logRelease files / nn_engine_core-0.1.9-cp314-cp314-win_amd64.whl
| Download URL | nn_engine_core-0.1.9-cp314-cp314-win_amd64.whl |
|---|---|
| Size | 853.8 kB |
| Tags | CPython 3.14 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
73787f77c42222b558ab135742d8ab17e356a3085c502638df480bd2c4e75a1b
|
|
BLAKE2b-256 checksum How to use checksums |
2b6f2923b7312089cca01b4e59de3c4335790075af7d9470804ef49371429a97
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 30, 2026.
Transparency logRelease files / nn_engine_core-0.1.9-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | nn_engine_core-0.1.9-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 13.2 MB |
| Tags | CPython 3.14 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
5cf3dcb47dcc95849a03f24c84eedfa3ad98c1754c3dea27834845adca1067f9
|
|
BLAKE2b-256 checksum How to use checksums |
b4cc767e2cecdc56aa283c684eed9de86445b1bf8ef70061064ac753708cab2a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 30, 2026.
Transparency logRelease files / nn_engine_core-0.1.9-cp314-cp314-macosx_26_0_arm64.whl
| Download URL | nn_engine_core-0.1.9-cp314-cp314-macosx_26_0_arm64.whl |
|---|---|
| Size | 514.6 kB |
| Tags | CPython 3.14 macOS 26.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
fd7e138921d9e21957be74c7633ebf923cd41898132a8689fd4e3d60112ec9dd
|
|
BLAKE2b-256 checksum How to use checksums |
e484d5f9f58e6846ea54a1154c6a4861be2d3ae434c48635de071339b546f9c8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 30, 2026.
Transparency logRelease files / nn_engine_core-0.1.9-cp313-cp313-win_amd64.whl
| Download URL | nn_engine_core-0.1.9-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 827.4 kB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
3a133921d2af38914d8323fd655929191ce5760f869147bf80e73715e2ca0874
|
|
BLAKE2b-256 checksum How to use checksums |
12bf44c4a5e12e9396456d6dd557111fb34f5ecfee4a368c31a445f1c6b57971
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 30, 2026.
Transparency logRelease files / nn_engine_core-0.1.9-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | nn_engine_core-0.1.9-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 13.2 MB |
| Tags | CPython 3.13 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
7fcf3d0114a8ea4706b4780c7a0b95eaf20444081e36fde9f0b1a8379ee80f53
|
|
BLAKE2b-256 checksum How to use checksums |
6bdb9d52acb2087d52852d5487908d859cb88d801884ac4b4a04fc7a782357a7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 30, 2026.
Transparency logRelease files / nn_engine_core-0.1.9-cp313-cp313-macosx_26_0_arm64.whl
| Download URL | nn_engine_core-0.1.9-cp313-cp313-macosx_26_0_arm64.whl |
|---|---|
| Size | 514.2 kB |
| Tags | CPython 3.13 macOS 26.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
9b69fc1f3d6ef95d09a623586f29eeed3599e20e8eb23f972afd733eaee481d9
|
|
BLAKE2b-256 checksum How to use checksums |
14e8f14e2ab602158b80e62ac932854c61b54a4b9e5de759a5691d2588e0de8e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 30, 2026.
Transparency logRelease files / nn_engine_core-0.1.9-cp312-cp312-win_amd64.whl
| Download URL | nn_engine_core-0.1.9-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 827.4 kB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
5f01284f26c9e605e4d3349aed326229639218a6907d6b6c61f30d0fc37e15c2
|
|
BLAKE2b-256 checksum How to use checksums |
a70c3ebdb40806bbc3b48ee068a92a13e3c517f388650529cf068f01eacbc90e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 30, 2026.
Transparency logRelease files / nn_engine_core-0.1.9-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | nn_engine_core-0.1.9-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 13.2 MB |
| Tags | CPython 3.12 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
6b808cc78c5ff1a257a1b902777d6313cb2121804e872b40e0a7dc902957cc4b
|
|
BLAKE2b-256 checksum How to use checksums |
b881366bc2d037d7ac031090f0a4284a02f55eaa48b2efbe3c8323222bfedf32
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 30, 2026.
Transparency logRelease files / nn_engine_core-0.1.9-cp312-cp312-macosx_26_0_arm64.whl
| Download URL | nn_engine_core-0.1.9-cp312-cp312-macosx_26_0_arm64.whl |
|---|---|
| Size | 514.2 kB |
| Tags | CPython 3.12 macOS 26.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
739b0d90b4942eaddc11269e778b85541551b26417efa5f888702f77a6905cf5
|
|
BLAKE2b-256 checksum How to use checksums |
629f3abeecac8316e31571c8315ddddbee4f5530fd7e4159637012b1667ff118
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 30, 2026.
Transparency logSecurity for nn-engine-core 0.1.9
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 12 files in this release have been uploaded with provenance metadata.
Attestation for nn_engine_core-0.1.9.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 30, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.