TokenVector.Inference 1.0.0

dotnet add package TokenVector.Inference --version 1.0.0
                    
NuGet\Install-Package TokenVector.Inference -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TokenVector.Inference" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TokenVector.Inference" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="TokenVector.Inference" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add TokenVector.Inference --version 1.0.0
                    
#r "nuget: TokenVector.Inference, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package TokenVector.Inference@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=TokenVector.Inference&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=TokenVector.Inference&version=1.0.0
                    
Install as a Cake Tool

🚀 TokenVector.Inference

License: MIT Target: .NET 8.0 AOT Ready Zero-GC Hot Path

TokenVector.Inference is an ultra-high-performance, Zero-GC Allocation, pure C# Native deep learning model serving, graph optimization, and precision quantization engine designed for the TokenVector AI ecosystem.


🌟 Key Capabilities & Highlights

  1. Zero-GC Allocation Hot Path:
    • Pre-allocates unified unmanaged ExecutionMemoryArena using Tensor Liveness Analysis.
    • session.Run(...) executes strictly 0 Byte of managed heap memory allocation.
  2. Zero-Copy Protobuf & ONNX Reader:
    • High-speed unmanaged parser (FastProtobufReader) decoding ONNX binaries directly from ReadOnlySpan<byte> without intermediate strings or object garbage.
  3. Graph Optimization Pipeline:
    • ConstantFoldingPass: Folds static parameter reshape, transpose, and permute passes ahead of time.
    • DeadCodeEliminationPass: Prunes disconnected operations and intermediate buffers.
    • OperatorFusionPass: Hardware-accelerated kernel fusion (FusedLinear, FusedConv2D, FusedRMSNorm) executing within CPU L1/L2 Cache.
  4. Quantization Engine (INT8 & FP8):
    • Static Post-Training Quantization (PTQ) via MinMax and KL-Divergence calibration.
    • Symmetric & Asymmetric INT8 acceleration with AVX2 (pmaddubsw + pmaddwd) & AVX-512 VNNI.
    • FP8 E4M3 and E5M2 bit-accurate formats for modern Transformer LLM architectures.
  5. Ultra-Low Latency Embedded Serving:
    • In-process REST/IPC engine (EmbeddedServer) responding with $< 1\text{ ms}$ latency.
    • Lock-free micro-batching (DynamicBatcher) using System.Threading.Channels and $100\ \mu\text{s} - 500\ \mu\text{s}$ spin-wait sliding windows.
  6. 100% C# .NET Native:
    • Fully independent and self-contained ($< 10\text{ MB}$ footprint), Native AOT-ready without external C++ DLL dependencies (no onnxruntime.dll or libtorch.so required).

📊 Competitor Matrix

Feature TokenVector.Inference Microsoft.ML.OnnxRuntime PyTorch LibTorch (C++)
Runtime Dependency 100% C# .NET Native (0 External DLLs) Depends on native C++ DLLs Depends on 500MB+ C++ binaries
GC Pressure on Inference Strictly 0 Bytes (Zero GC Hot Path) GCs & pins buffers across P/Invoke Heavy interop overhead
Model Load & Cold Start Ultra-Fast (Zero-Copy Parser) Slower runtime layer parsing Moderate
Embedded Latency $< 1\text{ ms}$ (Optimized Micro-Server) $\sim 2 - 5\text{ ms}$ $\sim 3 - 10\text{ ms}$
Package Footprint $< 10\text{ MB}$ (Lightweight & Self-Contained) $> 50 - 120\text{ MB}$ $> 500\text{ MB}$

⚡ Quick Start (C#)

using TokenVector.Inference.Runtime;
using TokenVector.Numerics.Core;

// 1. Load ONNX model and initialize Zero-GC Session
using var session = new InferenceSession("models/transformer.onnx");

// 2. Prepare Input NDArray
var input = new NDArray<float>(1, 64);
for (int i = 0; i < 64; i++) input.AsSpan()[i] = 1.0f;

// 3. Execute Zero-GC Inference
NDArray<float> output = session.Run(input);

Console.WriteLine($"Output Shape: [{string.Join(", ", output.Shape)}]");

🛠️ Build and Test

# Run full automated build, test, packaging, and benchmarks
.\build_inference.ps1 -Configuration Release
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 120 9/13/2026