KeyDNN
KeyDNN is a lightweight deep learning framework built from scratch in Python, with a strong focus on:
- clean architecture and explicit interfaces
- a practical CPU / CUDA execution stack
- correctness-first design validated by CPU ↔ CUDA parity tests
It is designed to be both:
- a learning-friendly implementation of modern DL abstractions (Tensor, autograd, modules), and
- a performance-oriented sandbox for building real backends (native CPU kernels, CUDA kernels, vendor libraries).
🚧 Status: v2.1.0.
The v2 public API is largely stable and continues to evolve incrementally within the v2.x line. Breaking changes are avoided when possible and documented when necessary.
📚 Documentation: https://keywind127.github.io/keydnn_v2/
💻 Source: https://github.com/keywind127/keydnn_v2
Platform support
- OS: Windows 10 / 11 (x64 only)
- Python: ≥ 3.10
- CUDA: Optional (NVIDIA GPU required for acceleration)
CUDA acceleration requires a compatible CUDA runtime. Some backends use vendor libraries such as cuBLAS / cuDNN when available.
If CUDA is unavailable, CPU execution remains supported.
Support snapshot
- Windows (CPU): ✅ supported
- Windows (CUDA): ✅ supported (requires NVIDIA GPU + CUDA runtime; cuBLAS/cuDNN optional)
- Linux/macOS: ❌ not yet supported in v2.x (v0 has CPU-focused Linux support)
Highlights
- CUDA device-pointer–backed Tensor backend
- Explicit H2D / D2H / D2D memory boundaries (no implicit host materialization)
- Vendor-accelerated kernels:
- cuBLAS GEMM for
matmul - cuDNN acceleration for
conv2d/conv2d_transpose(when enabled)
- cuBLAS GEMM for
- CUDA implementations for core ops:
- elementwise ops
- reductions
- pooling
- in-place scalar ops (optimizer hot paths)
- Extensive CPU ↔ CUDA parity tests
- Standalone microbenchmarks under
scripts/
Installation
pip install keydnn
Development install:
git clone https://github.com/keywind127/keydnn_v2.git
cd keydnn_v2
pip install -e .
Quickstart
from keydnn.tensors import Tensor, Device
x = Tensor(shape=(2, 3), device=Device("cpu"), requires_grad=True)
y = (x * 2.0).sum()
y.backward()
print(x.grad.to_numpy())
CUDA example:
from keydnn.tensors import Tensor, Device
from keydnn.backend import cuda_available
device = Device("cuda:0") if cuda_available() else Device("cpu")
x = Tensor.rand((1024, 1024), device=device, requires_grad=True)
y = (x @ x.T).mean()
y.backward()
print("device:", device)
print("y:", y.item())
CUDA setup (Windows)
CUDA requires additional setup on Windows (CUDA runtime discovery and optional cuDNN). See the documentation for details:
Versioning note
KeyDNN v2 is a major rewrite and is not API-compatible with KeyDNN v0.
License
Licensed under the Apache License, Version 2.0.
Metadata
Release files for keydnn 2.1.0
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 | Actions |
|---|---|---|---|---|
| keydnn-2.1.0.tar.gz | 1.3 MB | Without provenance | Details for keydnn-2.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| keydnn-2.1.0-py3-none-any.whl | Python 3 | none | any | Details for keydnn-2.1.0-py3-none-any.whl |
Total release size: 2.7 MB
Release files / keydnn-2.1.0.tar.gz
| Download URL | keydnn-2.1.0.tar.gz |
|---|---|
| Size | 1.3 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0fd5e13f8b6381b1bf294856c4e7be42cb7a84b991a7b0253f957d3edc12ea90
|
|
BLAKE2b-256 checksum How to use checksums |
1a45e67886941f4e8e83b37f1fe91df468b7adcfe525ecbb7217791cf71e2b44
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.19
|
Release files / keydnn-2.1.0-py3-none-any.whl
| Download URL | keydnn-2.1.0-py3-none-any.whl |
|---|---|
| Size | 1.5 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b04fd06dd0e145dc8399a867208c20b638ca52c0ffe547c2e1281b8c3d258ab1
|
|
BLAKE2b-256 checksum How to use checksums |
d9d70ad0c1e191d6dab910f4b2d2c9512d36868bbef0e63db4ef5387be73b5a0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.19
|
Security for keydnn 2.1.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.