HartsyInference.Cpu 2.0.0-alpha.16

This is a prerelease version of HartsyInference.Cpu.
dotnet add package HartsyInference.Cpu --version 2.0.0-alpha.16
                    
NuGet\Install-Package HartsyInference.Cpu -Version 2.0.0-alpha.16
                    
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="HartsyInference.Cpu" Version="2.0.0-alpha.16" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="HartsyInference.Cpu" Version="2.0.0-alpha.16" />
                    
Directory.Packages.props
<PackageReference Include="HartsyInference.Cpu" />
                    
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 HartsyInference.Cpu --version 2.0.0-alpha.16
                    
#r "nuget: HartsyInference.Cpu, 2.0.0-alpha.16"
                    
#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 HartsyInference.Cpu@2.0.0-alpha.16
                    
#: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=HartsyInference.Cpu&version=2.0.0-alpha.16&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=HartsyInference.Cpu&version=2.0.0-alpha.16&prerelease
                    
Install as a Cake Tool

HartsyInference

Run Flux, Qwen-Image, Wan, Whisper, Llama and 100+ other models from C#. No Python. No venv. No subprocess.

A complete AI inference engine written entirely in C#. It loads .safetensors, .gguf and PyTorch checkpoints directly and runs them on CUDA, Vulkan or CPU — as NuGet packages you reference from a .NET app. Nothing to install beyond your GPU driver.

Not a wrapper: the CUDA kernels are hand-written PTX loaded through the Driver API, the Vulkan kernels are SPIR-V, the CPU kernels are AVX2/AVX-512/NEON intrinsics.

⚠️ Alpha

Verified across a wide model set and in daily use, but public APIs still change between releases. Pin an exact version. Some models are built but not yet verified end-to-end, and video performance is still being optimized. Status is tracked openly — see the links at the bottom.

Install

dotnet add package HartsyInference             # everything
dotnet add package HartsyInference.Diffusion   # or just the modality you need

Generate an image

InferenceEngine is the facade — it owns model loading, caching and generation for every modality.

using HartsyInference.Engine;
using HartsyInference.Engine.Dispatch;
using HartsyInference.Engine.Requests;

using var engine = new InferenceEngine("cuda");   // "cpu", "vulkan", "cuda:1", "auto"

ImageResult image = await engine.Images.GenerateAsync(
    new ModelSpec { Requested = "sdxl", Modality = Modality.Image, LocalPath = "sdxl.safetensors" },
    new ImageRequest { Prompt = "a castle on a mountain at sunset, oil painting", Steps = 25 });

// image.Rgb is RGB24 bytes, image.Width × image.Height

Stream tokens from a local LLM

var spec = new ModelSpec { Requested = "qwen3", Modality = Modality.Text, LocalPath = "Qwen3-4B-Q4_K_M.gguf" };
var request = new TextRequest
{
    Messages = [new TextMessage { Role = TextRole.User, Content = "Explain flow matching." }],
};

await foreach (TextChunk chunk in engine.Text.StreamAsync(spec, request))
    if (chunk.Kind == TextChunkKind.Chunk)
        Console.Write(chunk.Text);

Every modality follows the same shape: engine.Images, engine.Text, engine.Video, engine.Speech, engine.Transcribe, engine.Music, engine.Vision, engine.Mesh, engine.World, engine.Restore, engine.VoiceConversion, engine.Fx, engine.Embeddings.

Performance

Faster than ComfyUI on the models most people run — same GPU, same checkpoint, same steps (RTX 4090): Flux-Schnell 2.4 s vs 3.8 s, Krea2-Turbo 4.5 s vs 6.5 s, Qwen-Image 20B 40.6 s vs 58.2 s, Flux-Dev 9.5 s vs 12.5 s. SDXL and Lumina 2 still trail; most video DiTs still trail.

Text decode beats llama.cpp at matched GGUF and quant on a 12 GB RTX 3060: Qwen2.5-0.5B 435.6 vs 328.9 tok/s, Gemma-3-1B 251.3 vs 196.8, Llama-3.2-1B 213.7 vs 192.0.

Full tables, including the losses, are in the repo under benchmarks/scoreboards/.

