Skip to main content

winnex-nano

Native Winnex inference engine — deterministic spectral tokenizer, multimodel weight balancing, and chunk streaming via the Madhava fast build.

Model-agnostic (Qwen / BERT / DeepSeek / GPT), C++20/OpenCL, no CUDA. Reuses the winnex-madhava engine kernels (QKᵀ matmul, selective-top-K with Cauchy-Schwarz bounds) — no code duplication.

Components

Module Purpose
SpectralTokenizer Character → quaternion spectrum (deterministic, no BPE, no vocabulary)
WeightBalancer Multimodel fusion: W' = Σᵢ αᵢ·R(qᵢ)·Wᵢ
StreamEngine Chunk generation via the Madhava fast build (working memory)
server_sse OpenAI-compatible /v1/chat/completions (stream + non-stream)

Installation

pip install winnex-nano

Requires winnex-madhava>=1.8.1 (the engine), numpy. Optional: winnex-nano[server] for the SSE server (fastapi, uvicorn, httpx).

Quick start

import winnex_nano as wn

# 1. Deterministic spectral tokenizer (no BPE, no vocabulary)
tok = wn.SpectralTokenizer(embed_dim=64)
states = tok.encode("Winnex AI")       # list of quaternions
text = tok.decode(states)              # round-trip: "Winnex AI"

# 2. Multimodel weight balancing: W' = Σ αᵢ·R(qᵢ)·Wᵢ
bal = wn.WeightBalancer()
model_a = {"layer.0.weight": [1, 2, 3, 4]}
model_b = {"layer.0.weight": [10, 20, 30, 40]}
a = wn.BlendWeight(); a.alpha = 0.5
b = wn.BlendWeight(); b.alpha = 0.5
fused = bal.blend([model_a, model_b], [a, b])   # [5.5, 11, 16.5, 22]

# 3. Streaming via the Madhava fast build
engine = wn.StreamEngine()
chunks = []
engine.stream(
    "O Madhava e deterministico.",
    lambda ctx, top: " chunk" if len(chunks) < 3 else "",
    lambda c: chunks.append(c.text) if not c.done else None,
)

SSE server (OpenAI-compatible)

pip install "winnex-nano[server]"
python -m winnex_nano.server_sse 30002
curl -N http://localhost:30002/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{"messages":[{"role":"user","content":"O Madhava e deterministico"}],"stream":true}'

Honest benchmark (vs BPE)

Run the full benchmark on Kaggle — installs winnex-nano from PyPI and reports round-trip, throughput and O(1) decode scaling on real multilingual text:

Kaggle

Metric winnex-nano spectral BPE (Qwen2.5)
Round-trip perfect 8/8 n/a
Char error rate 0.00% n/a
Encode throughput 234K chars/s 4.3M chars/s
Stream (3 chunks) 1.7 ms ~2.1 s (HTTP)
Vocabulary none 151K tokens

The spectral tokenizer is 100% deterministic with no vocabulary dependency, but 50–70× slower and ~1000× less compact than BPE. It is an autonomous encoding for the native multimodel engine, NOT a drop-in BPE replacement for a BPE-trained model.

Native forward pass — memory and speed

ForwardEngine runs a Qwen2/Qwen2.5/Qwen3/Llama checkpoint without torch, without transformers and without CUDA. Weights come straight out of the .safetensors file; the heavy matrix work goes to OpenCL.

import struct, numpy as np, winnex_nano as wn

# Map the payload instead of copying it. The 7B payload is 14.2 GB and the
# constructor copies it; view() borrows it and lets the kernel page it in.
with open(P, "rb") as f:
    hlen = struct.unpack("<Q", f.read(8))[0]
    header = f.read(hlen).decode()
st = wn.Safetensors.view(
    np.memmap(P, dtype=np.uint8, mode="r", offset=8 + hlen), header)

eng = wn.ForwardEngine(wn.load_config(cfg_path), st)
eng.enable_gpu()            # decides the weight strategy, see below
print(eng.weight_mode)      # "device" | "resident" | "stream" | "cpu"

enable_gpu() picks one of three strategies, in this order:

Mode What lives where When
device every projection on the GPU (bf16 when f32 does not fit); host keeps only norms and biases the model fits in VRAM
resident every projection in host RAM, stable pointers fits in 60% of available RAM, no usable GPU
stream one layer at a time through a scratch buffer otherwise

Measured on an RTX 5060 Ti (16 GB) and a 31 GB host, Qwen2.5-7B, 131 tokens:

Path PPL Time RSS Anonymous heap
CPU 15.55172 69.8 s 14.2 GB 0.69 GB
GPU device 15.55171 7.5 s 14.4 GB 0.74 GB

The perplexity difference is 7e-6 relative — the checkpoint is already bf16, so the GPU path's bf16 weights are the same numbers the CPU reads after widening them to f32. Nothing is lost that was ever in the file.

RSS stays high in both rows because the payload is mapped: those pages are the file, evictable under pressure, not heap. The number that decides whether a model fits a machine is the anonymous column.

