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,
)
Server (OpenAI-compatible, real inference)
pip install "winnex-nano[server]"
python -m winnex_nano.server_sse --model /path/to/checkpoint --port 30002
curl -N http://localhost:30002/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{"messages":[{"role":"user","content":"The capital of France is"}],
"max_tokens":32,"stream":true}'
It runs the native engine end to end: tokenizer → prefill → sample → step →
detokenize, on the KV cache, with greedy or temperature/top-k sampling, stop
sequences, a real chat template when the tokenizer has one, and SSE in OpenAI's
chunk format. /health reports the device and the weight mode that were
actually selected.
eng.prefill([...ids]) # -> logits for the last prompt token; fills the KV cache
eng.step(next_id) # -> logits for the next token; appends to the cache
eng.embed_ids([...ids]) # -> [n, hidden] rows, without touching the whole table
prefill+step is bit-identical to a full forward at every position (max
difference 0.0 over 85 tokens) and matches transformers to 1.2e-4.
Throughput, honestly. Qwen3-4B on an RTX 5060 Ti in device mode: prefill
40.6 tok/s, decode 2.6 tok/s. Decode is the slow one because attention, RoPE,
RMSNorm and the residual stream stay on the CPU by design — at seq_len=1 the
per-projection device round-trip dominates. Moving the whole layer to OpenCL is
the next real gain and is not done.
Changed in 0.1.28. Previous versions of this server answered every request with 12-character slices of the prompt. It was commented as a placeholder, but at the HTTP layer it was indistinguishable from a real completion. If you are running an older version, it is not inferring.
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:
| 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
viewinstead of a copy. The constructor reads the whole payload into astd::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
streammoderun_layerbuilds a freshLayerWeightsper 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.30
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 | |
|---|---|---|---|---|
| winnex_nano-0.1.30.tar.gz | 194.5 kB | With provenance | Details |
Built distributions (wheels)
Total release size: 5.3 MB
Release files / winnex_nano-0.1.30.tar.gz
| Download URL | winnex_nano-0.1.30.tar.gz |
|---|---|
| Size | 194.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1e47446661c0b9364b7b66c7e94dad4c32cce455c03bf2f31bf2edad90514147
|
|
BLAKE2b-256 checksum How to use checksums |
023a9b006667c34c2604586047c03a2cf10c7af8b93f603b4f9ab34c23758cc0
|
| 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 logRelease files / winnex_nano-0.1.30-cp313-cp313-win_amd64.whl
| Download URL | winnex_nano-0.1.30-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 310.6 kB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
7efde9db782c1cd41c45ed972c3f109d2fd1618eb239eb857069e5ca6cc31f15
|
|
BLAKE2b-256 checksum How to use checksums |
5055d023edc3a45b113cbfe280da11155a62bef370defa9529a2283c75329493
|
| 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 logRelease files / winnex_nano-0.1.30-cp313-cp313-manylinux_2_28_x86_64.whl
| Download URL | winnex_nano-0.1.30-cp313-cp313-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 649.7 kB |
| Tags | CPython 3.13 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
84a9d1bbb69acd05ed1e9f3900de7c69615d58c9e6a96c8f93dfb06510f27989
|
|
BLAKE2b-256 checksum How to use checksums |
39e048893860df1ff7cb75381ae8ad515459db8f81f8d44301e1c1e441baff30
|
| 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 logRelease files / winnex_nano-0.1.30-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | winnex_nano-0.1.30-cp313-cp313-macosx_11_0_arm64.whl |
|---|---|
| Size | 324.5 kB |
| Tags | CPython 3.13 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
c5d83e6cdccc15b4a918229f968f10d5705c360f2d982096aad233b64e93a95c
|
|
BLAKE2b-256 checksum How to use checksums |
512764dff5a192e8386fb1ceee668f44ad049c69fc3d125c4a2eb7a85785261b
|
| 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 logRelease files / winnex_nano-0.1.30-cp312-cp312-win_amd64.whl
| Download URL | winnex_nano-0.1.30-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 310.6 kB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
83257a5069ef2148ee289ea4518021d5bbf263627fd4dda89ab248356e8044be
|
|
BLAKE2b-256 checksum How to use checksums |
7c9ec0f99ec25fe3b7d4d2aad65d128ee19146883e1c95793a7218fc9593a28b
|
| 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 logRelease files / winnex_nano-0.1.30-cp312-cp312-manylinux_2_28_x86_64.whl
| Download URL | winnex_nano-0.1.30-cp312-cp312-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 649.5 kB |
| Tags | CPython 3.12 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
9f2d5bade96a457ca6990518df7077271efa53ad4b736fffcaf54ce850052cce
|
|
BLAKE2b-256 checksum How to use checksums |
b55c5271a84dec0d6c140f5ad3161629cbdc0add77814ee9d2720ec4e6398db9
|
| 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 logRelease files / winnex_nano-0.1.30-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | winnex_nano-0.1.30-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 324.5 kB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
20b5b1aa69a433902885678fe717bd8b918ec2b12738075b034ed8f0afe20d82
|
|
BLAKE2b-256 checksum How to use checksums |
5d00950d56f8944b744b54e8df268b7dab40b4a6d01e9b3de144d21d9664212b
|
| 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 logRelease files / winnex_nano-0.1.30-cp311-cp311-win_amd64.whl
| Download URL | winnex_nano-0.1.30-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 308.0 kB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
44b5abf41c01c1f80f84e7407e6a1c042219544da6b68d5ad0607b746c87464c
|
|
BLAKE2b-256 checksum How to use checksums |
06d7d9ece628b72a001090786da827e89ddcd0279a00237728c0a5e04069067b
|
| 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 logRelease files / winnex_nano-0.1.30-cp311-cp311-manylinux_2_28_x86_64.whl
| Download URL | winnex_nano-0.1.30-cp311-cp311-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 648.7 kB |
| Tags | CPython 3.11 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
9f2ad3db346c9e8bdd45ba4440c0dea5d1a50cd43b2bd75669786032c820a9c5
|
|
BLAKE2b-256 checksum How to use checksums |
d00129c103d99245b0ca83f9a97f451a5982b8751362d7f9e55f797571c543c9
|
| 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 logRelease files / winnex_nano-0.1.30-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | winnex_nano-0.1.30-cp311-cp311-macosx_11_0_arm64.whl |
|---|---|
| Size | 323.0 kB |
| Tags | CPython 3.11 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
ce01767e9af05dfed46fceb0c9e553c76000575ab2303865e0a36be43cba81c2
|
|
BLAKE2b-256 checksum How to use checksums |
8735793c2838cc060b458d5813a52505b395fbdb82114ba04ea9db9dcd3dcdb1
|
| 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 logRelease files / winnex_nano-0.1.30-cp310-cp310-win_amd64.whl
| Download URL | winnex_nano-0.1.30-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 306.8 kB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
0486d232058437ddd3de1058eab1952c23a81798648b64be7bb5119586b1373e
|
|
BLAKE2b-256 checksum How to use checksums |
ed6432ea1f1f4dcb7d2daec4ba1ffdc80b4c0bac63a4d9397feefefeca3f61f5
|
| 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 logRelease files / winnex_nano-0.1.30-cp310-cp310-manylinux_2_28_x86_64.whl
| Download URL | winnex_nano-0.1.30-cp310-cp310-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 647.3 kB |
| Tags | CPython 3.10 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
dc98321eb032cbba3f51e0436fd6dd73ad4a7c8cbd1c325b11bfb50f58511586
|
|
BLAKE2b-256 checksum How to use checksums |
9c26e5bf7080b46041f65df794a40b1ec68ded14ec85c0a981bfe6513dca8cb5
|
| 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 logRelease files / winnex_nano-0.1.30-cp310-cp310-macosx_11_0_arm64.whl
| Download URL | winnex_nano-0.1.30-cp310-cp310-macosx_11_0_arm64.whl |
|---|---|
| Size | 321.7 kB |
| Tags | CPython 3.10 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
9fcfd9d85e33365a413e0317a3c152591e23cf1d95f85b0268079fee5257d5dd
|
|
BLAKE2b-256 checksum How to use checksums |
442e9e4cdfdfb6758a5bd3861601eff8b3f2d24b386e803e5a1931d5d68b6bdc
|
| 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 logSecurity for winnex-nano 0.1.30
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.
Attestation for winnex_nano-0.1.30.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 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.