What it can run

  • Image — SD1.5, SDXL, Flux.1/.2, SD3.5, Qwen-Image (+Edit), Chroma, Krea 2, Z-Image, HiDream, AuraFlow, Lumina 2, Kandinsky 5, OmniGen 2, Ideogram 4. ControlNet, IP-Adapter (incl. FaceID), LoRA, img2img and inpaint.
  • Video — Wan 2.1/2.2, HunyuanVideo 13B, LTX-Video + LTX-2.3, MiniMax-H3, Kandinsky 5, plus SeedVR2 video/image restoration.
  • LLM — Llama, Qwen2/3, Gemma 2/3/4, Phi, Mistral, MoE giants, Mamba/RWKV, VLMs, embeddings and rerankers. GGUF quantized throughout, device-resident KV cache, chat templates.
  • Audio — Whisper and Moonshine (STT); Kokoro, Piper, StyleTTS2, F5-TTS, CosyVoice, VibeVoice, Bark (TTS); ACE-Step, MusicGen, YuE (music); 9 neural codecs; voice conversion, stem separation, enhancement.
  • Vision — CLIP / SigLIP / DINOv2, YOLOv8/11, RT-DETR, Grounding DINO, SAM 2, Depth-Anything-V2.
  • 3D — TripoSR, Hunyuan3D-2 (image → mesh, glTF/OBJ/PLY).
  • World — Oasis, DIAMOND (action-conditioned real-time frame generation).

Beyond one GPU

Memory-mapped weights run models far larger than VRAM — MiniMax-H3's 66 GB bf16 DiT is verified end-to-end on a 12 GB RTX 3060, loading at 943 MB RSS. One model can also be split across several GPUs with the VRAM pooled, over plain PCIe with no NVLink or P2P required: LLM layer splits, DiT block sharding, text-encoder/VAE placement, and CFG-parallel branches.

Packages

HartsyInference is a meta-package pulling in the core, all three backends and every modality. Reference individually if you only need one:

Core · ModelAssets (+ .Tokenizers) · Cpu · Cuda · Vulkan · LLM · Diffusion · Audio (+ .Phonemizer) · Vision · Video · ThreeD · World

Dependencies flow one way and GPU code stays behind IBackend, so a CPU-only package never drags in CUDA or Vulkan.

Requirements

.NET 8 or .NET 10. For CUDA: an NVIDIA GPU with compute capability 8.0+ and CUDA 12.x/13.x userspace libraries (FP8 paths need 8.9+; cuDNN 9.21+ optional for fused flash attention). For Vulkan: a Vulkan 1.3+ runtime and FP16 compute — most discrete GPUs from 2019+. The CPU backend needs nothing.

GitHub · SwarmUI backend extension · Model status · Benchmarks · Roadmap

Prefer a UI? The SwarmUI backend extension registers HartsyInference as a pure-C# alternative to the ComfyUI backend — full generation UI, model browser and parameter controls, with no Python environment.

License

MIT

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 is compatible.  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 (3)

Showing the top 3 NuGet packages that depend on HartsyInference.Cpu:

Package Downloads
HartsyInference

Meta-package for HartsyInference — a pure C#/.NET AI inference engine for non-LLM modalities (diffusion image generation, speech-to-text, text-to-speech, vision, video, interactive world models). Adds all backends (CPU, CUDA, Vulkan) and modality packages in one reference.

HartsyInference.Cuda

CUDA GPU inference backend for HartsyInference with PTX kernels and cuBLAS integration.

HartsyInference.Vulkan

Vulkan compute backend for HartsyInference. Cross-vendor GPU inference (NVIDIA, AMD, Intel, Apple via MoltenVK) via SPIR-V compute shaders and P/Invoke into the Vulkan loader.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.0-alpha.16 0 8/7/2026
2.0.0-alpha.15 24 8/7/2026
2.0.0-alpha.14 38 8/6/2026
2.0.0-alpha.12 40 8/6/2026
2.0.0-alpha.11 43 8/5/2026
2.0.0-alpha.10 65 8/3/2026
2.0.0-alpha.9 61 8/2/2026
2.0.0-alpha.8 76 8/2/2026
2.0.0-alpha.6 64 8/1/2026
2.0.0-alpha.5 64 7/28/2026
2.0.0-alpha.4 73 7/26/2026
2.0.0-alpha.3 66 7/25/2026
2.0.0-alpha.1 78 7/22/2026
1.0.0-alpha.52 75 7/18/2026
1.0.0-alpha.51 58 7/18/2026
1.0.0-alpha.50 66 7/18/2026
1.0.0-alpha.49 66 7/16/2026
1.0.0-alpha.48 73 7/12/2026
1.0.0-alpha.47 71 7/10/2026
1.0.0-alpha.46 72 7/9/2026
Loading failed