Why it is built this way

  • view instead of a copy. The constructor reads the whole payload into a std::vector. For the 7B that is 14.2 GB before a single weight is used, and it is what made the Kaggle run die with "Kernel died". view() follows the MadhavaL2 contract: the caller owns the pointer, the engine never copies.
  • Weights keyed by tensor name, not by host pointer. In stream mode run_layer builds a fresh LayerWeights per call, so every matrix gets a new address and the device cache never hits — the GPU then re-uploads 14.2 GB per forward and measures slower than the CPU (90.8 s against 67.0 s). Naming the weights (L3.gate_proj) lets the device keep them for the life of the engine regardless of what the host allocator does.
  • bf16 weights when f32 does not fit. The 7B in f32 is 26.1 GB against a 16 GB card. The dtype is decided once for the whole model from the declared total; deciding per matrix mixes formats on the device and corrupts every launch after the first switch.
  • Tiled GEMM. The original kernel was one work-item per output element with no blocking — arithmetic intensity 1 FLOP/byte against a machine balance of ~26, i.e. the kernel waited on its own weight reads. 16x16 local-memory tiles cut global traffic per MAC by ~8x.
  • lm_head streamed. The embedding table is the largest single tensor (152064x3584). Both of its uses — one row per decoded token, and the logits projection — go through the offset table in 512-row blocks, so it costs 7.3 MB instead of 2.18 GB.

Splitting a model into shards

ForwardEngine takes one Safetensors. Checkpoints that arrive as model-00001-of-0000N.safetensors must be merged into a single file first — concatenating the payloads byte-for-byte, without decoding, preserves bf16 and avoids the 30 GB a float32 merge would need.

License

Business Source License 1.1 (BSL 1.1) — pay@winnex.ai.

Pre-patent: https://zenodo.org/records/21861809

Metadata

Release files for winnex-nano 0.1.28

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for winnex-nano 0.1.28
File Size Uploaded Provenance
winnex_nano-0.1.28.tar.gz 179.7 kB With provenance Details

Built distributions (wheels)

Table of built distributions (wheels) for winnex-nano 0.1.28
File
winnex_nano-0.1.28-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details
winnex_nano-0.1.28-cp313-cp313-manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.28+ x86-64 Details
winnex_nano-0.1.28-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details
winnex_nano-0.1.28-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
winnex_nano-0.1.28-cp312-cp312-manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.28+ x86-64 Details
winnex_nano-0.1.28-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details
winnex_nano-0.1.28-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
winnex_nano-0.1.28-cp311-cp311-manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.28+ x86-64 Details
winnex_nano-0.1.28-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details
winnex_nano-0.1.28-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
winnex_nano-0.1.28-cp310-cp310-manylinux_2_28_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.28+ x86-64 Details
winnex_nano-0.1.28-cp310-cp310-macosx_11_0_arm64.whl CPython 3.10 CPython 3.10 macOS 11.0+ ARM64 Details

Total release size: 5.0 MB

Release files / winnex_nano-0.1.28.tar.gz

Download URL winnex_nano-0.1.28.tar.gz
Size 179.7 kB
Tags Source
SHA-256 checksum
How to use checksums
8d9ad2b883f5578961398fe79d3698e5369590e1140e77751d7626e37ce40d57
BLAKE2b-256 checksum
How to use checksums
3fdc4b43477ced3f20bf01d2a0f8517e1de9dbd845d2bfa59eb39f5ffd7adde0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 22, 2026.

Transparency log

Release files / winnex_nano-0.1.28-cp313-cp313-win_amd64.whl

Download URL winnex_nano-0.1.28-cp313-cp313-win_amd64.whl
Size 286.6 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
d318fe5490841ad16f52f0136c970814e5154d3d84c002fc19dc6905874897b5
BLAKE2b-256 checksum
How to use checksums
5e3c0d5c452427c12bf3b3fcfbe4c990a563662f656a4183d87c4e8bac6798a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 22, 2026.

Transparency log

Release files / winnex_nano-0.1.28-cp313-cp313-manylinux_2_28_x86_64.whl

Download URL winnex_nano-0.1.28-cp313-cp313-manylinux_2_28_x86_64.whl
Size 621.7 kB
Tags CPython 3.13 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
099b3404d3d51ed8d19441adb38acbb39c67bfa559ef0f4f595a9324cf04e22f
BLAKE2b-256 checksum
How to use checksums
a03f99b65733275d76bd909579277bce95323b5c7c66cd8d539ed5c43af56558
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 22, 2026.

Transparency log

Release files / winnex_nano-0.1.28-cp313-cp313-macosx_11_0_arm64.whl

Download URL winnex_nano-0.1.28-cp313-cp313-macosx_11_0_arm64.whl
Size 298.5 kB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
9dae40a9038479d714710c4fe9260fab811f8a1294113bab50ad79bf09b17eea
BLAKE2b-256 checksum
How to use checksums
0516f4d39007b8a2172eb3f7593befed5c8b6eee1bd19579812eedfed81ab69b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 22, 2026.

Transparency log

