Skip to main content

KeyDNN is a lightweight deep learning framework with explicit CPU/CUDA execution and clean architectural boundaries.

Project description

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 (alpha).
The v2 public API is largely stable and actively evolving toward a v2.1 release. 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)
  • 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

keydnn-2.1.0a3.tar.gz (1.3 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

keydnn-2.1.0a3-py3-none-any.whl (1.5 MB view details)

Uploaded Python 3

File details

Details for the file keydnn-2.1.0a3.tar.gz.

File metadata

  • Download URL: keydnn-2.1.0a3.tar.gz
  • Upload date:
  • Size: 1.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for keydnn-2.1.0a3.tar.gz
Algorithm Hash digest
SHA256 f275f79dd7ba5563f434d25f5feeefae733a33a1e58fe8389fb93b5da8281a08
MD5 ee6af1382707a82baa00f3d4f1f8857e
BLAKE2b-256 0850b7fd759eb476be63aae9a7ab27a6e14d6a3bef1b3fabf9f04f35b39a589f

See more details on using hashes here.

File details

Details for the file keydnn-2.1.0a3-py3-none-any.whl.

File metadata

  • Download URL: keydnn-2.1.0a3-py3-none-any.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for keydnn-2.1.0a3-py3-none-any.whl
Algorithm Hash digest
SHA256 a932c42694ed3fa43ca01ad74a1e5eff96d634c8349a5efdfa17870abab19e19
MD5 e46ef66e6ed102e9985d2ae5b3c33cd1
BLAKE2b-256 22d90e2e1ed892bd13b0b4a086c9de36ab57529a71ba7e3c4eae792a40330948

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page