Metadata-Version: 2.4
Name: nni-sdk
Version: 3.0.3
Summary: Neural-Native Interconnect (nni-sdk) - 64-byte zero-copy AI networking
Author-email: NNI Labs <nnilabs.hq@gmail.com>
License: Proprietary - Free for personal, academic, and commercial binary use. Source
	code private to NNI Labs.
Requires-Python: >=3.11
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Homepage, https://nnilabs.pages.dev

# ⚡ NNI Labs — `nni-sdk` (The Neural-Native Interconnect)

[![PyPI](https://img.shields.io/pypi/v/nni-sdk)](https://pypi.org/project/nni-sdk/)
[![Python](https://img.shields.io/badge/python-3.11%2B-blue)](https://pypi.org/project/nni-sdk/)
[![License](https://img.shields.io/badge/license-Free%20Binary%20(Closed--Source)-008F5D)](#licensing)

**Stop shipping tensors over 1990s web protocols.**

The internet was built for humans reading web pages—not for AI models thinking together. When models, local SLMs, and edge NPUs communicate over HTTP/JSON, they pay a massive serialization and TCP tax on every hop.

**`nni-sdk` by NNI Labs** replaces that with a **64-byte cache-line-aligned network layer**—where models discover each other by capability instead of IP addresses, pass raw latent states instead of JSON text, and link across shared RAM, LAN, and encrypted global relays.

🌐 Website & Wire Spec: **https://nnilabs.pages.dev**  
✉️ Contact / OEM: **nnilabs.hq@gmail.com**

---

## 📊 Verified Telemetry Benchmark (128-Float Tensor Round-Trip)

| Deployment Tier | Traditional HTTP/JSON | `nni-sdk` Runtime | Result |
| :--- | :--- | :--- | :--- |
| **Same Machine (Shared Memory L3)** | 3,263 µs | **32.9 µs (0.03 ms)** | **~99x faster** (`mmap` Seqlock) |
| **Local Network (Direct 0-RTT UDP)** | 3,263 µs | **136.4 µs (0.13 ms)** | **~24x faster** (P2P UDP) |
| **Global WAN (India ↔ Sweden)** | ~570.0 ms *(est. w/ TLS)* | **385.4 ms** | **Speed-of-Light Floor** |
| **Local Wire Size (Round-Trip)** | ~1,432 Bytes | **128 Bytes** | **91.1% less data** |
| **WAN Egress Size (Round-Trip)** | ~1,832 Bytes *(w/ TLS)* | **200 Bytes** | **89.1% less cloud egress** |
| **Encryption & Memory** | Proxy TLS / JSON heap alloc | **E2E AEAD / Zero alloc** | **Relays stay blind** |

---

## 🚀 Quickstart (Copy & Run)

```bash
pip install nni-sdk
```

Zero dependencies. Works on **Python 3.11+** (Linux `x86_64` / `aarch64`, macOS Apple Silicon, Windows `x64`), with zero-copy NumPy and PyTorch support via `__array_interface__`.

### 1. Direct P2P UDP (Local / LAN — 128 Bytes Round-Trip)
```python
import threading
import time
import nni_sdk as nni

def run_node():
    node = nni.Node(port=19150)
    node.serve("vision", lambda tensor: [x * 2.0 for x in tensor])

threading.Thread(target=run_node, daemon=True).start()
time.sleep(0.3)

client = nni.Client()
client.connect_direct("vision", "127.0.0.1:19150")

query = nni.zeros(128)
query[0] = 42.0
result = client.send("vision", query)
print("Output:", result[0])  # 84.0
```

### 2. Shared Memory on Same Machine (L3 Cache — ~32.9 µs, 0 Wire Bytes)
```python
import threading
import time
import nni_sdk as nni

def run_shm():
    node = nni.Node(19999)
    node.serve_shm("nni_vision_shm", lambda t: [x * 2.0 for x in t])

threading.Thread(target=run_shm, daemon=True).start()
time.sleep(0.3)

client = nni.Client()
result = client.send_shm("nni_vision_shm", nni.from_list([42.0] * 128))
print("Output:", result[0])  # 84.0
```

### 3. Global Encrypted Mesh (Across NATs — 200 Bytes Round-Trip)
```python
import nni_sdk as nni

RELAY = "13.62.157.43:19200"  # Hosted backbone or self-hosted `nni relay`

# On your remote host (behind any NAT):
# node = nni.Node(port=19100, relay=RELAY)
# node.serve(0x01B2, lambda t: [x * 2.0 for x in t])

# From anywhere on Earth:
client = nni.Client.connect_mesh(RELAY)
result = client.send(0x01B2, [1.25] * 128)
print("Output:", result[0])
```

---

## 🧬 How the Network Works

* **Fixed 64-Byte Frames:** Every packet fits a single CPU cache line (`16B` 128-bit sparsity mask, `4B` scale, `4B` target ID, `4B` flags, `4B` sequence ID, `32B` payload supporting Top-8 exact FP32, 32× INT8, or 64× INT4, plus 512-dim chained bursts).
* **No DNS — Route by Capability:** Nodes register 128-bit capability masks; routers and relays match incoming vectors in nanoseconds via single-cycle hardware `POPCOUNT` Hamming distance.
* **Blind Relays:** Global WAN envelopes (`100 Bytes`) wrap the 64-byte payload in X25519 + ChaCha20-Poly1305 AEAD with a 128-packet sliding anti-replay window. Relays never hold keys or read tensors.

---

## 📜 Licensing

**NNI Labs Proprietary Free Binary License (Free to Use)**

* **Free in Production:** Pre-compiled `nni-sdk` wheels and `nni` binaries are **free for personal, academic, and commercial production use** with zero royalties and no per-packet fees.
* **Closed-Source Core:** Source code remains proprietary to **NNI Labs** and is not distributed. Decompiling, reverse engineering, or redistributing modified binaries is prohibited.
* **Enterprise / C-ABI OEM:** Need static libraries (`.a`/`.so`/`.dll`) or dedicated SLA relay clusters? Contact **nnilabs.hq@gmail.com**.

© 2026 **NNI Labs**. All rights reserved.