Release files / winnex_nano-0.1.28-cp312-cp312-win_amd64.whl

Download URL winnex_nano-0.1.28-cp312-cp312-win_amd64.whl
Size 286.5 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
2ba08a5deb5f9f87dc10ec55cda045a90aafbf1a0cf0ff6c2b86e92d09955b98
BLAKE2b-256 checksum
How to use checksums
eba1bbb95ea03dd45ce7b8325b13003974ccc433300118c3f1f433cadf854cd4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 22, 2026.

Transparency log

Release files / winnex_nano-0.1.28-cp312-cp312-manylinux_2_28_x86_64.whl

Download URL winnex_nano-0.1.28-cp312-cp312-manylinux_2_28_x86_64.whl
Size 621.6 kB
Tags CPython 3.12 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
68aa795df217a85865cf18db3089b4a441e61351ec53a639a4e40151dd628d92
BLAKE2b-256 checksum
How to use checksums
d6726e059d364850c0c7ddcbd7225c22c8a73114f81ea1659a99218d885d815c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 22, 2026.

Transparency log

Release files / winnex_nano-0.1.28-cp312-cp312-macosx_11_0_arm64.whl

Download URL winnex_nano-0.1.28-cp312-cp312-macosx_11_0_arm64.whl
Size 298.5 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
f244d6d03ca9b9e31c21eef4d65d23f853a3118e14c76c1ddd58d31afedde5da
BLAKE2b-256 checksum
How to use checksums
edf516d88a3b3fcfaaebd24bfd6aaa54d50395dce8c33ae39cac12b24b5995f7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 22, 2026.

Transparency log

Release files / winnex_nano-0.1.28-cp311-cp311-win_amd64.whl

Download URL winnex_nano-0.1.28-cp311-cp311-win_amd64.whl
Size 284.0 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
2e2686d3828f410d5793817f76fd3fa9e6d7c0b1d98b7a18e1e287f0e8a3d2ad
BLAKE2b-256 checksum
How to use checksums
49a8ff6b56086ba7dde513e6bce45dff6351ebe2527ba36337e8e06ec6cf0fa8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 22, 2026.

Transparency log

Release files / winnex_nano-0.1.28-cp311-cp311-manylinux_2_28_x86_64.whl

Download URL winnex_nano-0.1.28-cp311-cp311-manylinux_2_28_x86_64.whl
Size 620.5 kB
Tags CPython 3.11 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
8212295ca0b8479c0b675014109659dc00955385e7985bd529c8954ac6b893ef
BLAKE2b-256 checksum
How to use checksums
ff4d1b05ed1a9a410532fbe48e99391b50c2732d9419b1fd8679b5b19bf380f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 22, 2026.

Transparency log

Release files / winnex_nano-0.1.28-cp311-cp311-macosx_11_0_arm64.whl

Download URL winnex_nano-0.1.28-cp311-cp311-macosx_11_0_arm64.whl
Size 297.1 kB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
e1c853ccf87e7714da242b881ab920c32e8548cb85129877c12b43ae93b6fd3b
BLAKE2b-256 checksum
How to use checksums
918e3d9c7cedbcc0389c54936435aee9125d37900bd267e59b7b49cb3fc1b478
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 22, 2026.

Transparency log

Release files / winnex_nano-0.1.28-cp310-cp310-win_amd64.whl

Download URL winnex_nano-0.1.28-cp310-cp310-win_amd64.whl
Size 283.0 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
c9dd0ff54e80eda4da668c7d42ba3edfe8267cb4b2de9d4b86574a9f847f1d9f
BLAKE2b-256 checksum
How to use checksums
a93c05f9cad5e66a27cd50e2615ea61c4606d074cbd89febfc6f32e75fbbb0b0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 22, 2026.

Transparency log

Release files / winnex_nano-0.1.28-cp310-cp310-manylinux_2_28_x86_64.whl

Download URL winnex_nano-0.1.28-cp310-cp310-manylinux_2_28_x86_64.whl
Size 618.7 kB
Tags CPython 3.10 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
71cc5d07112fc3af39442dc944abe4123fa194f752a58a1ec1f28c5047d9d9f4
BLAKE2b-256 checksum
How to use checksums
1135533c4b3081ff59f4b47523740512f069ab57db6010d09ad660e37548ce1d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 22, 2026.

Transparency log

Release files / winnex_nano-0.1.28-cp310-cp310-macosx_11_0_arm64.whl

Download URL winnex_nano-0.1.28-cp310-cp310-macosx_11_0_arm64.whl
Size 296.0 kB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
890adedad0f7ebc9965cd1c70891b7eeeb7a06de450b6180938142d591db4970
BLAKE2b-256 checksum
How to use checksums
b170acac1bcf8a8bc81af50ee61433e6546e20a29e16944f1f347b7315ee827c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 22, 2026.

Transparency log

Security for winnex-nano 0.1.28

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 13 files in this release have been uploaded with provenance metadata.

Select from 13 files

Attestation for winnex_nano-0.1.28.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 Oct 22, 2026.

Transparency log

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page